For the latest updates and improvements, see the latest Cloud documentation instead.
How to configure PHP_CodeSniffer coding standards?#
By default, Codacy uses the PHP_CodeSniffer configuration on the Code patterns page when analyzing your repositories.
To enforce a specific PHP_CodeSniffer coding standard you must create a configuration file on the root of your repository that references one or more of the following coding standards:
-
Default coding standards packaged together with PHP_CodeSniffer:
https://github.com/squizlabs/PHP_CodeSniffer/tree/master/src/Standards
-
Additional coding standards that Codacy packages on the PHP_CodeSniffer tool plugin. Check the repository the additional coding standards to learn how you can reference them in your configuration files:
https://github.com/codacy/codacy-codesniffer/blob/master/composer.json
For example, create a text file with the name .phpcs.xml
to use the PSR12 coding standard but excluding the sniffs Generic.WhiteSpace.DisallowTabIndent
and PSR12.Operators.OperatorSpacing
:
<?xml version="1.0"?>
<ruleset name="PHP_CodeSniffer">
<description>PHP_CodeSniffer configuration</description>
<rule ref="PSR12">
<exclude name="Generic.WhiteSpace.DisallowTabIndent"/>
<exclude name="PSR12.Operators.OperatorSpacing"/>
</rule>
</ruleset>
See also#
Check these external resources for more help on customizing your PHP_CodeSniffer configuration:
Share your feedback 📢
Did this page help you?
Thanks for the feedback! Is there anything else you'd like to tell us about this page?
255 characters left
We're sorry to hear that. Please let us know what we can improve:
255 characters left
Alternatively, you can create a more detailed issue on our GitHub repository.
Thanks for helping improve the Codacy documentation.
If you have a question or need help please contact support@codacy.com.