2012-03-10 72 views

回答

4

顯然有一種方法是這樣的:創建一個新的「標準」,創建一個新的ruleset.xml,然後插入該ruleset.xml文件,一個設置屬性的XML節。

例如,(我在Windows上,所以我的反斜線所有的反斜線,而不是FWD斜槓)

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> 

xml文件中的最後一節設置應用程序ropriate財產。

要做到這一點,你必須知道,

A)縮進嗅(rule)是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

相關問題