编程语言
首页 > 编程语言> > PHPCS针对不同目录的不同规则集

PHPCS针对不同目录的不同规则集

作者:互联网

我目前正在努力清理现有的代码库,其中一个方面涉及使用PHPCS.这是我目前的phpcs.xml文件:

<?xml version='1.0'?>
<ruleset name='MyApplication'>
    <arg name='encoding' value='utf-8'/>
    <arg name='extensions' value='php'/>
    <arg name='warning-severity' value='0'/>
    <arg name='colors'/>
    <arg value='p'/>

    <exclude-pattern>vendor/*</exclude-pattern>
    <exclude-pattern>node_modules/*</exclude-pattern>

    <rule ref='PSR1'></rule>
</ruleset>

我想修改它,以便将PSR-2应用于某些目录(例如foo /和bar /),同时根据PSR-1检查剩余的目录.

我找到了< exclude-pattern>手册中的选项可以作为< rule>的子元素放置元素,但我需要相反的.

解决方法:

创建多个配置并使用–standard选项加载它们:

vendor/bin/phpcs source-to-check --standard first-settings.xml 
vendor/bin/phpcs another-to-check --standard second-settings.xml 

标签:php,phpcs
来源: https://codeday.me/bug/20190711/1430638.html