Ignore specific warnings with PHP_CodeSniffer

I am working on a password tool module, and part of it uses base64 Encoding / Decoding. As a result, I have a number of variables that, for obvious reasons, include the term base64. The problem is that when I run the PHP_CodeSniffer tool, it gives warnings: "The variable" ... 64 "contains numbers, but this is discouraging . "

Is there a way to tell PHP_CodeSniffer to ignore these warnings for this particular file? I am sure there is a good reason to avoid numbers, but in this case, I would rather use base64 rather than baseSixtyFour ...

This is how I run PHP_CodeSniffer:

valorin@gandalf :~/workspace/library$ phpcs --standard=ZEND ./Tools/ FILE: /home/valorin/workspace/library/Tools/Password.php -------------------------------------------------------------------------------- FOUND 0 ERROR(S) AND 6 WARNING(S) AFFECTING 5 LINE(S) -------------------------------------------------------------------------------- 38 | WARNING | Variable "_bEncryptionBase64" contains numbers but this is | | discouraged 94 | WARNING | Variable "_bEncryptionBase64" contains numbers but this is | | discouraged 94 | WARNING | Variable "base64" contains numbers but this is discouraged 95 | WARNING | Variable "base64" contains numbers but this is discouraged 210 | WARNING | Variable "bEncryptionBase64" contains numbers but this is | | discouraged 251 | WARNING | Variable "bEncryptionBase64" contains numbers but this is | | discouraged -------------------------------------------------------------------------------- Time: 1 second, Memory: 7.50Mb 
+7
source share
2 answers

Use suppression comment tags:

 // @codingStandardsIgnoreStart /* put your bad code here! */ // @codingStandardsIgnoreEnd 

This requires version 1.2 or later.

+4
source

In CodeSniffer version 1.3, you can exclude certain nuances from certain files at the level of the ruleset.xml file.

+4
source

All Articles