Showing posts with label Zend Code Analyzer. Show all posts
Showing posts with label Zend Code Analyzer. Show all posts

Monday, 24 September 2007

PHP_CodeSniffer 0.9.0 (beta) released

I've just released PHP_CodeSniffer version 0.9.0. No bug fixes were included in this release, but a couple of great new features made it in.

I've talked about the new Zend coding standard (including the Zend Code Analyzer sniff) before but there is also a long awaited feature that made it in; config options. Config options allow PHP_CodeSniffer and its standards to use persistent settings across runs. The most useful of these is the ability to set the default coding standard that PHP_CodeSniffer uses.

You can view the full changelog, and download the release, on the package download page.

Tuesday, 18 September 2007

PHP_CodeSniffer and the Zend Code Analyzer

Ever since I first used the Zend Code Analyzer, I've wanted to put it into our code sniffers, but I've never got around to doing it. Now, thanks to a contribution from Holger Kral of Zend, and a new config system in PHP_CodeSniffer, you can include ZCA warnings in your coding standards.

I've just committed the CodeAnalyzer sniff into the Zend standard under a new Debug category. The sniff requires you to have ZCA installed on the same machine as PHP_CodeSniffer, and you need to tell PHP_CodeSniffer where to find it.

$ phpcs --config-set zend_ca_path /path/to/ZendCodeAnalyzer
$ phpcs --standard=zend /path/to/file
Zend Code Analyzer produces warnings for things like unused function arguments and unreachable code. Not all the warnings need to be fixed, but it can certainly find some common mistakes in your code.