PHP Coding Standards - Laying Down the Law

September 19, 2006 17:47, contributed by: seagull
There was a fantastic CS helper package released at PEAR this week, PHP_CodeSniffer. The package, which requires PHP5 and is nicely coded, puts a phpcs script in your path so you can pass files or directories to it to get your CS validated.

The results are detailed and processing is surprisingly fast considering how many tokens are being parsed.

[demian@localhost lib]$ phpcs -v SGL.php
Registering sniffs... DONE
Processing SGL.php [2587 tokens in 425 lines]... DONE in < 1 second

Typical CS errors/warnings look like this, I just fixed the errors in this case ;-)

PHP_CodeSniffer is a godsend when you're in the position of having to explain what PHP coding standards are the newbies on average twice/week, and what the difference is between conditional and method bracing, etc, etc.

As we've seen ZDE and various other IDEs bundle other PEAR packages with their software like phpDocumentor, I hope this tool too becomes a standard IDE helper in the near future.

Hats off to Squiz for putting PHP_CodeSniffer together.

 See the wiki for details on how to install and run the code sniffer.

[back to list]

comments


be the first to leave a comment
Enter your comment Note: Comments must be approved before being displayed.
  #####    #####    #####   ####### 
 #     #  #     #  #     #  #    #  
       #  #     #  #     #      #   
  #####    #####    ######     #    
       #  #     #        #    #     
 #     #  #     #  #     #    #     
  #####    #####    #####     #     
 

Syndicate

At a Glance

Sponsors

Login

Username Password

Not Registered?
Forgot Your Password

*denotes required field

Community

 
Seagull PHP Framework Seagull PHP Framework

Sponsored by

The Seagull project is sponsored by Seagull Systems, see the range of products and services offered.

Readers