5

我目前正在清理现有的代码库,其中一个方面涉及使用 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>但我需要相反的选项。

4

2 回答 2

0

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

vendor/bin/phpcs source-to-check --standard first-settings.xml 
vendor/bin/phpcs another-to-check --standard second-settings.xml 
于 2017-10-28T12:01:06.540 回答
0
./vendor/bin/phpcs /project/path --standard=/other/path/phpcs.xml
于 2022-02-21T22:20:43.107 回答