ZF-407: Provide a degree of automated coding standards compliance


It would be nice to have some level of automated coding standards compliance assistance, and below are a couple of options:

Most likely this is too old and doesn't work with PHP 5.1.4:" rel="nofollow">phpCodeBeautifier (Thanks, ~gavin])

To evaluate: [PHP_CodeSniffer (Thanks, [~nicklo])

Help Wanted - We would like help with evaluating such a system for Zend Framework code, as we would possibly integrate a good solution as a pre-commit hook to the Subversion repository.


Not evaluated yet for quality yet, but:

Most recent release was in June, built in PHP 5. Works on the command line, and you write custom rules.

That should read, "you can write custom rules if you like."

Here's a command line usage guide:…

These tools require a non-trivial effort to configure and setup "profiles". If someone takes the initiative of codifying the ZF coding standards into configurations for these tools, then the chance for adoption would increase.

I've had bad luck with automated code beautifiers. The risk is that there's some obscure corner case that the code beautifier doesn't handle well, and it inadvertently changes the functionality of the code and introduces bugs.

This actually happened on a Java project I was on in 2005. We upgraded from Java 1.4 to Java 5 and the code beautifier tools didn't know about the new syntax in that release, so they totally ruined the code in the process of trying to beautify it.

It would be one thing to have a tool check and report mismatches between the code and the coding standard, but I wouldn't want it committing changes without a human reviewing them first. Code beautifiers should be run manually and then the results checked visually and with unit tests.

We also have some points in our draft coding standards document that are not simply syntactic issues. So enforcement by a code beautifier is not a complete solution. Still, some automation is better than none.

Matthew, if you want to write a profile that does best-effort checks with respect to the Zend Framework coding standard, that would be much appreciated.

The pre-commit SVN hook we previously discussed for code analysis/beautifier tools might simply result in an email under certain conditions instead of doing something drastic.

Changing to 'Unassigned'

This issue should have been fixed for the 1.5 release.

This doesn't appear to have been fixed in 1.5.0. Please update if this is not correct.

Thomas, I believe you are currently working on this. Please update the issue with any changes to the original idea.

We have decide to use PHP_CodeSniffer. Actually a testbed can already be found within incubator under tools.

This issue itself is seems to be duplicated by ZF-3027 and ZF-3065.

Changing to comply with new IT coventions for components.

Closing due to duplication of existing issue ZF-3065

Updating for the 1.6.0 release.