-
Notifications
You must be signed in to change notification settings - Fork 1
/
phpcs.xml.dist
504 lines (375 loc) · 17.8 KB
/
phpcs.xml.dist
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
<?xml version="1.0" encoding="UTF-8" ?>
<ruleset name="Base Coding Standard">
<description>Base Coding Standard</description>
<!-- README: http://edorian.github.io/php-coding-standard-generator/#phpcs -->
<file>src</file>
<file>tests</file>
<!-- Exclude Composer vendor directory. -->
<exclude-pattern>*/vendor/*</exclude-pattern>
<!-- You can hard-code custom php.ini settings into your custom standard. -->
<ini name="memory_limit" value="256M"/>
<!-- Call with arguments -->
<arg name="report" value="full"/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="10"/>
<arg name="encoding" value="utf-8"/>
<arg name="tab-width" value="4"/>
<arg value="np"/>
<!--
There is a special internal error message produced by PHP_CodeSniffer
when it is unable to detect code in a file, possible due to
the use of short open tags even though php.ini disables them.
You can disable this message in the same way as sniff messages.
Again, the code here will be displayed in the PHP_CodeSniffer
output when using the -s command line argument while checking a file.
-->
<rule ref="Internal.NoCodeFound">
<severity>0</severity>
</rule>
<!-- Don't hide tokenizer exceptions -->
<rule ref="Internal.Tokenizer.Exception">
<type>error</type>
</rule>
<!-- Include the whole PSR-2 standard -->
<rule ref="PSR2">
<!-- To address at a later point in time. -->
<exclude name="Generic.Files.LineLength.TooLong"/>
<!-- Ignoring a number of whitespace issues around blank lines. -->
<exclude name="Squiz.ControlStructures.ControlSignature.SpaceAfterCloseBrace"/>
<exclude name="PSR2.ControlStructures.ControlStructureSpacing.SpacingAfterOpenBrace"/>
<exclude name="PSR2.Classes.ClassDeclaration"/>
</rule>
<!-- ==================== -->
<!-- === Array Sniffs === -->
<!-- ==================== -->
<rule ref="Squiz.Arrays.ArrayDeclaration">
<exclude name="Squiz.Arrays.ArrayDeclaration.KeySpecified"/>
<exclude name="Squiz.Arrays.ArrayDeclaration.ValueNoNewline"/>
</rule>
<!-- We use custom indent rules for arrays -->
<rule ref="Generic.Arrays.ArrayIndent"/>
<!-- Ensures short-array notation. -->
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<!-- Ensures there are no spaces around array brackets -->
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
<rule ref="Squiz.Arrays.ArrayDeclaration.KeyNotAligned">
<severity>0</severity>
</rule>
<rule ref="Squiz.Arrays.ArrayDeclaration.ValueNotAligned">
<severity>0</severity>
</rule>
<rule ref="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned">
<severity>0</severity>
</rule>
<rule ref="Squiz.Arrays.ArrayDeclaration.CloseBraceNewLine">
<severity>0</severity>
</rule>
<!-- Single and multi-line arrays are both allowed. -->
<rule ref="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed">
<severity>0</severity>
</rule>
<rule ref="Squiz.Arrays.ArrayDeclaration.MultiLineNotAllowed">
<severity>0</severity>
</rule>
<!-- All nice and good, but too much of a fuss for the outer array of nested arrays. -->
<rule ref="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned">
<severity>0</severity>
</rule>
<!-- ====================== -->
<!-- === Classes Sniffs === -->
<!-- ====================== -->
<!-- Classes with duplicate names are not allowed -->
<rule ref="Generic.Classes.DuplicateClassName"/>
<!--
Classes must have their opening brace on a new line and must indeted by $indent spaces.
http://pear.php.net/manual/en/standards.classdef.php
-->
<rule ref="PEAR.Classes.ClassDeclaration"/>
<!-- Checks the declaration of the class and its inheritance is correct -->
<rule ref="Squiz.Classes.ClassDeclaration"/>
<!-- All classes keywords should be lowercase -->
<rule ref="Squiz.Classes.LowercaseClassKeywords"/>
<!-- Tests self member references -->
<rule ref="Squiz.Classes.SelfMemberReference"/>
<!-- Test class names are camel-cased properly -->
<rule ref="Squiz.Classes.ValidClassName"/>
<!-- ============================ -->
<!-- === Code Analysis Sniffs === -->
<!-- ============================ -->
<!-- Warns when it finds empty PHP open/close tag combinations or superfluous semicolons. -->
<rule ref="Generic.CodeAnalysis.EmptyPHPStatement"/>
<!-- Statements may not have an empty body. -->
<rule ref="Generic.CodeAnalysis.EmptyStatement">
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedCatch"/>
</rule>
<!-- If- and elseif-statements may not be unconditional. -->
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
<!-- If a class is declared as being final, it is redundant to redeclare methods as final -->
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
<!-- Detects unnecessary overridden methods that simply call their parent -->
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<!-- Reports cases where incrementer jumbling might happen in 'for' loops. -->
<rule ref="Generic.CodeAnalysis.JumbledIncrementer"/>
<!-- ========================= -->
<!-- === Commenting Sniffs === -->
<!-- ========================= -->
<rule ref="Squiz.Commenting.BlockComment">
<exclude name="Squiz.Commenting.BlockComment.NoEmptyLineAfter"/>
<exclude name="Squiz.Commenting.BlockComment.SingleLine"/>
<exclude name="Squiz.Commenting.BlockComment.CloserSameLine"/>
<exclude name="Squiz.Commenting.BlockComment.FirstLineIndent"/>
<exclude name="Squiz.Commenting.BlockComment.LineIndent"/>
<exclude name="Squiz.Commenting.BlockComment.NoNewLine"/>
</rule>
<rule ref="Squiz.Commenting.DocCommentAlignment"/>
<rule ref="Squiz.Commenting.EmptyCatchComment"/>
<rule ref="Squiz.Commenting.InlineComment"/>
<rule ref="Squiz.Commenting.LongConditionClosingComment"/>
<rule ref="Squiz.Commenting.PostStatementComment"/>
<rule ref="Squiz.Commenting.VariableComment"/>
<!-- Inline Documentation check. -->
<rule ref="Generic.Commenting.DocComment">
<!-- Having a @see or @internal tag before the @param tags is fine. -->
<exclude name="Generic.Commenting.DocComment.ParamNotFirst"/>
<exclude name="Generic.Commenting.DocComment.MissingShort"/>
<type>error</type>
</rule>
<rule ref="PEAR.Commenting">
<exclude name="PEAR.Commenting.FileComment"/>
<!-- Exclude PEAR specific tag requirements. -->
<exclude name="PEAR.Commenting.FileComment.MissingCategoryTag"/>
<exclude name="PEAR.Commenting.FileComment.MissingPackageTag"/>
<exclude name="PEAR.Commenting.FileComment.MissingAuthorTag"/>
<exclude name="PEAR.Commenting.FileComment.MissingVersionTag"/>
<exclude name="PEAR.Commenting.FileComment.MissingLinkTag"/>
<exclude name="PEAR.Commenting.FileComment.MissingLicenseTag"/>
<exclude name="PEAR.Commenting.ClassComment.MissingCategoryTag"/>
<exclude name="PEAR.Commenting.ClassComment.MissingPackageTag"/>
<exclude name="PEAR.Commenting.ClassComment.MissingAuthorTag"/>
<exclude name="PEAR.Commenting.ClassComment.MissingLicenseTag"/>
<exclude name="PEAR.Commenting.ClassComment.MissingLinkTag"/>
<!-- Having a @see or @internal tag before the @category tag is fine. -->
<exclude name="PEAR.Commenting.ClassComment.CategoryTagOrder"/>
<exclude name="PEAR.Commenting.FunctionComment.MissingParamComment"/>
</rule>
<!-- ================================= -->
<!-- === Control Structures Sniffs === -->
<!-- ================================= -->
<!-- Inline controls (IF, ELSE, FOR, WHILE) must have brackets -->
<rule ref="Generic.ControlStructures.InlineControlStructure"/>
<!-- Ensures that switch statements are defined according to PSR2. -->
<rule ref="PSR2.ControlStructures.SwitchDeclaration"/>
<!-- The keyword elseif SHOULD be used instead of else if so that all control keywords look like single words. -->
<rule ref="PSR2.ControlStructures.ElseIfDeclaration">
<type>error</type>
</rule>
<!-- ==================== -->
<!-- === Files Sniffs === -->
<!-- ==================== -->
<!-- ========================= -->
<!-- === Formatting Sniffs === -->
<!-- ========================= -->
<rule ref="Squiz.Formatting.OperatorBracket"/>
<rule ref="Generic.Formatting.SpaceAfterCast"/>
<!-- Checks alignment of assignments. -->
<rule ref="Generic.Formatting.MultipleStatementAlignment">
<properties>
<property name="maxPadding" value="15"/>
<property name="ignoreMultiLine" value="true"/>
<property name="error" value="true"/>
</properties>
</rule>
<!-- ======================== -->
<!-- === Functions Sniffs === -->
<!-- ======================== -->
<rule ref="Squiz.Functions.FunctionDuplicateArgument"/>
<!-- Disallows usage of call-time pass-by-reference. See: http://php.net/manual/en/language.references.pass.php -->
<rule ref="Generic.Functions.CallTimePassByReference"/>
<!--
Warns when function values are returned directly.
The Sniff enforces that the result of a function call should be assigned to a variable before being returned.
-->
<rule ref="MySource.PHP.ReturnFunctionValue"/>
<!-- ====================== -->
<!-- === Metrics Sniffs === -->
<!-- ====================== -->
<!--
Defines a maximum $nestingLevel and $absoluteNestingLevel for functions.
If $nestingLevel has the same value as $absoluteNestingLevel then there will be only errors and no warnings.
-->
<rule ref="Generic.Metrics.NestingLevel"/>
<!-- ================================= -->
<!-- === Naming Conventions Sniffs === -->
<!-- ================================= -->
<!-- Constructor should be in PHP5 mode (__construct) -->
<rule ref="Generic.NamingConventions.ConstructorName"/>
<!-- Check that function and method names are in camelCaps. -->
<rule ref="Generic.NamingConventions.CamelCapsFunctionName">
<properties>
<!-- Allow for two adjacent capital letters for acronyms. -->
<property name="strict" value="false"/>
</properties>
</rule>
<!-- ====================== -->
<!-- === Objects Sniffs === -->
<!-- ====================== -->
<!-- ======================== -->
<!-- === Operators Sniffs === -->
<!-- ======================== -->
<!-- Disallow "and" and "or". Use && and || instead -->
<rule ref="Squiz.Operators.ValidLogicalOperators"/>
<!-- ================== -->
<!-- === PHP Sniffs === -->
<!-- ================== -->
<!-- Ensures PHP believes the syntax is clean. -->
<rule ref="Generic.PHP.Syntax"/>
<!-- Deprecated functions are not allowed. This is a modern codebase -->
<rule ref="Generic.PHP.DeprecatedFunctions"/>
<!-- Makes sure that shorthand PHP open tags are not used. -->
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
<rule ref="Generic.PHP.DisallowShortOpenTag.EchoFound"/>
<!-- Discourage unsafe functions -->
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array">
<element key="die" value="null"/>
<element key="var_dump" value="null"/>
<element key="sizeof" value="count"/>
<element key="delete" value="unset"/>
<element key="print" value="echo"/>
<element key="is_null" value="null"/>
<element key="create_function" value="null"/>
</property>
</properties>
</rule>
<!-- Disallows usage of the @ operator. -->
<rule ref="Generic.PHP.NoSilencedErrors">
<properties>
<property name="error" value="true"/>
</properties>
</rule>
<!-- Ensures the PHP_SAPI constant is used instead of php_sapi_name() -->
<rule ref="Generic.PHP.SAPIUsage"/>
<!-- Ensures all calls to builtin PHP functions are lowercase. -->
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
<!-- Checks that all PHP types are lowercase. -->
<rule ref="Generic.PHP.LowerCaseType"/>
<!-- ==================== -->
<!-- === Scope Sniffs === -->
<!-- ==================== -->
<!-- Ensures that class members have scope modifiers. -->
<rule ref="Squiz.Scope.MemberVarScope"/>
<!-- Ensures that $this is not used in static methods to avoid runtime errors. -->
<rule ref="Squiz.Scope.StaticThisUsage"/>
<!-- ====================== -->
<!-- === Strings Sniffs === -->
<!-- ====================== -->
<!-- Use one string instead of concatenating 2 strings together -->
<rule ref="Generic.Strings.UnnecessaryStringConcat">
<properties>
<property name="allowMultiline" value="true"/>
</properties>
</rule>
<!-- Makes sure there are one spaces between the concatenation operator (.) the strings -->
<rule ref="Squiz.Strings.ConcatenationSpacing">
<properties>
<property name="spacing" value="1"/>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule>
<rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar">
<type>warning</type>
</rule>
<!-- ============================== -->
<!-- === Version Control Sniffs === -->
<!-- ============================== -->
<!-- ========================== -->
<!-- === White Space Sniffs === -->
<!-- ========================== -->
<!-- PSR2 appears to ignore blank lines for superfluous whitespace and in several other places. Let's fix that. -->
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<property name="ignoreBlankLines" value="false"/>
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.StartFile">
<severity>5</severity>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EndFile">
<severity>5</severity>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines">
<severity>5</severity>
</rule>
<rule ref="Generic.WhiteSpace.ArbitraryParenthesesSpacing">
<properties>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule>
<!--
Checks the separation between methods in a class or interface.
Methods are expected to have two blank lines between them.
-->
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
<properties>
<property name="spacing" value="1"/>
</properties>
</rule>
<!-- Object operators must be indented 4 spaces if they are the first thing on a line. -->
<rule ref="PEAR.WhiteSpace.ObjectOperatorIndent"/>
<!-- Ensures all language constructs (without brackets) contain a single space between themselves and their content. -->
<rule ref="Generic.WhiteSpace.LanguageConstructSpacing"/>
<!-- Ensures that there is one space before and after a logical operator. -->
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
<!-- Ensures that there is one blank lines between each member declaration. -->
<rule ref="Squiz.WhiteSpace.MemberVarSpacing"/>
<!-- Ensures there is no whitespace before a ObjectOperator ( -> ). -->
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule>
<!-- Ensures that operators have one space surrounding them. -->
<rule ref="Squiz.WhiteSpace.OperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule>
<!-- Ensures that there is no whitespace before a semicolon. -->
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
<!-- Ensures that the 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"/>
<!--
Checks that no whitespace proceeds the first content of the file,
exists after the last content of the file, resides after content on any line, or are two empty lines in functions.
-->
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
<!-- ============================================= -->
<!-- === Namespace and Use Declarations Sniffs === -->
<!-- ============================================= -->
<!-- There must be one blank line after the namespace declaration. -->
<rule ref="PSR2.Namespaces.NamespaceDeclaration"/>
<!-- Ensures USE blocks are declared according to PSR2. -->
<rule ref="PSR2.Namespaces.UseDeclaration"/>
<!-- ======================================== -->
<!-- === Classes, Properties, and Methods === -->
<!-- ======================================== -->
<rule ref="PSR12.Classes.ClassInstantiation"/>
<!-- Private properties MUST not be prefixed with an underscore -->
<rule ref="PSR2.Classes.PropertyDeclaration.Underscore">
<type>error</type>
</rule>
<!-- Only one argument per line in multi-line function calls -->
<rule ref="PEAR.Functions.FunctionCallSignature">
<properties>
<property name="allowMultipleArguments" value="false"/>
</properties>
</rule>
<!-- Private methods MUST not be prefixed with an underscore -->
<rule ref="PSR2.Methods.MethodDeclaration.Underscore">
<type>error</type>
</rule>
<rule ref="PSR12.Keywords.ShortFormTypeKeywords"/>
</ruleset>