views:

216

answers:

5

I try to ensure that the code I write is of the best quality possible, so I strive to follow accepted sets of best practices.

In perl, I try to follow the guidelines in the popular book "Perl Best Practices" and I use the perlcritic module to enforce the policies recommended in that book. Perlcritic checks my code to ensure that each recommended policy is followed. I have perlcritic set to "brutal" because I'm serious about creating bug-free code.

With javascript, I use JSLint to do the same thing, as well as enabling strict error checking in firefox.

Unfortunately, I haven't found anything like that for PHP! I've never found a best practices list for PHP with more than 20 items on it, and certainly haven't found a syntax checker that would enforce such rules.

( by the way, I know about php's error_reporting setting. i want something in addition to that ).

Is there such a program to enforce strict best practices in php?

+4  A: 

I would recommend PHP CodeSniffer for static code analysis...

Jochen Hilgers
Ironically, that link leads to a 404.
Matthew Scharley
For some reason, the link only returns a 404 when clicking. Reloading afterwards does make the page display. Odd.
Duroth
(replace Reloading with 'setting focus on the address bar and pressing enter')
Duroth
What an odd glitch...
ceejayoz
A: 

Have you looked at :

http://www.icosaedro.it/phplint/phplint-on-line.html

Anthony
+2  A: 

PEAR coding standards

knittl
also nice: http://framework.zend.com/manual/en/coding-standard.html
Jochen Hilgers
mere-teresa
A: 

PHP Codesniffer is indeed the best tool there is right now. The distribution contains a few different rulesets, and you can also create your own.

In addition to running it locally, you can also integrate PHP Codesniffer reports into your CI tool. For phpUnderControl its quite easy, no idea about Hudson or others.

Anti Veeranna
A: 

You will find almost all tools about quality of code in PHP on this page : http://phptothemoon.com/en/content/tools-quality-php

Take a look on continuous integration tools, as it can measure the quality of your code.

mere-teresa