编程语言
首页 > 编程语言> > PHP_CodeSniffer缺少Zend标准?

PHP_CodeSniffer缺少Zend标准?

作者:互联网

我正在尝试使用PHP_CodeSniffer根据zend编码标准来嗅探php文件中的问题.
例如,问题是没有检测到一些基本规则

String Literals
$a = "Example String";
should give a warning because the standard is
$a = 'Example String';

我错过了什么,这不是代码标准的一部分吗?

解决方法:

根据respective pages in the ZF Reference Guide,它是Zend Coding Standard的一部分.但是,这并不一定意味着所有这些规则都包含在phpcs中.它们是不相关的项目.如果您查看ruleset defined for ZF in phpcs,您会在右上方看到此通知:

A coding standard based on an early Zend Framework coding standard. Note that this standard is out of date.

根据Wiki for ZF Coding Standards中的comment by Thomas Weidner判断,目前没有最新的PHPCS规则集可供使用:

My code sniffer implementation was not finished but it has also not been accepted by Zend. Several rules did not conform, were not checked, or were too strict. I had to delete it from Incubator. You can find the latest version by looking into SVN (

The CS files delivered with PHPCS do not conform any ZF standard.

I was said that Zend will not integrate a own CS testbed as it will use the new Pear2 standard as soon as it’s available. This is the reason why I did not do any additional work since last year.

So the actual state is that there is no official CS testbed available.

标签:php,pear,zend-framework,codesniffer
来源: https://codeday.me/bug/20190621/1256697.html