PHP_CodeSniffer 缺少 Zend 标准?

发布于 2024-10-06 08:17:48 字数 243 浏览 5 评论 0原文

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

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

我是否遗漏了一些东西,这不是代码标准的一部分吗?

I'm trying to use PHP_CodeSniffer to sniff the problems in a php file according to the zend coding standards.
The problem is some of the basic rules are not detected, for example

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

Am I missing something, is this not part of the code standard ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心如狂蝶 2024-10-13 08:17:48

根据 ZF 参考中的相应页面,它是 Zend 编码标准的一部分指南。然而,这并不一定意味着所有这些规则都已包含在 phpcs 中。它们是不相关的项目。如果您查看 在 phpcs 中为 ZF 定义的规则集,您将在顶部看到此通知:

基于早期 Zend Framework 编码标准的编码标准。请注意,该标准已经过时。

根据评论来判断ZF 编码标准 Wiki 中的 Thomas Weidner ,目前没有可用的最新 PHPCS 规则集:

我的代码嗅探器实现尚未完成,但也尚未被 Zend 接受。一些规则不符合、未经检查或过于严格。我不得不将其从孵化器中删除。您可以通过查看 SVN 找到最新版本(

使用 PHPCS 交付的 CS 文件不符合任何 ZF 标准。

我听说 Zend 不会集成自己的 CS 测试床,因为一旦新的 Pear2 标准可用,它就会使用它。这就是为什么我从去年开始就没有做任何额外的工作。

所以实际情况是没有可用的官方 CS 测试平台。

It is part of the Zend Coding Standard according to the respective pages in the ZF Reference Guide. However, that does not necessarily mean all these rules have been included in phpcs. They are unrelated projects. If you look at the ruleset defined for ZF in phpcs, you will see this notice right on top:

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

Judging by a comment by Thomas Weidner in the Wiki for ZF Coding Standards, there is currently no up-to-date PHPCS ruleset available:

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文