{"id":13424889,"url":"https://github.com/squizlabs/php_codesniffer","last_synced_at":"2025-05-13T15:11:16.693Z","repository":{"id":1777238,"uuid":"2699935","full_name":"squizlabs/PHP_CodeSniffer","owner":"squizlabs","description":"PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.","archived":false,"fork":false,"pushed_at":"2024-04-01T20:37:32.000Z","size":201893,"stargazers_count":10741,"open_issues_count":281,"forks_count":1473,"subscribers_count":193,"default_branch":"master","last_synced_at":"2025-04-23T18:56:11.793Z","etag":null,"topics":["automation","cli","coding-standards","php","qa","static-analysis"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/squizlabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"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}},"created_at":"2011-11-03T04:06:24.000Z","updated_at":"2025-04-23T18:11:44.000Z","dependencies_parsed_at":"2023-07-05T18:49:38.432Z","dependency_job_id":"4e0af541-b7bb-4cb2-b53e-5fcece0ee0aa","html_url":"https://github.com/squizlabs/PHP_CodeSniffer","commit_stats":{"total_commits":6009,"total_committers":253,"mean_commits":23.75098814229249,"dds":0.2792477949742054,"last_synced_commit":"8dfb63220e1fd5cfcce07f20bc24f75a5269597c"},"previous_names":[],"tags_count":88,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squizlabs%2FPHP_CodeSniffer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squizlabs%2FPHP_CodeSniffer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squizlabs%2FPHP_CodeSniffer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squizlabs%2FPHP_CodeSniffer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/squizlabs","download_url":"https://codeload.github.com/squizlabs/PHP_CodeSniffer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253969259,"owners_count":21992263,"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","qa","static-analysis"],"created_at":"2024-07-31T00:01:00.592Z","updated_at":"2025-05-13T15:11:11.678Z","avatar_url":"https://github.com/squizlabs.png","language":"PHP","readme":"\u003e [!WARNING]\n\u003e This repository has been abandoned. Its successor is [PHPCSStandards/PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer/)\n\u003e\n\u003e See issue [#3932](https://github.com/squizlabs/PHP_CodeSniffer/issues/3932) for more information.\n\u003e\n\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[![Build Status](https://github.com/squizlabs/PHP_CodeSniffer/workflows/Validate/badge.svg?branch=master)](https://github.com/squizlabs/PHP_CodeSniffer/actions)\n[![Build Status](https://github.com/squizlabs/PHP_CodeSniffer/workflows/Test/badge.svg?branch=master)](https://github.com/squizlabs/PHP_CodeSniffer/actions)\n[![Code consistency](http://squizlabs.github.io/PHP_CodeSniffer/analysis/squizlabs/PHP_CodeSniffer/grade.svg)](http://squizlabs.github.io/PHP_CodeSniffer/analysis/squizlabs/PHP_CodeSniffer)\n[![Join the chat at https://gitter.im/squizlabs/PHP_CodeSniffer](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/squizlabs/PHP_CodeSniffer?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\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/squizlabs/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/squizlabs/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```\n# Download using curl\ncurl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar\ncurl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar\n\n# Or download using wget\nwget https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar\nwget https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar\n\n# Then test the downloaded PHARs\nphp phpcs.phar -h\nphp phpcbf.phar -h\n```\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.*\"\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### Phive\nIf you use Phive, you can install PHP_CodeSniffer as a project tool using the following commands:\n```bash\nphive install phpcs\nphive install 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### PEAR\nIf you use PEAR, you can install PHP_CodeSniffer using the PEAR installer. This will make the `phpcs` and `phpcbf` commands immediately available for use. To install PHP_CodeSniffer using the PEAR installer, first ensure you have [installed PEAR](http://pear.php.net/manual/en/installation.getting.php) and then run the following command:\n```bash\npear install PHP_CodeSniffer\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/squizlabs/PHP_CodeSniffer.git\ncd PHP_CodeSniffer\nphp bin/phpcs -h\nphp bin/phpcbf -h\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/squizlabs/PHP_CodeSniffer/wiki/Usage).\n\n## Documentation\n\nThe documentation for PHP_CodeSniffer is available on the [Github wiki](https://github.com/squizlabs/PHP_CodeSniffer/wiki).\n\n## Issues\n\nBug reports and feature requests can be submitted on the [Github Issue Tracker](https://github.com/squizlabs/PHP_CodeSniffer/issues).\n\n## Contributing\n\nSee [CONTRIBUTING.md](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":[],"categories":["QA Tools","类库"],"sub_categories":["Nginx setup","代码检查/静态分析"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsquizlabs%2Fphp_codesniffer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsquizlabs%2Fphp_codesniffer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsquizlabs%2Fphp_codesniffer/lists"}