-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphpcs.xml
More file actions
230 lines (169 loc) · 8.18 KB
/
Copy pathphpcs.xml
File metadata and controls
230 lines (169 loc) · 8.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<?xml version="1.0"?>
<ruleset name="Example phpcs default">
<!-- Useful guide to help you can be found here https://github.com/squizlabs/PHP_CodeSniffer/wiki/Customisable-Sniff-Properties -->
<description>Example configuration for phpcs, command line php code sniffer</description>
<!-- Exclude Composer PHP vendor folder -->
<exclude-pattern>vendor/*</exclude-pattern>
<!-- Exclude any idea directory -->
<exclude-pattern>.idea/*</exclude-pattern>
<!-- Our tab width is four spaces -->
<arg name="tab-width" value="4"/>
<!-- Ensure we use UNIX newlines -->
<rule ref="Generic.Files.LineEndings">
<properties>
<property name="eolChar" value="\n" />
</properties>
</rule>
<!-- Include some sniffs from existing standards -->
<!-- Statements must not have an empty body -->
<rule ref="Generic.CodeAnalysis.EmptyStatement" />
<!-- PHP code MUST use only UTF-8 without BOM. -->
<rule ref="Generic.Files.ByteOrderMark" />
<!-- Dont allow the short php open tag, we want <?php -->
<rule ref="Generic.PHP.DisallowShortOpenTag" />
<!-- No superfluous whitespace at end of lines -->
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace" />
<!-- Array's should be indented correctly -->
<rule ref="Generic.Arrays.ArrayIndent">
<properties>
<property name="indent" value="2" />
</properties>
</rule>
<!-- There MUST NOT be more than one statement per line. -->
<rule ref="Generic.Formatting.DisallowMultipleStatements" />
<!-- In the argument list, there MUST NOT be a space before each comma, and there MUST be one space after each comma. -->
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
<properties>
<property name="equalsSpacing" value="1" />
</properties>
</rule>
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterHint">
<severity>0</severity>
</rule>
<!-- Warn about a nesting level of 6, any deeper than 10 is an error, less strict than our standard! -->
<rule ref="Generic.Metrics.NestingLevel" />
<!-- Constants must be upper case -->
<rule ref="Generic.NamingConventions.UpperCaseConstantName" />
<!-- Forbid use of php functions which are kept for compatibility when new ones should be used -->
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array"
value="print=>echo,create_function=>null,define=>const,extract=>checkParameter" />
</properties>
</rule>
<!-- Warn about discouraged functions, such as print_r, and error_log -->
<rule ref="Squiz.PHP.DiscouragedFunctions" />
<!-- Don't allow globals -->
<rule ref="Squiz.PHP.GlobalKeyword" />
<!-- Warn about non executable code which can never be executed (function returns before reaching it?)-->
<rule ref="Squiz.PHP.NonExecutableCode" />
<!-- Should use elseif, rather than else if -->
<rule ref="PSR2.ControlStructures.ElseIfDeclaration" />
<!-- Ensure that $this is not used in static methods to avoid runtime errors-->
<rule ref="Squiz.Scope.StaticThisUsage" />
<!-- Ensure there is spacing between logical operators -->
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing" />
<!-- Ensure there is one space between member declration -->
<rule ref="Squiz.WhiteSpace.MemberVarSpacing" />
<!-- Ensure there is no whitespace before a semicolon -->
<rule ref="Squiz.WhiteSpace.SemicolonSpacing" />
<!-- The PHP constants true, false, and null MUST be in lower case. -->
<rule ref="Generic.PHP.LowerCaseConstant" />
<!-- Function cames must be camelCase capitalised -->
<rule ref="Generic.NamingConventions.CamelCapsFunctionName">
<!-- Disable strict mode so two capitals can sit together, eg setXAxis() over setXaxis() -->
<properties>
<property name="strict" value="false" />
</properties>
</rule>
<!-- Ensure there is no closing tag in the php doc -->
<rule ref="Zend.Files.ClosingTag" />
<!-- Ensure functions are seperated by one space -->
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
<properties>
<property name="spacing" value="1" />
</properties>
</rule>
<!-- Ensure concactenation of strings have spaces -->
<rule ref="Squiz.Strings.ConcatenationSpacing">
<properties>
<property name="spacing" value="1" />
</properties>
</rule>
<!-- Ensure spacing between function declaration arguments -->
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
<properties>
<property name="equalsSpacing" value="1" />
</properties>
</rule>
<!-- Functions must have comments -->
<rule ref="Squiz.Commenting.FunctionComment">
<!-- Disable this until we upgrade to php7 on live, 5.6 does not support ScalarTypeHints -->
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing" />
</rule>
<!-- Variables must have comments -->
<rule ref="Squiz.Commenting.VariableComment" />
<!-- Only 50% of a comment can be commented out code -->
<rule ref="Squiz.PHP.CommentedOutCode">
<properties>
<property name="maxPercentage" value="50" />
</properties>
</rule>
<!-- Do not allow code that is too complicated -->
<rule ref="Generic.Metrics.CyclomaticComplexity" />
<!-- Do not allow depreciated functions -->
<rule ref="Generic.PHP.DeprecatedFunctions" />
<!-- Make sure perl comments # are not used. -->
<rule ref="PEAR.Commenting.InlineComment" />
<!-- Ensure standard approach to including files, its a statement, not a function -->
<rule ref="PEAR.Files.IncludingFile" />
<!-- Standardise on short array syntax [], rather than long array() -->
<rule ref="Generic.Arrays.DisallowLongArraySyntax.Found" />
<!-- Enforces function call signatures "foo($a, $b, $c)" style reporting all other whitespaces -->
<rule ref="PEAR.Functions.FunctionCallSignature">
<properties>
<property name="indent" value="2" />
</properties>
</rule>
<!-- Ensure that parameters defined for a function that have a default value come at the end of the function signature. -->
<rule ref="PEAR.Functions.ValidDefaultValue" />
<!-- Class and interface names must start with a capital letter for each part of the name, seperated by underscores -->
<rule ref="PEAR.NamingConventions.ValidClassName" />
<!-- Each class must be in a file by itself and must be in a namespace of at least one level of depth
-->
<rule ref="PSR1.Classes.ClassDeclaration"/>
<!-- Ensure file ends with a newline character -->
<rule ref="PSR2.Files.EndFileNewline" />
<!-- Rules when embedding PHP within files -->
<rule ref="Squiz.PHP.EmbeddedPhp" />
<!-- Ensure all calls to php functions are lower case. -->
<rule ref="Squiz.PHP.LowercasePHPFunctions" />
<!-- Ensure that class members have scope modifiers -->
<rule ref="Squiz.Scope.MemberVarScope" />
<!-- Ensure that methods have scope modifiers (public|private|protected statements) -->
<rule ref="Squiz.Scope.MethodScope" />
<!-- Methods should not use single _ to indicate protected or private -->
<rule ref="PSR2.Methods.MethodDeclaration" />
<!-- Methods should be formatted correctly, no space between name and params -->
<rule ref="Squiz.Functions.FunctionDeclaration" />
<!-- Ensures that $this is not used in static methods to avoid runtime errors -->
<rule ref="Squiz.Scope.StaticThisUsage" />
<!-- Ensure that cast spacing doesn't contain whitespace -->
<rule ref="Squiz.WhiteSpace.CastSpacing" />
<!-- Ensures that control structures have a certain style of spacing around brackets -->
<rule ref="Squiz.WhiteSpace.ControlStructureSpacing" />
<!-- Ensure closing braces of scopes are on a new line and indented correctly -->
<rule ref="Squiz.WhiteSpace.ScopeClosingBrace" />
<!-- Ensure there is a single space after scope keywords. -->
<rule ref="Squiz.WhiteSpace.ScopeKeywordSpacing" />
<!-- Functions opening brace must be on function definition line -->
<rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie" />
<!-- Enforces show control signatures are spaced -end of line after opening bracket -->
<rule ref="PEAR.ControlStructures.ControlSignature" />
<!-- Function arguments should have a single space -->
<rule ref="Generic.Functions.FunctionCallArgumentSpacing" />
<!-- Avoid global functions, encourage tidy re-usability -->
<rule ref="Squiz.Functions.GlobalFunction.Found" />
<!-- $_REQUEST is not allowed. You must specify $_GET or $_POST! -->
<rule ref="Generic.PHP.DisallowRequestSuperglobal" />
</ruleset>