1<?xml version="1.0"?>
2<ruleset name="PSR2">
3 <description>The PSR-2 coding standard.</description>
4 <arg name="tab-width" value="4"/>
5
6 <!-- 2. General -->
7
8 <!-- 2.1 Basic Coding Standard -->
9
10 <!-- Include the whole PSR-1 standard -->
11 <rule ref="PSR1"/>
12
13 <!-- 2.2 Files -->
14
15 <!-- All PHP files MUST use the Unix LF (linefeed) line ending. -->
16 <rule ref="Generic.Files.LineEndings">
17  <properties>
18   <property name="eolChar" value="\n"/>
19  </properties>
20 </rule>
21
22 <!-- All PHP files MUST end with a single blank line. -->
23 <!-- checked in Files/EndFileNewlineSniff -->
24
25 <!-- The closing ?> tag MUST be omitted from files containing only PHP. -->
26 <!-- checked in Files/ClosingTagSniff -->
27
28 <!-- 2.3 Lines -->
29
30 <!-- The soft limit on line length MUST be 120 characters; automated style checkers MUST warn but MUST NOT error at the soft limit. -->
31 <rule ref="Generic.Files.LineLength">
32  <properties>
33   <property name="lineLimit" value="120"/>
34   <property name="absoluteLineLimit" value="0"/>
35  </properties>
36 </rule>
37
38 <!-- There MUST NOT be trailing whitespace at the end of non-blank lines. -->
39 <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
40  <properties>
41   <property name="ignoreBlankLines" value="true"/>
42  </properties>
43 </rule>
44 <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.StartFile">
45  <severity>0</severity>
46 </rule>
47 <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EndFile">
48  <severity>0</severity>
49 </rule>
50 <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines">
51  <severity>0</severity>
52 </rule>
53
54 <!-- There MUST NOT be more than one statement per line. -->
55 <rule ref="Generic.Formatting.DisallowMultipleStatements"/>
56
57 <!-- 2.4 Indenting -->
58
59 <!-- Code MUST use an indent of 4 spaces, and MUST NOT use tabs for indenting. -->
60 <rule ref="Generic.WhiteSpace.ScopeIndent">
61  <properties>
62   <property name="ignoreIndentationTokens" type="array" value="T_COMMENT,T_DOC_COMMENT_OPEN_TAG"/>
63  </properties>
64 </rule>
65 <rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
66
67 <!-- 2.5 Keywords and True/False/Null -->
68
69 <!-- PHP keywords MUST be in lower case. -->
70 <rule ref="Generic.PHP.LowerCaseKeyword"/>
71
72 <!-- The PHP constants true, false, and null MUST be in lower case. -->
73 <rule ref="Generic.PHP.LowerCaseConstant"/>
74
75 <!-- 3. Namespace and Use Declarations -->
76
77 <!-- When present, there MUST be one blank line after the namespace declaration. -->
78 <!-- checked in Namespaces/NamespaceDeclarationSniff -->
79
80 <!-- When present, all use declarations MUST go after the namespace declaration.
81      There MUST be one use keyword per declaration.
82      There MUST be one blank line after the use block. -->
83 <!-- checked in Namespaces/UseDeclarationSniff -->
84
85 <!-- 4. Classes, Properties, and Methods -->
86
87 <!-- 4.1. Extends and Implements -->
88
89 <!-- The extends and implements keywords MUST be declared on the same line as the class name.
90      The opening brace for the class go MUST go on its own line; the closing brace for the class MUST go on the next line after the body.
91      Lists of implements MAY be split across multiple lines, where each subsequent line is indented once. When doing so, the first item in the list MUST be on the next line, and there MUST be only one interface per line. -->
92 <!-- checked in Classes/ClassDeclarationSniff -->
93
94 <!-- 4.2. Properties -->
95
96 <!-- Visibility MUST be declared on all properties.
97      The var keyword MUST NOT be used to declare a property.
98      There MUST NOT be more than one property declared per statement.
99      Property names SHOULD NOT be prefixed with a single underscore to indicate protected or private visibility. -->
100 <!-- checked in Classes/PropertyDeclarationSniff -->
101
102 <!-- 4.3 Methods -->
103
104 <!-- Visibility MUST be declared on all methods. -->
105 <rule ref="Squiz.Scope.MethodScope"/>
106 <rule ref="Squiz.WhiteSpace.ScopeKeywordSpacing"/>
107
108 <!-- Method names SHOULD NOT be prefixed with a single underscore to indicate protected or private visibility. -->
109 <!-- checked in Methods/MethodDeclarationSniff -->
110
111 <!-- Method names MUST NOT be declared with a space after the method name. The opening brace MUST go on its own line, and the closing brace MUST go on the next line following the body. There MUST NOT be a space after the opening parenthesis, and there MUST NOT be a space before the closing parenthesis. -->
112 <!-- checked in Methods/FunctionClosingBraceSniff -->
113 <rule ref="Squiz.Functions.FunctionDeclaration"/>
114 <rule ref="Squiz.Functions.LowercaseFunctionKeywords"/>
115
116 <!-- 4.4 Method Arguments -->
117
118 <!-- In the argument list, there MUST NOT be a space before each comma, and there MUST be one space after each comma. -->
119 <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
120  <properties>
121   <property name="equalsSpacing" value="1"/>
122  </properties>
123 </rule>
124 <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterHint">
125  <severity>0</severity>
126 </rule>
127
128 <!-- Method arguments with default values MUST go at the end of the argument list. -->
129 <rule ref="PEAR.Functions.ValidDefaultValue"/>
130
131 <!-- Argument lists MAY be split across multiple lines, where each subsequent line is indented once. When doing so, the first item in the list MUST be on the next line, and there MUST be only one argument per line. When the argument list is split across multiple lines, the closing parenthesis and opening brace MUST be placed together on their own line with one space between them. -->
132 <rule ref="Squiz.Functions.MultiLineFunctionDeclaration"/>
133
134 <!-- 4.5 abstract, final, and static -->
135
136 <!-- When present, the abstract and final declarations MUST precede the visibility declaration.
137      When present, the static declaration MUST come after the visibility declaration. -->
138 <!-- checked in Methods/MethodDeclarationSniff -->
139
140 <!-- 4.6 Method and Function Calls -->
141
142 <!-- When making a method or function call, there MUST NOT be a space between the method or function name and the opening parenthesis, there MUST NOT be a space after the opening parenthesis, and there MUST NOT be a space before the closing parenthesis. In the argument list, there MUST NOT be a space before each comma, and there MUST be one space after each comma.
143 Argument lists MAY be split across multiple lines, where each subsequent line is indented once. When doing so, the first item in the list MUST be on the next line, and there MUST be only one argument per line. -->
144 <rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
145 <rule ref="PSR2.Methods.FunctionCallSignature.SpaceAfterCloseBracket">
146  <severity>0</severity>
147 </rule>
148
149 <!-- 5. Control Structures -->
150
151 <!-- The general style rules for control structures are as follows:
152 There MUST be one space after the control structure keyword
153 There MUST NOT be a space after the opening parenthesis
154 There MUST NOT be a space before the closing parenthesis
155 There MUST be one space between the closing parenthesis and the opening brace
156 The structure body MUST be indented once
157 The closing brace MUST be on the next line after the body -->
158 <rule ref="Squiz.ControlStructures.ControlSignature"/>
159 <rule ref="Squiz.WhiteSpace.ControlStructureSpacing" />
160 <!--
161    When 3.0 is released, change this to:
162    <rule ref="Squiz.WhiteSpace.ControlStructureSpacing.SpacingAfterOpen" />
163    <rule ref="Squiz.WhiteSpace.ControlStructureSpacing.SpacingBeforeClose" />
164 -->
165 <rule ref="Squiz.WhiteSpace.ControlStructureSpacing.SpacingAfterOpenBrace">
166  <severity>0</severity>
167 </rule>
168 <rule ref="Squiz.WhiteSpace.ControlStructureSpacing.SpaceBeforeCloseBrace">
169  <severity>0</severity>
170 </rule>
171 <rule ref="Squiz.WhiteSpace.ControlStructureSpacing.LineAfterClose">
172  <severity>0</severity>
173 </rule>
174 <rule ref="Squiz.WhiteSpace.ControlStructureSpacing.NoLineAfterClose">
175  <severity>0</severity>
176 </rule>
177 <rule ref="Squiz.WhiteSpace.ScopeClosingBrace"/>
178 <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration"/>
179 <rule ref="Squiz.ControlStructures.ForLoopDeclaration"/>
180 <rule ref="Squiz.ControlStructures.LowercaseDeclaration"/>
181 <!-- checked in ControlStructures/ControlStructureSpacingSniff -->
182
183 <!-- The body of each structure MUST be enclosed by braces. This standardizes how the structures look, and reduces the likelihood of introducing errors as new lines get added to the body. -->
184 <rule ref="Generic.ControlStructures.InlineControlStructure"/>
185
186 <!-- 5.1. if, elseif, else -->
187
188 <!-- The keyword elseif SHOULD be used instead of else if so that all control keywords look like single words. -->
189 <!-- checked in ControlStructures/ElseIfDeclarationSniff -->
190
191 <!-- 5.2. switch, case -->
192
193 <!-- The case statement MUST be indented once from switch, and the break keyword (or other terminating keyword) MUST be indented at the same level as the case body. There MUST be a comment such as // no break when fall-through is intentional in a non-empty case body. -->
194 <!-- checked in ControlStructures/SwitchDeclarationSniff -->
195
196 <!-- 6. Closures -->
197
198 <!-- Closures MUST be declared with a space after the function keyword, and a space before and after the use keyword.
199 The opening brace MUST go on the same line, and the closing brace MUST go on the next line following the body.
200 There MUST NOT be a space after the opening parenthesis of the argument list or variable list, and there MUST NOT be a space before the closing parenthesis of the argument list or variable list.
201 In the argument list and variable list, there MUST NOT be a space before each comma, and there MUST be one space after each comma.
202 Closure arguments with default values MUST go at the end of the argument list.
203 Argument lists and variable lists MAY be split across multiple lines, where each subsequent line is indented once. When doing so, the first item in the list MUST be on the next line, and there MUST be only one argument or variable per line.
204 When the ending list (whether or arguments or variables) is split across multiple lines, the closing parenthesis and opening brace MUST be placed together on their own line with one space between them. -->
205 <!-- checked in Squiz.Functions.MultiLineFunctionDeclaration -->
206</ruleset>
207