@@ -9,6 +9,9 @@ follow the same guidelines, and you should too.
9
9
Remember that the main advantage of standards is that every piece of code
10
10
looks and feels familiar, it's not about this or that being more readable.
11
11
12
+ Symfony follows the standards defined in the PSR-0, PSR-1, and PSR-2
13
+ documents.
14
+
12
15
Since a picture - or some code - is worth a thousand words, here's a short
13
16
example containing most features described below:
14
17
@@ -61,45 +64,19 @@ example containing most features described below:
61
64
Structure
62
65
---------
63
66
64
- * Never use short tags (`<? `);
65
-
66
- * Don't end class files with the usual `?> ` closing tag;
67
-
68
- * Indentation is done by steps of four spaces (tabs are never allowed);
69
-
70
- * Use the linefeed character (`0x0A `) to end lines;
71
-
72
67
* Add a single space after each comma delimiter;
73
68
74
- * Don't put spaces after an opening parenthesis and before a closing one;
75
-
76
69
* Add a single space around operators (`== `, `&& `, ...);
77
70
78
- * Add a single space before the opening parenthesis of a control keyword
79
- (`if `, `else `, `for `, `while `, ...);
80
-
81
71
* Add a blank line before `return ` statements, unless the return is alone
82
72
inside a statement-group (like an `if ` statement);
83
73
84
- * Don't add trailing spaces at the end of lines;
85
-
86
74
* Use braces to indicate control structure body regardless of the number of
87
75
statements it contains;
88
76
89
- * Put braces on their own line for classes, methods, and functions
90
- declaration;
91
-
92
- * Separate the conditional statements (`if `, `else `, ...) and the opening
93
- brace with a single space and no blank line;
94
-
95
77
* Declare visibility explicitly for class, methods, and properties (usage of
96
78
`var ` is prohibited);
97
79
98
- * Use lowercase PHP native typed constants: `false `, `true `, and `null `. The
99
- same goes for `array() `;
100
-
101
- * Use uppercase strings for constants with words separated with underscores;
102
-
103
80
* Define one class per file - this does not apply to private helper classes
104
81
that are not intended to be instantiated from the outside and thus are not
105
82
concerned by the PSR-0 standard;
0 commit comments