# squizlabs/php_codesniffer

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/squizlabs-php-codesniffer).**

10,771 stars · 1,451 forks · PHP · BSD-3-Clause

## Links

- GitHub: https://github.com/squizlabs/PHP_CodeSniffer
- awesome-repositories: https://awesome-repositories.com/repository/squizlabs-php-codesniffer.md

## Topics

`automation` `cli` `coding-standards` `php` `qa` `static-analysis`

## Description

PHP_CodeSniffer is a static analysis tool, coding standard linter, and command-line validator for PHP. It scans files and directories to detect and report formatting errors and language-specific coding violations without executing the code.

The project functions as an automated code formatter capable of correcting detected style and formatting violations to bring source code into compliance with defined standards. It uses token-based lexical analysis to match code patterns against rule sets, ensuring consistency across a codebase.

The tool provides comprehensive capabilities for recursive file auditing, severity-based result filtering, and customizable report generation. It includes automation features for continuous integration, such as exit code control, file exclusion patterns, and inline violation suppression.

Users can manage analysis settings through project configuration files, global preferences, and custom standard path management.

## Tags

### Software Engineering & Architecture

- [Pattern Violation Scanning](https://awesome-repositories.com/f/software-engineering-architecture/violation-reporters/pattern-violation-scanning.md) — Scans source code for structures that violate predefined coding standards and formatting rules.
- [Coding Standards Enforcement](https://awesome-repositories.com/f/software-engineering-architecture/coding-standards-enforcement.md) — Enforces adherence to specific style guides and organizational standards across a PHP codebase.
- [Coding Standards](https://awesome-repositories.com/f/software-engineering-architecture/development-methodologies/engineering-best-practices/code-craftsmanship-standards/coding-standards.md) — Validates PHP code against one or more standards to ensure consistency and adherence to style guides. ([source](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage))
- [Rule-Based Token Analysis](https://awesome-repositories.com/f/software-engineering-architecture/violation-reporters/rule-based-token-analysis.md) — Uses token-based lexical analysis to identify where PHP code deviates from defined formatting rules. ([source](https://github.com/squizlabs/php_codesniffer#readme))
- [Recursive Directory Traversers](https://awesome-repositories.com/f/software-engineering-architecture/recursive-validation-engines/recursive-tree-traversers/file-system-traversers/recursive-directory-traversers.md) — Recursively scans nested directory structures to identify files for analysis based on extensions.
- [Rule Subset Selections](https://awesome-repositories.com/f/software-engineering-architecture/rule-subset-selections.md) — Enables running a selected subset of rules or excluding specific checks to isolate particular types of violations. ([source](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage))
- [Violation Reporters](https://awesome-repositories.com/f/software-engineering-architecture/violation-reporters.md) — Processes detected coding violations into various visual formats for human reading or machine automation.
- [Violation Severity Management](https://awesome-repositories.com/f/software-engineering-architecture/violation-reporters/violation-severity-management.md) — Evaluates violation priority levels to determine which errors trigger build failures or are reported.
- [Rule Suppression Comments](https://awesome-repositories.com/f/software-engineering-architecture/warning-issuance-systems/warning-suppressions/suppression-comment-governors/rule-suppression-comments.md) — Provides inline source code comments to disable specific linting rules for targeted lines or blocks. ([source](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage))

### Testing & Quality Assurance

- [Static Code Analysis](https://awesome-repositories.com/f/testing-quality-assurance/static-code-analysis.md) — Performs static scanning of PHP files to identify syntax violations and style errors without execution.

### Development Tools & Productivity

- [Automated Lint Fixes](https://awesome-repositories.com/f/development-tools-productivity/automated-lint-fixes.md) — Corrects detected style and formatting errors automatically to bring code into compliance. ([source](https://github.com/squizlabs/php_codesniffer#readme))
- [CLI Coding Standard Validators](https://awesome-repositories.com/f/development-tools-productivity/cli-coding-standard-validators.md) — Provides a command-line interface for auditing PHP source code against defined sets of rules.
- [PHP Formatters](https://awesome-repositories.com/f/development-tools-productivity/developer-utilities-libraries/developer-tools/code-quality-verification/coding-style-tools/php-formatters.md) — Automatically corrects coding standard violations to bring PHP source code into compliance.
- [PHP Linters](https://awesome-repositories.com/f/development-tools-productivity/developer-utilities-libraries/developer-tools/code-quality-verification/coding-style-tools/php-linters.md) — Tokenizes PHP code to detect and report violations of defined coding style guides.
- [Analysis File Extension Filters](https://awesome-repositories.com/f/development-tools-productivity/custom-file-extension-analysis/analysis-file-extension-filters.md) — Restricts analysis to specific file types by matching extensions to ensure only relevant files are scanned. ([source](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage))
- [File Exclusion Patterns](https://awesome-repositories.com/f/development-tools-productivity/file-exclusion-patterns.md) — Skips specific directories or files using regular expression patterns to avoid scanning irrelevant code. ([source](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage))
- [Project Configuration](https://awesome-repositories.com/f/development-tools-productivity/project-configuration.md) — Supports loading analysis settings and coding standards from project-specific configuration files. ([source](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage))

### Programming Languages & Runtimes

- [Lexical Tokenizers](https://awesome-repositories.com/f/programming-languages-runtimes/lexical-tokenizers.md) — Converts raw PHP source code into a stream of atomic tokens for structural inspection.
- [Token Manipulation](https://awesome-repositories.com/f/programming-languages-runtimes/token-manipulation.md) — Implements token manipulation to automatically correct formatting violations and rewrite source files.
- [Language Version Targeting](https://awesome-repositories.com/f/programming-languages-runtimes/language-version-targeting.md) — Allows the analyzer to apply rules compatible with the specific version of PHP used in a project. ([source](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Configuration-Options))

### DevOps & Infrastructure

- [Build Exit Code Controls](https://awesome-repositories.com/f/devops-infrastructure/build-exit-code-controls.md) — Allows configuring the return code for automated builds to prevent failures when only warnings are detected. ([source](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Configuration-Options))
- [Configuration File Loading](https://awesome-repositories.com/f/devops-infrastructure/configuration-management/file-based-configuration/configuration-file-loading.md) — Loads rule definitions from external configuration files to define the analysis profile.
- [Continuous Integration Checks](https://awesome-repositories.com/f/devops-infrastructure/continuous-integration-pipelines/continuous-integration-checks.md) — Integrates as a check within CI pipelines to catch style and syntax errors before deployment.

### System Administration & Monitoring

- [Analysis Result Filtering](https://awesome-repositories.com/f/system-administration-monitoring/analysis-result-filtering.md) — Adjusts which errors and warnings are displayed by filtering based on severity levels or hiding warnings. ([source](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Configuration-Options))
- [Detector Severity Thresholds](https://awesome-repositories.com/f/system-administration-monitoring/audit-log-filters/severity-level-filtering/detector-severity-thresholds.md) — Filters analysis detectors based on a minimum severity level to hide low-priority findings. ([source](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage))
