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.
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