Features Releases

PHP Mess Detector in PhpStorm

PHP Mess Detector in PhpStormPhpStorm comes with many inspections that help us analyze and improve the quality of our codebase. By using PHP Mess Detector (PHPMD), we can enable many additional code quality checks on our codebase: it can detect possible bugs, suboptimal code, unused parameters and so on. In other words: it tells us if our code is worthy of seeing the daylight. PHPMD also contains several rules that check for complexity of code and will tell us if we should rewrite our code into something that is more maintainable. All these checks are integrated nicely in PhpStorm. Let’s have a look at some examples!

Once configured, PhpStorm runs the PHP Mess Detector rulesets in the background and surfaces the inspection results in the same way other inspections are shown. We could configure PHP Mess Detector to check if we are violating SOLID‘s Single Responsibility Principle:

PhpStormcheck SOLID single responsibility principle

Many other checks are available through PHPMD. For example when too many decision points (if/else/while/for/case) are found, code becomes more complex and less maintainable. We can have PHPMD warn us when the Cyclomatic Complexity of a method exceeds a given threshold.

PhpStorm Cyclomatic Complexity warning

Want to learn how this works in more detail? Check out our tutorial on using PHP Mess Detector in PhpStorm!

Have feedback? Comments? Suggestions? We value your opinion! Anything you want to let us know is welcome through the issue tracker, by posting your comments below or in our forums!

Develop with pleasure!
– JetBrains PhpStorm Team

image description