In a quick new post to his site Theo Tzaferis shows you how to set up PHPStorm and PHP_CodeSniffer to perform automatic inspection of your PHP code's syntax.
Some time ago I wrote an article on how to format your code automatically in PhpStorm to be conform the PSR standards. In this article I want to show you how you can enable inspections in PhpStorm which throws a warning if you have code which is not PSR, e.g.
This is pretty easy. We will use squizlabs/PHP_CodeSniffer from Github.
- Whitespace at the end of line
- No newline at the end of file
- No newline between namespace and use statements
I’m doing this on an Ubuntu machine, but it should work the same in OS X (no idea about Windows).
He then provides the (*nix-centric) instructions on getting the two tools up and playing happily together. Fortunately PHPStorm comes with handy built-in support for PHP_CodeSniffer, basically only requiring you to install
phpcs and point it to the right location. The rest is handled by the IDE when you enable the automatic evaluation.