PHP_CodeSniffer 2.0.0a2 released01 May
I've just released the second alpha of PHP_CodeSniffer version 2.0.0. This update brings a new type of report, performance improvements, and Phar distribution for each download and testing.
PHP_CodeSniffer now comes with an information report that is able to show you information about how your code is written rather than checking that it conforms to a standard. You can read more about this report, and see example output, on the wiki.
A number of minor performance improvements have gone into this version, which will probably only be obvious when checking very large code bases. As a result, there are a few important changes to know about:
- Line length warnings will now be shown for lines that refer to licence and VCS information. The line length sniff previously ignored these lines, which meant that it had to run a regular expression on every line it checked.
- The $tokens array has a new length index that you can use to determine the length of the token's content rather than having to call strlen() yourself and deal with character encoding.
- The use of in_array() when checking the PHP_CodeSniffer_Tokens static vars impacted performance significantly, so they have been restructured so that you can also use isset() on them.
- Custom reports can now specify a $recordErrors member var that, when set to FALSE, will tell PHP_CodeSniffer that it doesn't need to record errors during the run. This gives a significant memory saving if you are using a custom report to output summary information rather than a full list of errors found.
For the first time, PHP_CodeSniffer's phpcs and phpcbf commands are now available as Phar files. The Phars are still in testing and are known to not work with HHVM, but are an easy way to try out the new 2.0 alpha versions.
curl -OL https://github.com/squizlabs/PHP_CodeSniffer/releases/download/2.0.0a2/phpcs.phar php phphcs.phar /path/to/code curl -OL https://github.com/squizlabs/PHP_CodeSniffer/releases/download/2.0.0a2/phpcbf.phar php phpcbf.phar /path/to/code
Besides these major changes, there are a number of bug fixes and improvements to automatic code fixing. Thanks to all the developers who directly contributed code to this release.