gpt4 book ai didi

PHPCS 不同目录的不同规则集

转载 作者:可可西里 更新时间:2023-10-31 23:45:52 25 4
gpt4 key购买 nike

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

关于PHPCS 不同目录的不同规则集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37848498/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com