1
我有一个我正在写的php库。它使用Doctrine。带有standard=PSR2
的Php代码嗅探器传递我的代码,除了使用Doctrine中定义的常量之外。许多Doctrine常量不是全部大写,因为PSR2需要,但我无法更改它们,因为它们没有在我的库中定义。如何获取Code Sniffer来检查我的库,但忽略在Doctrine中定义的常量?如何使Php代码嗅探器运行除了一个以外的所有PSR2嗅探器
我有一个我正在写的php库。它使用Doctrine。带有standard=PSR2
的Php代码嗅探器传递我的代码,除了使用Doctrine中定义的常量之外。许多Doctrine常量不是全部大写,因为PSR2需要,但我无法更改它们,因为它们没有在我的库中定义。如何获取Code Sniffer来检查我的库,但忽略在Doctrine中定义的常量?如何使Php代码嗅探器运行除了一个以外的所有PSR2嗅探器
最简单的解决方案是使用@codingStandardsIgnoreStart
和@codingStandardsIgnoreEnd
注释。例如:
// @codingStandardsIgnoreStart
$xmlPackage['error_code'] = get_default_error_code_value();
// @codingStandardsIgnoreEnd
参见 '忽略部分文件' 一节http://pear.php.net/manual/en/package.php.php-codesniffer.advanced-usage.php