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

Saturday, 26 April 2008

PHP_CodeSniffer code taken and rebadged as Zend Framework code

A new feature request for PHP_CodeSniffer alerted me to the effort of a couple of Zend Framework developers to create a PHP_CodeSniffer standard that can be used by all Zend Framework developers. The feature request mentioned that the name they had chosen (Zend) conflicts with the existing standard that is distributed with PHP_CodeSniffer.

I immediately thought this was a bit strange because I've already had someone from Zend contribute some code for the Zend Framework coding standard, and I've written a fair few sniffs for it myself.

I took a look at the code and noticed that almost all of the sniffs that have been committed to the Zend Framework SVN repository are just copies of the sniffs I have written for the existing PHP_CodeSniffer standards. The troubling part is that all the copyright notices and author tags have been switched to indicate that the code was written by and copyright Zend. Worse still, the licence had been changed to the Zend Framework's New BSD licence.

This is a pretty clear violation of the BSD licence under which PHP_CodeSniffer is distributed, so I've left a comment on the Coding Standard RC page in the Zend Framework wiki. I tried locating an email address, submitting an issue and even commenting on an existing issue, but it appears the Zend Framework doesn't have any scope for non-approved developer comments besides the wiki.

I did get a little angry when I saw this, but I also see this as an opportunity to complete the PHP_CodeSniffer Zend standard and get PHP_CodeSniffer our there to a new developer community. The Zend Framework obviously has a couple of developers dedicated to automating their coding standard checks using PHP_CodeSniffer, so I've provided them with an invitation to contact me and work together. I will hopefully be taken up on that offer.

Update: Thought it might be easier to see the problem if you can focus on one file. Take a look at Zend's FunctionDeclarationArgumentSpacingSniff (from the ZF SVN repo) and Squiz's FunctionDeclarationArgumentSpacingSniff (from the PEAR CVS repo). Only very minor changes have been made. Even with these changes, it would be best to extend the Squiz sniff and do some minor refactoring rather than copy/paste, which I'm happy to help with.

Update: Thomas Weidner has contacted me to let me know the files have been removed from the Zend Framework SVN repo.

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.

Friday, 17 August 2007

Getting the Zend coding standard into PHP_CodeSniffer

With the help of some sniffs contributed by Johann-Peter Hartmann, I've started creating a Zend coding standard for PHP_CodeSniffer, a commonly requested addition to the tool. This new standard implements the Zend Framework coding standards document and is currently available in CVS.

The standard is not yet complete, but it is on the way. I'll continue adding more sniffs as I get time. If you use the Zend coding standard and want to contribute, let me know.