我们在项目中使用PSR0,PSR1和PSR2标准,但我想从PSR0命名空间检查规则中排除特定文件。有没有办法可以在文件中添加注释,所以phpcs会忽略这个规则:
每个类必须位于至少一个级别的命名空间中......
答案 0 :(得分:10)
此处:http://pear.php.net/manual/en/package.php.php-codesniffer.annotated-ruleset.php
他们展示了这个例子:
<!--
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>