PHP Code Sniffer 能否告诉我违反了哪条规则以及如何将其关闭?

Can PHP Code Sniffer advise me which rule has been violated and how to turn it off?

是否可以让嗅探器输出规则已被破坏,因此我可以更改配置的哪一行来阻止这些违规行为的出现?

例如我收到大量与数组相关的违规行为,但我对数组缩进很满意。我如何找出规则以及如何禁用它?

谢谢

 494 | ERROR | [x] Array double arrow not aligned correctly; expected
     |       |     20 space(s) but found 1
 495 | ERROR | [x] Array key not aligned correctly; expected 19
     |       |     spaces but found 12
 495 | ERROR | [x] Array double arrow not aligned correctly; expected
     |       |     22 space(s) but found 1
 496 | ERROR | [x] Array key not aligned correctly; expected 19
     |       |     spaces but found 12
 496 | ERROR | [x] Array double arrow not aligned correctly; expected
     |       |     25 space(s) but found 1
 497 | ERROR | [x] Array key not aligned correctly; expected 19
     |       |     spaces but found 12

使用 -s 参数,它在 docs 中的 "Printing Full and Summary Reports" 下列出。

例如phpcs -s myfile.php

要回答问题的第二部分,有多种方法可以忽略特定的嗅探。您可以使用注释和 phpcs:disable 语法进行内联,或者您可以使用命令行参数来排除特定的嗅探,这看起来更像是您想要的:

phpcs --exclude=Generic.PHP.LowerCaseConstant,Some.Other.Rule myfile.php