Coding Standards/conventions Question:

What is the structure of Coding Standard?

Tweet Share WhatsApp

Answer:

☆ Add a single space after each comma delimiter;
☆ Add a single space around binary operators (==, &&, ...), with the exception of the concatenation (.) operator;
☆ Place unary operators (!, --, ...) adjacent to the affected variable;
☆ Add a comma after each array item in a multi-line array, even after the last one;
☆ Add a blank line before return statements, unless the return is alone inside a statement-group (like an if statement);
☆ Use braces to indicate control structure body regardless of the number of statements it contains;
☆ Define one class per file - this does not apply to private helper classes that are not intended to be instantiated from the outside and thus are not concerned by the PSR-0 standard;
☆ Declare class properties before methods;
☆ Declare public methods first, then protected ones and finally private ones. The exceptions to this rule are the class constructor and the setUp and tearDown methods of PHPUnit tests, which should always be the first methods to increase readability;
☆ Use parentheses when instantiating classes regardless of the number of arguments the constructor has;
☆ Exception message strings should be concatenated using sprintf.

Download Coding Standards PDF Read All 26 Coding Standards Questions
Previous QuestionNext Question
What are the conditions of CamelCase coding standard?List the naming conventions in Coding Standards?