Skip to content

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:

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:

Feedback

Did this page help you?

Thank you for the feedback!

We're sorry to hear that. Please let us know what we can improve.

If you have a question, please ask our community or contact support@codacy.com.

Last modified August 27, 2021