{"id":18849917,"url":"https://github.com/asispts/ptscs","last_synced_at":"2025-04-14T09:21:25.608Z","repository":{"id":51332866,"uuid":"507166381","full_name":"asispts/ptscs","owner":"asispts","description":"PSR-12 coding standard with additional strict rules","archived":false,"fork":false,"pushed_at":"2023-11-10T14:13:11.000Z","size":234,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-09T12:38:37.978Z","etag":null,"topics":["coding-standard","coding-style","php","phpcs-standard","psr-12"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/asispts/ptscs","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/asispts.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-06-24T23:15:33.000Z","updated_at":"2023-11-06T03:58:13.000Z","dependencies_parsed_at":"2023-02-12T15:30:39.220Z","dependency_job_id":"4b9cf8a3-aca3-4a18-b706-cce957f408a8","html_url":"https://github.com/asispts/ptscs","commit_stats":{"total_commits":77,"total_committers":1,"mean_commits":77.0,"dds":0.0,"last_synced_commit":"78725984261f0c0b42a49c07477e6afc454061b4"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asispts%2Fptscs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asispts%2Fptscs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asispts%2Fptscs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asispts%2Fptscs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asispts","download_url":"https://codeload.github.com/asispts/ptscs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248852186,"owners_count":21171843,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["coding-standard","coding-style","php","phpcs-standard","psr-12"],"created_at":"2024-11-08T03:26:44.962Z","updated_at":"2025-04-14T09:21:25.587Z","avatar_url":"https://github.com/asispts.png","language":"PHP","readme":"\u003cdiv align=\"center\"\u003e\n  \u003csamp\u003e\n    \u003ch1\u003eptscs\u003c/h1\u003e\n    \u003ch3\u003e\u0026raquo; PSR-12 coding standard with additional strict rules  \u0026laquo;\u003c/h3\u003e\n  \u003c/samp\u003e\n\n  [![Build](https://github.com/asispts/ptscs/actions/workflows/ci.yml/badge.svg)](https://github.com/asispts/ptscs/actions/workflows/ci.yml)\n  [![](https://img.shields.io/github/license/asispts/ptscs)](./LICENSE)\n  [![](https://img.shields.io/packagist/php-v/asispts/ptscs/dev-main)](https://github.com/asispts/ptscs)\n  [![](https://img.shields.io/packagist/dt/asispts/ptscs)](https://packagist.org/packages/asispts/ptscs)\n\n\n  [Installation](#installation) \u0026#10022;\n  [Usage](#usage) \u0026#10022;\n  [Notable coding standard](#notable-coding-standard) \u0026#10022;\n  [Contributing](#contributing) \u0026#10022;\n  [License](#license)\n\n  \u0026nbsp;\n\u003c/div\u003e\n\n\n\n`ptscs` is a coding standard for [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) that follows the PSR-12 with additional strict rules. It is intended to help developers maintain consistency and readability in their codebase, and to encourage best practices.\n\n## Installation\nYou can install with composer\n```\ncomposer require --dev asispts/ptscs\n```\n\n## Usage\nOnce installed, you can create a `phpcs.xml.dist` file to define your PHPCS configuration and then configure your text editor or workflow to lint or fix the codebase based on this configuration. Here is an example phpcs.xml.dist file:\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cruleset xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n  xsi:noNamespaceSchemaLocation=\"vendor/squizlabs/php_codesniffer/phpcs.xsd\"\u003e\n\n  \u003carg name=\"colors\"/\u003e\n  \u003carg name=\"parallel\" value=\"8\"/\u003e\n  \u003carg value=\"psv\"/\u003e\n  \u003carg name=\"extensions\" value=\"php\"/\u003e\n\n  \u003cfile\u003esrc\u003c/file\u003e\n  \u003cfile\u003etests\u003c/file\u003e\n\n  \u003cexclude-pattern\u003evendor\u003c/exclude-pattern\u003e\n\n  \u003crule ref=\"ptscs\"/\u003e\n\u003c/ruleset\u003e\n```\nYou can use `phpcs` to validate your source code against this standard or `phpcbf` to automatically fix any violations.\n\nTo run `phpcs`, execute the following command:\n```\nvendor/bin/phpcs\n```\nTo automatically fix any coding standard violations, execute the following command:\n```\nvendor/bin/phpcbf\n```\n\n### Excluding Some Rules\nYou can exclude some rules by modifying the `phpcs.xml.dist` file. For example, if you want to exclude the rule that requires classes to be declared as either `final` or `abstract` in the `src/Entity` directory of a Symfony project, you can add the following to your `phpcs.xml.dist` file:\n```xml\n\u003crule ref=\"SlevomatCodingStandard.Classes.RequireAbstractOrFinal\"\u003e\n    \u003cexclude-pattern\u003esrc/Entity\u003c/exclude-pattern\u003e\n\u003c/rule\u003e\n```\n\nThis will exclude the `RequireAbstractOrFinal` rule for the `src/Entity` directory. You can customize the rule and the directory as per your needs. By excluding some rules, you can customize the coding standard to better suit your project's requirements.\n\n## Notable coding standard\nAs mentioned, this coding standard use PSR-12 with some exceptions and additional strict rules. Here are some notable additional strict rules.\n\n1. We exclude some PSR-12 rules to allow `declare(strict_types=1)` on the same line as PHP open tag.\n```php\n\u003c?php declare(strict_types=1)\n```\n2.  `declare(strict_types=1)` is required in all PHP files.\n3. `snake_case` is allowed in test method names\n```php\npublic function test_something(): void\n{\n}\n```\n4. All classes should be declared as either `final` or `abstract`\n```php\n// Prohibited.\n// Should be declared as either final or abstract\nclass foobar\n{\n}\n```\n5. Filenames must match the class names.\n\nThe complete set of rules can be seen in [RULES.md](./RULES.md) file. These rules are intended to promote cleaner, more readable, and more maintainable code.\n\n\n## Contributing\nWe welcome contributions from the community in all forms. You can report issues, suggest improvements or submit pull requests.\n\nFor major changes, it is highly recommended to open an issue first to discuss the proposed changes with the project maintainers.\n\n## License\nReleased under [MIT License](./LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasispts%2Fptscs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasispts%2Fptscs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasispts%2Fptscs/lists"}