PHP CodeSniffer Cheat Sheet

In an effort to build coding standards for our team, I recently began looking at PHP CodeSniffer.
PHP CodeSniffer is a great tool to define and enforce coding standards with PHP.

Its usage can be very simple:

phpcs –standard=zend yourscript.php

Although its usage can be simple, the understanding of the various rules can be a tad daunting. The two coding standards I was interested in were Zend and PEAR, but I knew little about them and how they compare to each other. After digging into the CodeSniffer code, I could see the various sniffs in their rulesets:


In addition to the rulesets, each had their own custom sniffs. With all the information I’ve gathered about each of the standards’ sniffs, I still found it difficult to compare the two. I searched around to see if any one had done any comparison of the standards, but I came up with nothing. I did find some great information and examples at the official CodeSniffer blog, but that wasn’t what I was looking for.

This was when I created a CodeSniffer cheat sheet:

Any suggestions/improvements for the cheat sheet would be appreciated, just leave a comment.

~ by ityndall on June 2, 2011.

Leave a Reply