Ben*_*min 17 php phpdoc codesniffer
是否有一个PHPCS编码标准,将检查适当的注释(@param
,@return
,@throws
等)存在于文档块,包括它们之间的适当的间距?
Gre*_*ood 30
尝试运行以下命令,看看它是否产生了你想要的东西:
phpcs /path/to/code --standard=Squiz --sniffs=Squiz.Commenting.FunctionComment,Squiz.Commenting.FunctionCommentThrowTag,Squiz.Commenting.ClassComment,Squiz.Commenting.FileComment,Squiz.Commenting.VariableComment
如果是这样,您可以创建自己的标准,只包括那些嗅探,以及您想要检查的任何其他内容.您可以通过创建ruleset.xml
文件并将其用作标准来完成此操作.
例如,您可以创建一个名为的文件mystandard.xml
并包含以下内容:
<?xml version="1.0"?>
<ruleset name="MyStandard">
<description>My custom coding standard.</description>
<rule ref="Squiz.Commenting.FunctionComment" />
<rule ref="Squiz.Commenting.FunctionCommentThrowTag" />
<rule ref="Squiz.Commenting.ClassComment" />
<rule ref="Squiz.Commenting.FileComment" />
<rule ref="Squiz.Commenting.VariableComment" />
</ruleset>
Run Code Online (Sandbox Code Playgroud)
然后您可以改为运行此命令:
phpcs /path/to/code --standard=/path/to/mystandard.xml
Run Code Online (Sandbox Code Playgroud)
您还可以在ruleset.xml
文件中执行其他操作.请参阅此处的文档:https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml
2017年,您现在有更多选择: