Generated by GPT-5-mini| PHP_CodeSniffer | |
|---|---|
| Name | PHP_CodeSniffer |
| Developer | Squiz, Chris Shiflett, Gregory Beaver, and contributors |
| Released | 2006 |
| Programming language | PHP |
| Operating system | Cross-platform |
| License | BSD |
PHP_CodeSniffer PHP_CodeSniffer is a PHP-based static analysis tool that detects coding standard violations in PHP, JavaScript, and CSS source files. It is used by developers, organizations, and continuous integration systems to enforce style and formatting across projects, and it integrates with editors, build systems, and package managers to provide automated linting and reporting.
PHP_CodeSniffer inspects source code for adherence to predefined rules and reports deviations, enabling teams to maintain consistency across repositories and deliverables associated with GitHub, GitLab, Bitbucket, Composer (software), and Packagist. It operates as a command-line application and as libraries callable from environments such as Travis CI, Jenkins, CircleCI, Azure DevOps Services, and GitHub Actions. The project interacts with ecosystems including PEAR, PECL, Symfony (software), Laravel (framework), and Zend Framework, facilitating adoption across enterprise and open-source projects supported by organizations such as Google, Facebook, Amazon (company), Microsoft.
PHP_CodeSniffer provides a set of core components: a tokenizer, a file parser, and a rule engine used by the standards and sniffs. The tokenizer maps source to tokens akin to processing in PHPParser, while the rule engine applies checks influenced by conventions from PSR-1, PSR-2, PSR-12, WordPress, Drupal, PEAR (PHP) and company-specific guides from Netflix, Airbnb, Twitter, Spotify. Reporting modules integrate with formatters that output for systems such as JUnit, Checkstyle, SonarQube, Sentry (software), and New Relic, while the command interface supports flags modeled after tools like PHPCSFixer and ESLint.
Users install PHP_CodeSniffer via Composer (software), package repositories, or system package managers and configure it using rulesets, XML configuration, and CLI arguments. Rulesets reference coding standards derived from documents like PSR-12, and configuration files can be stored in repositories alongside manifests used by npm, Yarn, Bower (package manager), and build files for Maven, Gradle, Make (software) or Ant (software). Integration with editors such as Visual Studio Code, Sublime Text, PhpStorm, Vim, Emacs, and Atom (text editor) is enabled through plugins and language servers similar to Language Server Protocol, allowing instantaneous feedback for contributors collaborating on projects under governance by entities like Apache Software Foundation, Linux Foundation, Mozilla Foundation, and Wikimedia Foundation.
The tool implements a modular sniff architecture where each sniff encapsulates a rule inspired by guidelines from bodies like PHP-FIG, The Linux Kernel, FreeBSD, Apple Inc., Google (company), Intel, Oracle Corporation, and public style guides such as those by PEAR (PHP), Drupal Association, WordPress Foundation, and Symfony (software). Sniffs can be community-contributed, packaged similarly to plugins for WordPress, extensions like those for Drupal, or vendor-specific rule sets used by firms including Adobe Inc., Salesforce, Uber Technologies, and Shopify. Developers author custom sniffs in PHP, leveraging APIs comparable to those in PHPUnit, PHPMD, Psalm (software), and Phan (software), with patterns inspired by static analysis projects such as Clang, Coverity, SonarQube, and FindBugs.
PHP_CodeSniffer integrates into CI/CD pipelines, IDEs, and pre-commit tooling, interacting with systems like Prettier, Husky (software), Lint-staged, Overcommit, and orchestration platforms including Kubernetes, Docker, OpenShift, and Heroku. It is frequently combined with testing frameworks and quality gates such as PHPUnit, Behat, PHPSpec, Cypress (software), and dashboarding services like Jira, Confluence, Trello, Asana (company), and Slack. Enterprise usage often ties PHP_CodeSniffer reports into governance workflows operated by Atlassian, Red Hat, IBM, and professional services from firms like Accenture and Deloitte.
Originating in the mid-2000s, PHP_CodeSniffer evolved through contributions from Squiz and individual maintainers alongside community members from projects like PEAR, phpBB, Drupal, and WordPress. Its development has been tracked and managed on platforms including SourceForge, GitHub, and mirrored on GitLab. Key influences include coding standardization efforts by PHP-FIG and high-profile style guides from Google (company), Symfony (software), and the Linux Foundation. The project has seen releases coordinated by contributors who also worked on tools such as PHPUnit, Composer (software), and PHPMD.
PHP_CodeSniffer is widely adopted across open-source and corporate codebases, recommended in community resources from Symfony (software), Laravel (framework), Magento, and Drupal Association. It is cited in developer tooling surveys alongside ESLint, Prettier, Rubocop, and Pylint, and it informs contribution guidelines for projects hosted by GitHub, GitLab, Apache Software Foundation, and Mozilla Foundation. Organizations such as Google, Facebook, Microsoft, Amazon (company), and Netflix influence the propagation of automated linting, contributing to PHP_CodeSniffer's role in modern development workflows.
Category:Static program analysis tools