talira

PHP_CodeSniffer

Detect and fix coding standard violations in PHP

open sourceBSD-3-Clausefree

PHP_CodeSniffer is two PHP command-line scripts: phpcs tokenizes PHP files and reports violations of a coding standard, and phpcbf fixes them automatically. It takes custom rulesets and third-party standards, and reads a project's configuration file, so teams run it in their editor and on CI. It installs as signed PHAR files or with Composer. This repository is the official continuation of the PHP_CodeSniffer that Squizlabs created and abandoned, under the same squizlabs/php_codesniffer package.

Problems it solves

  • enforce a coding standard like PSR-12 across a PHP codebase
  • automatically fix PHP code style violations
  • check PHP code style on CI and fail the build on violations
  • write my own coding standard rules for PHP

Features

  • phpcs detects coding standard violations
  • phpcbf fixes them automatically
  • built-in standards and custom rulesets
  • project configuration files
  • signed PHAR downloads and Composer

Capabilities

Has a command line toolplan not known
Takes pluginsplan not known

Alternatives

The same job

These do what PHP_CodeSniffer does.

  1. PHPStan PHP static analysis that finds bugs without running your code
  2. RuboCop A Ruby static code analyzer and formatter, based on the community Ruby style guide.
  3. ESLint Find and fix problems in your JavaScript code.
  4. typos Source code spell checker

Compare PHP_CodeSniffer with the top 3