Code standard
Most of it comes from http://mikenaberezny.com/2008/09/16/php-developer-best-practices/
One should stay as close to the PEAR coding standard as possible. The stuff below is basically a summary of the PEAR cs. See http://pear.php.net/manual/en/standards.php for more information and this for additional information. Also see http://java.sun.com/j2se/javadoc/writingdoccomments/index.html for more information on how to write documentation and the PEAR RFC.
PHP_CodeSniffer is run, http://pear.php.net/package/PHP_CodeSniffer, on all code. Some of the older code still needs validation though.
PHPCS is located here: /usr/share/php/PHP/CodeSniffer/Standards
$ phpcs --standard=PEAR <filename>
PHPDOC templates
Files and Directories
Class name used to name file
.php extension
Class name underscores convert to directory separator:
Spreadsheet_Excel_Writer
Spreadsheet/Excel/Writer.php
One class per file, no loose code
Naming Conventions
Class names are MixedCase
Method names are camelCase
Constants are ALL_CAPS
Properties and variables are camelCase
Non-public class members are _underscorePrefixed
Source Formatting
One True Brace
Functions and Classes have the opening brace on the line following the declaration, at the same indentation level. (DO NOT APPLY TO simpleSAMLphp)
Control Structures keep the opening brace on the same line as the declaration
Indentation (DO NOT APPLY TO simpleSAMLphp)
Spaces only; no tabs
Four (4) spaces per level of indentation
Purpose is consistency of viewing
All control structures use braces; no one liners
Keep lines 75-85 characters in length, maximum (79 characters in simpleSAMLphp)
Some thoughts about line length http://paul-m-jones.com/?p=276
No shell-style comments (#)