● ● File and Directory Names Brackets ○ Curly Brackets ○ Class Brackets ○ Empty Brackets ○ Array Brackets ■ Opening Parenthesis ■ Closing parenthesis ● Single Dimension ● Multidimensional ■ Arrays as Function Arguments Naming Conventions ○ Classes ○ Functions and Methods ○ Variables Indentation String Concatenation Single Line Statements Comparison Operations Switch Structures Parentheses Ternaries Type Casting Constants Comments ○ One-line Comments Regular Expressions
●
● ● ● ● ● ● ● ● ● ● ●
Reference: http://kohanaframework.org/3.2/guide/kohana/conventions Syntax Highlighter: https://snipt.net
File and Directory Names
1. CamelCased should not be used. 2. Should be lowercase. Example: Incorrect ThisIsDirectory/ThisIsDirectory/ThisIsFile.php Correct this_is_directory/this_is_directory/this_is_file.php
Coding Standards
In order to produce highly consistent source code, we ask that everyone follow the coding standards as closely as possible.
Brackets
Please use BSD/Allman Style bracketing. Example: while (x == y) { something(); somethingelse(); }
The following is still syntactically correct:
//while (x == y) { something(); somethingelse(); }
As is this:
//for (int i=0; i < x; i++) //while (x == y) if (x == y) { something(); somethingelse(); }
Curly Brackets
Curly brackets are placed on their own line, indented to the same level as the control statement.
// Correct if ($a === $b) { ... } else { ... } // Incorrect if ($a === $b) { ... } else { ... }
Class Brackets
The only exception to the curly bracket rule is, the opening bracket of a class goes on the same line.
// Correct class Foo { // Incorrect class Foo {
Empty Brackets
Don't put any characters inside empty brackets.
// Correct class Foo {} // Incorrect class Foo { }
Array Brackets
Arrays may be signle line or multi-line array('a' => 'b', 'c' => 'd') array( 'a' => 'b',
'c' => 'd', )
Opening Parenthesis The opening array