PHP_CodeSniffer is a style checker to enforce a defined set of PHP coding standards.
To start using PHP_CodeSniffer, enable it in your repository settings.
To configure the coding standard you want to follow, add
sider.yml in your repository and set the
linter: code_sniffer: dir: app/ standard: CakePHP
If you don't specify anything, Sider tries to detect the standard and target directory for your project automatically.
If it cannot find an appropriate standard, it assumes
PSR2 as its standard and analyzes all PHP files in your repository.
Standard and Analysis Target
Sider tries to detect the most suitable standard and target directory for your project, based on the framework your project is using.
The following standards are detected automatically:
The auto-detection is based on file names and directory structure in your repository.
If this auto-detection fails, you can specify a standard in
An example setting for PHP_CodeSniffer under
linter: code_sniffer: dir: app/ standard: phpcs.xml extensions: php,inc,lib encoding: utf-8 ignore: - app/vendor - test/ignored.php
You can use several options to fine-tune PHP_CodeSniffer to your project:
This option controls directories to be analyzed. The default value is dependent on the frameworks PHP_CodeSniffer supports.
If you are not using any frameworks or are using a framework PHP_CodeSniffer does not support,
. is used.
If you would like to exclude specific directories, you can specify them in a custom ruleset file.
This option controls a coding standard of your project. If you leave this value empty, Sider tries to detect the standard automatically.
PSR2 is used when auto detection fails.
You can use the following third-party standards in addition to the standards which PHP_CodeSniffer supports natively:
If you want to see the actual standard lists, run the command
The following output is a standard list that we prepare.
phpcs -i The installed coding standards are Zend, PSR12, MySource, Squiz, PSR2, PSR1, PEAR, CakePHP, Symfony, WordPress, WordPress-Extra, WordPress-Docs and WordPress-Core
You can also define your own standard, and enter the path to the config file here.
This option controls a comma-separated list of file extensions to be analyzed. You also can specify an array of extensions.
This option controls an encoding of files to be analyzed.
This option controls a comma-separated list of file or directory patterns to be ignored. You also can specify an array of patterns.