简体   繁体   中英

How to have Php Code Sniffer run all PSR2 sniffs except one

I have a php library I'm writing. It uses Doctrine. Php code sniffer with standard=PSR2 passes on my code with the exception of where I use constants defined in the Doctrine. Many Doctrine constants are not all uppercase, as PSR2 requires, but I can't change them because they are not defined in my library. How do I get Code Sniffer to check my library, but ignore those constants defined in Doctrine?

The simplest solution is to use the @codingStandardsIgnoreStart and @codingStandardsIgnoreEnd annotations. Eg:

// @codingStandardsIgnoreStart
$xmlPackage['error_code'] = get_default_error_code_value();
// @codingStandardsIgnoreEnd

See the section 'Ignoring Parts of a File' in http://pear.php.net/manual/en/package.php.php-codesniffer.advanced-usage.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM