Search code examples
phpzend-frameworkpearphpcodesniffer

PHP_CodeSniffer missing Zend standards?


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 ?


Solution

  • 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.