Static Analysis with HipHop for PHP
In July 2010 I already blogged about the fact that HipHop for PHP, the source code transformer that turns PHP code into C++ code that can then be compiled with g++, can also be used for static code analysis to find problems in PHP source code.
Today I started to work on a convenience wrapper for HipHop's static analyzer:
➜ ~ hphpa /usr/local/src/code-coverage/PHP hphpa 1.0.0 by Sebastian Bergmann. /usr/local/src/code-coverage/PHP/CodeCoverage/Filter.php 206 TooManyArgument: $this->addFileToWhitelist($file, FALSE)
Of course the tool can also generate an XML logfile in a format that is suitable for continuous integration:
➜ ~ hphpa --checkstyle hphpa.xml --quiet /usr/local/src/code-coverage/PHP hphpa 1.0.0 by Sebastian Bergmann. ➜ ~ cat hphpa.xml <checkstyle> <file name="/usr/local/src/code-coverage/PHP/CodeCoverage/Filter.php"> <error line="206" message="$this->addFileToWhitelist($file, FALSE)" source="TooManyArgument"/> </file> </checkstyle>
