Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude a specific PHPCS rule for a specific file

We're using PSR0, PSR1 and PSR2 standards in our project, but I want to exclude a specific file from just the PSR0 namespace checking rule. Is there a way I can add a comment to the file, so phpcs ignores this rule:

Each class must be in a namespace of at least one level...

like image 463
josef.van.niekerk Avatar asked Dec 23 '13 11:12

josef.van.niekerk


1 Answers

Here: http://pear.php.net/manual/en/package.php.php-codesniffer.annotated-ruleset.php

They show this example:

<!--
    You can also hard-code ignore patterns for specific sniffs,
    a feature not available on the command line.

    The code here will hide all messages from the Squiz DoubleQuoteUsage
    sniff for files that match either of the two exclude patterns.
 -->
 <rule ref="Squiz.Strings.DoubleQuoteUsage">
    <exclude-pattern>*/tests/*</exclude-pattern>
    <exclude-pattern>*/data/*</exclude-pattern>
 </rule>
like image 147
Lajos Veres Avatar answered Nov 07 '22 12:11

Lajos Veres