PHP_CodeSniffer - Show Sniff that failed PHP_CodeSniffer - Show Sniff that failed php php

PHP_CodeSniffer - Show Sniff that failed


You can use the -s command line argument to show the source for an error message.

$ phpcs temp.php -s       FILE: /Users/gsherwood/Sites/Projects/PHP_CodeSniffer/temp.php--------------------------------------------------------------------------------FOUND 4 ERROR(S) AFFECTING 2 LINE(S)-------------------------------------------------------------------------------- 2 | ERROR | Missing file doc comment (PEAR.Commenting.FileComment.Missing) 2 | ERROR | Missing class doc comment (PEAR.Commenting.ClassComment.Missing) 2 | ERROR | Opening brace of a class must be on the line after the definition   |       | (PEAR.Classes.ClassDeclaration.OpenBraceNewLine) 3 | ERROR | Missing function doc comment   |       | (PEAR.Commenting.FunctionComment.Missing)--------------------------------------------------------------------------------Time: 0 seconds, Memory: 4.50Mb

You can also use the source report to show a list of all failed sniffs.

$ phpcs temp.php --report=sourcePHP CODE SNIFFER VIOLATION SOURCE SUMMARY--------------------------------------------------------------------------------STANDARD  CATEGORY            SNIFF                                        COUNT--------------------------------------------------------------------------------PEAR      Commenting          File comment missing                         1PEAR      Commenting          Class comment missing                        1PEAR      Classes             Class declaration open brace new line        1PEAR      Commenting          Function comment missing                     1--------------------------------------------------------------------------------A TOTAL OF 4 SNIFF VIOLATION(S) WERE FOUND IN 4 SOURCE(S)--------------------------------------------------------------------------------Time: 0 seconds, Memory: 4.75Mb$ phpcs temp.php --report=source -sPHP CODE SNIFFER VIOLATION SOURCE SUMMARY--------------------------------------------------------------------------------SOURCE                                                                     COUNT--------------------------------------------------------------------------------PEAR.Commenting.FileComment.Missing                                        1PEAR.Commenting.ClassComment.Missing                                       1PEAR.Classes.ClassDeclaration.OpenBraceNewLine                             1PEAR.Commenting.FunctionComment.Missing                                    1--------------------------------------------------------------------------------A TOTAL OF 4 SNIFF VIOLATION(S) WERE FOUND IN 4 SOURCE(S)--------------------------------------------------------------------------------Time: 0 seconds, Memory: 4.75Mb