We are very excited to announce the availability of a new major version of PHP Analyzer. If you haven’t heard of PHP Analyzer yet, it is an advanced static analysis tool for PHP code; much like a compiler for PHP, except that it does not transform your source code, but analyzes it.
Before PHP Analyzer runs its bug detection routines and other heuristics, it first performs several flow analyses on your source code to get a better picture of what it does and how data is passed through it. One of these flow analyses is type inference. Our type inference engine had been growing over time as we added new features to make it more accurate. As the architecture was not planned for these new features, the speed of the engine suffered over time.
This new version contains rewritten internals which show speed improvements by 10 to 20 times or even more depending on the analyzed package. Just as an example, analyzing the latest version of the Symfony framework went down from something over an hour to a mere 3 to 4 minutes!
Since PHP Analyzer is implemented in PHP itself, and PHP is single-threaded, that inherently puts a speed limit on a CPU-intensive tool like PHP Analyzer. To still make inspections as fast as possible, the process of analyzing dependencies of your root package is distributed across several machines and done in parallel whenever possible.
These results are then cached in a persistent storage for subsequent runs and only analyzed again if their versions change. This process is now also nicely displayed in your inspection progress log:
Last but not least, this new version also comes with a couple of new checks. An in-depth view will follow over the next days and weeks, here a short summary of things that have changed:
You can enable PHP Analyzer on your project by adding the following to your configuration:
# .scrutinizer.yml
tools:
php_analyzer: true
Currently, PHP Analyzer is available for all paid plans and we also started to make it available to a few hundred of the thousands of open-source repositories on Scrutinizer. We will gradually enable it for more open-source repositories as we get a better idea of the necessary capacities.
If you’d like to get access earlier, you can join us on #scrutinizer on Freenode IRC and we might be able to squeeze you in. At any rate, if you enabled PHP Analyzer in your configuration, you will get an email once it becomes available for your repository.
Help us spread the word, and a happy new year!