显然,一种方法是:创建一个新的"标准",创建一个新的ruleset.xml,然后在该ruleset.xml文件中插入一个设置该属性的XML节.
例如,(我在Windows上,所以我的反斜杠都是反斜杠而不是反斜杠)
cd\dev\phpcs\CodeSniffer
mkdir NewStandard
在该目录中,创建ruleset.xml,包含以下内容:
<?xml version="1.0"?>
<ruleset name="Custom Standard">
<description>My custom coding standard</description>
<rule ref="PEAR">
<exclude name="PEAR.Commenting.ClassComment"/>
<exclude name="PEAR.Commenting.FileComment"/>
<exclude name="PEAR.Commenting.FunctionComment"/>
<exclude name="PEAR.Commenting.InlineComment"/>
<exclude name="PEAR.Classes.ClassDeclaration"/>
<exclude name="Generic.Files.LineEndings"/>
</rule>
<rule ref="PEAR.WhiteSpace.ScopeIndent">
<properties>
<property name="indent" value="2"/>
</properties>
</rule>
</ruleset>
Run Code Online (Sandbox Code Playgroud)
xml文件中的最后一节设置适当的属性.
要做到这一点,你必须知道这一点
A)缩进嗅(规则)是PEAR.WhiteSpace.ScopeIndent
B)调用该嗅探的属性indent.
然后像往常一样运行phpcs:
\php\php.exe phpcs\scripts\phpcs --standard=NewStandard --report=emacs MyCode.php
文档:
http://pear.php.net/manual/en/package.php.php-codesniffer.annotated-ruleset.php