Overview of PHP code quality tools


Below tools provide a comprehensive set of rules and analyse the code from different angles.


PHPStan focuses on finding errors in your code without actually running it. It catches whole classes of bugs even before you write tests for the code. It moves PHP closer to compiled languages in the sense that the correctness of each line of the code can be checked before you run the actual line.


Very similar to PHPStan. Also can specify levels and there is probably a lot of overlap in terms of analysis, but could also be a useful tool.

PHP Mess Detector

It is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD. PHPMD can be seen as an user friendly and easy to configure frontend for the raw metrics measured by PHP Depend.


Detects violations of the defined coding standards and helps to keep the code base clean and easy to read.


PhpMetrics provides metrics about PHP project and classes, with beautiful and readable HTML report.

PHP Insights

The perfect starting point to analyse the code quality of your PHP projects.


Exakat looks very promising and comprehensive, but the biggest drawback is buggy documentation and small community. Generates reports in various formats, including HTML and analyses many areas like security or compatibility with specific versions of PHP.


Below deal with specific areas of code quality.

PHP Copy/Paste Detector (PHPCPD)

phpcpd is a Copy/Paste Detector (CPD) for PHP code. Does what the name says. It discovers where simple copy paste was used or a duplicate code. Makes it possible to see where it can be wrapped up into a function.

PHPMND (PHP Magic Number Detector)

This tools is pretty specific: it can help you to find magic numbers your code.

Enlightn Security Checker
PHP Assumptions

Helps discover good candidates for refactoring by finding classes that change often.


These tools test the code base or improve the quality of written tests


PHPUnit is a programmer-oriented testing framework for PHP.


PHP Mutation Testing Framework



Rector is a CLI tool written in PHP. It can instantly upgrade old PHP code and handle automated refactorings. It's fast and precise - changes 5000 files under minute.

PHP Parallel Lint

Analyser of PHP code to search usages of deprecated functionality in newer interpreter versions - deprecations detector. Doesn't support PHP 8.0 yet.