{"id":20453267,"url":"https://github.com/phpcsstandards/php_codesniffer","last_synced_at":"2025-05-16T12:00:30.783Z","repository":{"id":206080915,"uuid":"715878832","full_name":"PHPCSStandards/PHP_CodeSniffer","owner":"PHPCSStandards","description":"PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.","archived":false,"fork":false,"pushed_at":"2025-05-07T03:48:52.000Z","size":212029,"stargazers_count":1207,"open_issues_count":148,"forks_count":73,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-05-09T11:18:28.519Z","etag":null,"topics":["automation","cli","coding-standards","php","phpcbf","phpcs","psr1","psr12","psr2","qa","static-analysis"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"squizlabs/PHP_CodeSniffer","license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PHPCSStandards.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"open_collective":"php_codesniffer","github":["PHPCSStandards","jrfnl"],"thanks_dev":"u/gh/phpcsstandards"}},"created_at":"2023-11-08T02:29:53.000Z","updated_at":"2025-05-09T10:31:53.000Z","dependencies_parsed_at":"2023-12-04T10:24:28.974Z","dependency_job_id":"39aef19f-7fb1-434f-970a-9c246bbc05a8","html_url":"https://github.com/PHPCSStandards/PHP_CodeSniffer","commit_stats":{"total_commits":6763,"total_committers":272,"mean_commits":"24.863970588235293","dds":"0.35960372615703096","last_synced_commit":"c2b6235e5ba1c2665c520564c5f978f393a3b382"},"previous_names":["phpcsstandards/php_codesniffer"],"tags_count":106,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHPCSStandards%2FPHP_CodeSniffer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHPCSStandards%2FPHP_CodeSniffer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHPCSStandards%2FPHP_CodeSniffer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHPCSStandards%2FPHP_CodeSniffer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PHPCSStandards","download_url":"https://codeload.github.com/PHPCSStandards/PHP_CodeSniffer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254527071,"owners_count":22085917,"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":["automation","cli","coding-standards","php","phpcbf","phpcs","psr1","psr12","psr2","qa","static-analysis"],"created_at":"2024-11-15T11:12:18.522Z","updated_at":"2025-05-16T12:00:30.730Z","avatar_url":"https://github.com/PHPCSStandards.png","language":"PHP","readme":"# PHP_CodeSniffer\n\n\u003cdiv aria-hidden=\"true\"\u003e\n\n[![Latest Stable Version](https://img.shields.io/packagist/v/squizlabs/php_codesniffer?label=Stable)](https://github.com/PHPCSStandards/PHP_CodeSniffer/releases)\n[![Validate](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/workflows/validate.yml/badge.svg?branch=master)](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/workflows/validate.yml)\n[![Test](https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/workflows/test.yml/badge.svg?branch=master)][GHA-test]\n[![Coverage Status](https://coveralls.io/repos/github/PHPCSStandards/PHP_CodeSniffer/badge.svg?branch=master)](https://coveralls.io/github/PHPCSStandards/PHP_CodeSniffer?branch=master)\n[![License](https://img.shields.io/github/license/PHPCSStandards/PHP_CodeSniffer)](https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt)\n\n![Minimum PHP Version](https://img.shields.io/packagist/dependency-v/squizlabs/php_codesniffer/php.svg)\n[![Tested on PHP 5.4 to 8.4](https://img.shields.io/badge/tested%20on-PHP%205.4%20|%205.5%20|%205.6%20|%207.0%20|%207.1%20|%207.2%20|%207.3%20|%207.4%20|%208.0%20|%208.1%20|%208.2%20|%208.3%20|%208.4-brightgreen.svg?maxAge=2419200)][GHA-test]\n\n[GHA-test]: https://github.com/PHPCSStandards/PHP_CodeSniffer/actions/workflows/test.yml\n\n\u003c/div\u003e\n\n\u003e [!NOTE]\n\u003e This package is the official continuation of the now abandoned [PHP_CodeSniffer package which was created by Squizlabs](https://github.com/squizlabs/PHP_CodeSniffer).\n\n## About\n\nPHP_CodeSniffer is a set of two PHP scripts; the main `phpcs` script that tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard, and a second `phpcbf` script to automatically correct coding standard violations. PHP_CodeSniffer is an essential development tool that ensures your code remains clean and consistent.\n\n\n## Requirements\n\nPHP_CodeSniffer requires PHP version 5.4.0 or greater, although individual sniffs may have additional requirements such as external applications and scripts. See the [Configuration Options manual page](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Configuration-Options) for a list of these requirements.\n\nIf you're using PHP_CodeSniffer as part of a team, or you're running it on a [CI](https://en.wikipedia.org/wiki/Continuous_integration) server, you may want to configure your project's settings [using a configuration file](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Advanced-Usage#using-a-default-configuration-file).\n\n\n## Installation\n\nThe easiest way to get started with PHP_CodeSniffer is to download the Phar files for each of the commands:\n```bash\n# Download using curl\ncurl -OL https://phars.phpcodesniffer.com/phpcs.phar\ncurl -OL https://phars.phpcodesniffer.com/phpcbf.phar\n\n# Or download using wget\nwget https://phars.phpcodesniffer.com/phpcs.phar\nwget https://phars.phpcodesniffer.com/phpcbf.phar\n\n# Then test the downloaded PHARs\nphp phpcs.phar -h\nphp phpcbf.phar -h\n```\n\nThese Phars are signed with the official Release key for PHPCS with the\nfingerprint `689D AD77 8FF0 8760 E046 228B A978 2203 05CD 5C32`.\n\nAs of PHP_CodeSniffer 3.10.3, the provenance of PHAR files associated with a release can be verified via [GitHub Artifact Attestations](https://docs.github.com/en/actions/security-for-github-actions/using-artifact-attestations/using-artifact-attestations-to-establish-provenance-for-builds) using the [GitHub CLI tool](https://cli.github.com/) with the following command: `gh attestation verify [phpcs|phpcbf].phar -o PHPCSStandards`.\n\n### Composer\nIf you use Composer, you can install PHP_CodeSniffer system-wide with the following command:\n```bash\ncomposer global require \"squizlabs/php_codesniffer=*\"\n```\nMake sure you have the composer bin dir in your PATH. The default value is `~/.composer/vendor/bin/`, but you can check the value that you need to use by running `composer global config bin-dir --absolute`.\n\nOr alternatively, include a dependency for `squizlabs/php_codesniffer` in your `composer.json` file. For example:\n\n```json\n{\n    \"require-dev\": {\n        \"squizlabs/php_codesniffer\": \"^3.0\"\n    }\n}\n```\n\nYou will then be able to run PHP_CodeSniffer from the vendor bin directory:\n```bash\n./vendor/bin/phpcs -h\n./vendor/bin/phpcbf -h\n```\n\n### Phive\nIf you use Phive, you can install PHP_CodeSniffer as a project tool using the following commands:\n```bash\nphive install --trust-gpg-keys 689DAD778FF08760E046228BA978220305CD5C32 phpcs\nphive install --trust-gpg-keys 689DAD778FF08760E046228BA978220305CD5C32 phpcbf\n```\nYou will then be able to run PHP_CodeSniffer from the `tools` directory:\n```bash\n./tools/phpcs -h\n./tools/phpcbf -h\n```\n\n### Git Clone\nYou can also download the PHP_CodeSniffer source and run the `phpcs` and `phpcbf` commands directly from the Git clone:\n```bash\ngit clone https://github.com/PHPCSStandards/PHP_CodeSniffer.git\ncd PHP_CodeSniffer\nphp bin/phpcs -h\nphp bin/phpcbf -h\n```\n\n## Getting Started\n\nThe default coding standard used by PHP_CodeSniffer is the PEAR coding standard. To check a file against the PEAR coding standard, simply specify the file's location:\n```bash\nphpcs /path/to/code/myfile.php\n```\nOr if you wish to check an entire directory you can specify the directory location instead of a file.\n```bash\nphpcs /path/to/code-directory\n```\nIf you wish to check your code against the PSR-12 coding standard, use the `--standard` command line argument:\n```bash\nphpcs --standard=PSR12 /path/to/code-directory\n```\n\nIf PHP_CodeSniffer finds any coding standard errors, a report will be shown after running the command.\n\nFull usage information and example reports are available on the [usage page](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Usage).\n\n## Documentation\n\nThe documentation for PHP_CodeSniffer is available on the [GitHub wiki](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki).\n\n## Issues\n\nBug reports and feature requests can be submitted on the [GitHub Issue Tracker](https://github.com/PHPCSStandards/PHP_CodeSniffer/issues).\n\n## Contributing\n\nSee [CONTRIBUTING.md](.github/CONTRIBUTING.md) for information.\n\n## Versioning\n\nPHP_CodeSniffer uses a `MAJOR.MINOR.PATCH` version number format.\n\nThe `MAJOR` version is incremented when:\n- backwards-incompatible changes are made to how the `phpcs` or `phpcbf` commands are used, or\n- backwards-incompatible changes are made to the `ruleset.xml` format, or\n- backwards-incompatible changes are made to the API used by sniff developers, or\n- custom PHP_CodeSniffer token types are removed, or\n- existing sniffs are removed from PHP_CodeSniffer entirely\n\nThe `MINOR` version is incremented when:\n- new backwards-compatible features are added to the `phpcs` and `phpcbf` commands, or\n- backwards-compatible changes are made to the `ruleset.xml` format, or\n- backwards-compatible changes are made to the API used by sniff developers, or\n- new sniffs are added to an included standard, or\n- existing sniffs are removed from an included standard\n\n\u003e NOTE: Backwards-compatible changes to the API used by sniff developers will allow an existing sniff to continue running without producing fatal errors but may not result in the sniff reporting the same errors as it did previously without changes being required.\n\nThe `PATCH` version is incremented when:\n- backwards-compatible bug fixes are made\n\n\u003e NOTE: As PHP_CodeSniffer exists to report and fix issues, most bugs are the result of coding standard errors being incorrectly reported or coding standard errors not being reported when they should be. This means that the messages produced by PHP_CodeSniffer, and the fixes it makes, are likely to be different between PATCH versions.\n","funding_links":["https://opencollective.com/php_codesniffer","https://github.com/sponsors/PHPCSStandards","https://github.com/sponsors/jrfnl","https://thanks.dev/u/gh/phpcsstandards"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpcsstandards%2Fphp_codesniffer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphpcsstandards%2Fphp_codesniffer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpcsstandards%2Fphp_codesniffer/lists"}