Using PHP Code Sniffer in PhpStorm

Team members may have different backgrounds and code style preferences. In code bases where no formal code style is used, it can become obvious who wrote which code because of different styles being used. Having to work on such code base comes with some drawbacks: developers have to continuously switch their mind around reading code because sometimes brackets are on a new line, sometimes not. Sometimes brackets are required, sometimes not. To ensure a natural flow working with code, a coding standard can be enforced so that the entire code base becomes more uniform to read and work with.

In PhpStorm, we can configure code style through Project Settings | Code Style and use one of the many available schemes. There are also various inspections that check our code against the code style. We can add additional code style inspections to PhpStorm using tools like PHP Code Sniffer. By inspecting PHP, JavaScript and CSS files PHP Code Sniffer will warn us whenever violations are encountered against coding standards like PEAR, PHPCS, PSR1, PSR2, Squiz, Zend and many others like WordPress, Drupal, Symfony2 and so on.

PHPCS in action

Did you know PhpStorm comes with PHP Code Sniffer integration, displaying its warnings and errors right in the IDE? Read our tutorial on PHP Code Sniffer in PhpStorm to find out more.

Your feedback, comments and suggestions are welcome through the issue tracker, by posting your comments below or in our forums!

Develop with pleasure!
– JetBrains PhpStorm Team

About Maarten Balliauw

Maarten Balliauw is a Developer Advocate at JetBrains, working on .NET tools. He focuses on .NET, Azure, web technologies and application performance. Maarten is a frequent speaker at various national and international events. In his free time, he brews his own beer. Follow him on Twitter or check his personal blog.
This entry was posted in Cool Feature and tagged , , , , , , . Bookmark the permalink.