phpsyntax-checking

PHP code review/checking methods during development


I am looking for methods for performing sanity checks of PHP code during development

I hope to to avoid finding out about the coding mistakes the hard way, but instead find them before publishing the website.

display_errors = on and similar run-time methods find the problems too late.

So far I have found the following ways, which I think are not thorough enough:

Are there more ways to find problems in PHP code early?


Solution

  • PHP Code Sniffer can help ensure you're writing code to a set standard.

    http://pear.php.net/package/PHP_CodeSniffer/

    PHP_CodeSniffer is a PHP5 script that tokenises and "sniffs" PHP, JavaScript and CSS files to detect violations of a defined coding standard. It is an essential development tool that ensures your code remains clean and consistent. It can also help prevent some common semantic errors made by developers.

    Incidentally, if you want to get really into code checking, you can integrate Code Sniffer, PHPUnit and a repo together with something like phpUnderControl for automating such a process.