phpcs
安装在系统上,代码嗅探可以从命令行正常工作。
phpcs --extensions=php /path/to/code.php`
^ 工作正常。
对于 PHP Storm IDE,我在设置中指定了 ruleset.xml 文件的位置,如下所示:
Cmd
+ ,
> PHP Code Sniffer validation
> Coding standard
> Custom
> ruleset.xml 的路径
但是,我收到此错误:
PHP Code Sniffer
phpcs: /Users/gketkar/code-sniffer/Blah/ruleset.xml: line 1: syntax error near unexpected token `newline'
/Users/gketkar/code-sniffer/Blah/ruleset.xml: line 1: `<?xml version="1.0"?>'
更新:ruleset.xml 文件如下所示:
<?xml version="1.0"?>
<ruleset name="Blah">
<description>Blah Coding Standards</description>
<rule ref="Generic">
<exclude name="Generic.Formatting.SpaceAfterCast.NoSpace"/>
<exclude name="Generic.PHP.DeprecatedFunctions"/>
<exclude name="Generic.PHP.DisallowShortOpenTag.EchoFound"/>
<exclude name="Generic.PHP.UpperCaseConstant.Found"/>
</rule>
</ruleset>