Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

86 lines (55 sloc) 2.693 kB
The coding style in Chyrp's code is very, very specific in almost every
case. If you are going to contribute, please try to follow the guidelines
below. Thank you!
* Use single quotes only for strings containing numerous double-quotes,
like HTML. Use double quotes everywhere else, except for array accessors
in $_POST, $_GET, and all the other $_* and "core" variables.
A complex example:
$foo = '<a href="'.$foo["bar"].'">'.$_GET['link_name'].'</a>';
Edge case: If writing HTML and the part containing the opening tag is in
single quotes, put the closing tag in single quotes too.
* Use four spaces for indenting. No tabs.
* Keep the braces on the same line as the declaration, like so:
function foo_bar($baz) {
# code
* Use hashmarks for commenting.
* Don't use excessive spaces. Calling a function with multiple arguments
should look like so:
foo($bar, $baz);
* Use the no-braces shortcuts wherever possible, but don't make it cryptic.
When used intermixed with other code, keep them spaced by a blank line:
$foo = "bar";
$fizz = "buzz";
if ($something)
* Multi-line arrays should be formatted like this:
* Keep function names simple, preferably one word. Use snake_case for most
names, but halfCamelCase where appropriate (e.g. class methods).
* Use NaturalDocs for docstrings. Use hashmarks for docstrings on
variables and constants, but use C-style block comments for functions
and classes.
* For infix boolean notation:
$foo = ($bar ? $baz : buzz);
Be sure to use proper parentheses if you're going to use "and" and "or"
instead of "&&" and "||". Because PHP is retarded like that.
$foo = (($bar and $baz) ? $fizz : $buzz);
Or, alternatively:
$foo = ($bar and $baz) ? $fizz : $buzz ;
* Comments should describe WHY, not HOW, and only be used when it is not
clear in the code itself.
* Avoid global variables. Only use them when a cleaner location for them is
not available.
* Don't use too many variables. If it is only used once, just use its
value unless you are preparing many variables for a later operation.
* Use snake_case for variable names, but try to keep them to one word.
* Take advantage of PHP's key => val arrays whenever possible, they make
for very clear and concise code structures.
* If you're only going to use FooClass::current() once, don't bother
declaring a variable for it. Conversely, if you use it a lot, declare a
variable for it at or near the top of the function, or above its first
Jump to Line
Something went wrong with that request. Please try again.