如何禁用代码嗅探器检查命名空间是否存在

How to disable Code sniffer checking if namespaces are present

我已经从这个 page(手动安装)下载了 Code sniffer,并且我已经将它导入到我的 PHP storm IDE(我在本地包含了 phpcs)。因为我使用的是 cakephp 并且不需要命名空间,所以我不想禁用代码嗅探器来检查 class 是否有命名空间。我该怎么做?

您需要禁用 ClassDeclarationSniff rule。请注意 side-effect 将禁用 One class per file 检查。

有关如何创建您自己的自定义编码标准的教程,您可以在 https://www.jetbrains.com/help/phpstorm/2016.3/using-php-code-sniffer-tool.htmlConfiguring a local Code Sniffer script 部分中找到。