Squiz Labs Blog - The latest news from the R&D division of Squiz®

Subscribe to our RSS feeds

PHP_CodeSniffer 2.0.0a2 released

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.

Information Report

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.

Performance Improvements

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.

Phar Distribution

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

Everything Else

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.

View the full 2.0.0a2 changelog at PEAR or Github

Stay up to date on all PHP_CodeSniffer changes, including new features and releases, by subscribing to the RSS feed or following me on Twitter.

Squiz Labs

R & D division of Squiz Pty Ltd

Open source web experience management solutions

Squiz Labs is the research and development division of Squiz, the company behind the Squiz Suite of web experience management and development tools.

Our PHP and JavaScript developers are responsible for producing innovative enterprise-quality software while our interface designers and testing team ensure our products both look great and are easy to use.