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, Sider analyzes all PHP files in your repository using our recommended ruleset. For more details, please visit Recommended Ruleset.
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: target: [app/, test/] standard: [phpcs.xml, PSR2] extensions: [php, inc, lib] encoding: utf-8 ignore: - app/vendor - test/ignored.php parallel: true
You can use several options to fine-tune PHP_CodeSniffer to your project:
This option allows you to specify paths 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.
This option allows you to specify a coding standard of your project. If you leave this value empty, Sider tries to detect the standard automatically. If this auto-detection fails, our recommended ruleset will be used.
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 -iThe installed coding standards are Zend, PSR12, MySource, Squiz, PSR2, PSR1, PEAR, CakePHP, Symfony, WordPress, WordPress-Extra, WordPress-Docs and WordPress-Core
You can also specify your own standard file path: e.g.
This option allows you to specify a list of file extensions to be analyzed.
This option allows you to specify an encoding of files to be analyzed.
This option allows you to specify a list of path patterns to be ignored.
This option allows you to control if an analysis runs in parallel mode.