【问题标题】:Exclude a specific PHPCS rule for a specific file排除特定文件的特定 PHPCS 规则
【发布时间】:2015-10-30 22:47:09
【问题描述】:

我们在项目中使用 PSR0、PSR1 和 PSR2 标准,但我想从 PSR0 命名空间检查规则中排除特定文件。有没有办法可以在文件中添加注释,所以 phpcs 会忽略此规则:

每个类必须位于至少一层的命名空间中...

【问题讨论】:

    标签: php codesniffer


    【解决方案1】:

    这里: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>
    

    【讨论】:

    猜你喜欢
    • 2017-02-01
    • 2022-06-10
    • 1970-01-01
    • 2017-01-07
    • 1970-01-01
    • 2011-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多