====== Coding Standards ======
This document provides guidelines for code formatting and documentation to individuals and teams contributing to 68 Classifieds. This is a work in progress and everything listed here is a starting point. Starting with v4.1 all the core code should adhere to these standards.
===== Commenting =====
In general, code should be commented prolifically. It not only helps describe the flow and intent of the code for less experienced programmers, but can prove invaluable when returning to your own code months down the line. There is not a required format for comments, but the following are recommended.
DocBlock style comments preceding class and method declarations so they can be picked up by IDEs:
/**
* My Class
*
* @package Example Package
* @subpackage Subpackage
* @category Category
* @author Author Name
* @link http://yoursite.com
*/
class Super_sweet {
===== PHP Closing Tag =====
For files that contain only PHP code, the closing tag ("?>") is never permitted. It is not required by PHP, and omitting it prevents the accidental injection of trailing whitespace into the response.
===== Brackets and Indentations =====
You should indent your code with 1 tab.
Opening brackets should start on the next line as the keyword, closing bracket should be aligned below the first letter of the starting keyword. Eg:
if ($foo == "bar")
{
call_bar();
}
elseif($foo == "baz")
{
call_baz();
}
else
{
call_other();
}
===== Line Termination =====
Line termination follows the Unix text file convention. Lines must end with a single linefeed (LF) character. Linefeed characters are represented as ordinal 10, or hexadecimal 0x0A.
Note: Do not use carriage returns (CR) as is the convention in Apple OS's (0x0D) or the carriage return/linefeed combination (CRLF) as is standard for the Windows OS (0x0D, 0x0A).
===== Short Open Tags =====
PHP code must always be delimited by the full-form, standard PHP tags:
Short tags are never allowed. For files containing only PHP code, the closing tag must always be omitted