-
Notifications
You must be signed in to change notification settings - Fork 2
/
phpcs.xml
429 lines (343 loc) · 15 KB
/
phpcs.xml
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
<?xml version="1.0"?>
<ruleset name="Made_in_Ukraine">
<description>PHP Code Standards used at made.ua</description>
<!--
#########################################################################
These Code Standards (mostly) Adopted From WordPress Code Standards.
Revision date - 13.03.2017
#########################################################################
-->
<rule ref="WordPress" />
<!-- ##### Path Never Going To Be Tested ##### -->
<exclude-pattern>tests/*</exclude-pattern>
<exclude-pattern>vendor/*</exclude-pattern>
<!-- https://github.com/Automattic/vip-scanner/blob/master/vip-scanner/checks/ForbiddenPHPFunctionsCheck.php -->
<rule ref="WordPress.PHP.DiscouragedPHPFunctions">
<properties>
<property name="exclude" value="obfuscation" />
</properties>
</rule>
<!--
https://vip.wordpress.com/documentation/code-review-what-we-look-for/#commented-out-code-debug-code-or-output
//-->
<rule ref="WordPress.PHP.DevelopmentFunctions" />
<rule ref="WordPress.PHP.DevelopmentFunctions.error_log">
<type>error</type>
</rule>
<!--
https://vip.wordpress.com/documentation/vip/code-review-what-we-look-for/#settings-alteration
//-->
<rule ref="WordPress.PHP.DevelopmentFunctions.prevent_path_disclosure">
<type>error</type>
</rule>
<!--
Rule: Use real tabs and not spaces.
//-->
<arg name="tab-width" value="4"/>
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/>
<!--
Rule: Use single and double quotes when appropriate.
If you're not evaluating anything in the string, use single quotes.
-->
<rule ref="Squiz.Strings.DoubleQuoteUsage"/>
<rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar">
<severity>0</severity>
</rule>
<!--
Handbook: PHP - Brace Style.
Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#brace-style
Rule: Braces shall be used for all blocks.
//-->
<rule ref="Squiz.ControlStructures.ControlSignature" />
<rule ref="Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace">
<severity>0</severity>
</rule>
<!--
Rule: If you consider a long block unavoidable, please put a short comment at the end ...
- typically this is appropriate for a logic block, longer than about 35 rows.
//-->
<rule ref="Squiz.Commenting.LongConditionClosingComment">
<properties>
<property name="lineLimit" value="35" />
<property name="commentFormat" value="// End %s()." />
</properties>
<exclude name="Squiz.Commenting.LongConditionClosingComment.SpacingBefore" />
</rule>
<!--
Rule: Braces should always be used, even when they are not required.
//-->
<rule ref="Generic.ControlStructures.InlineControlStructure" />
<!--
Handbook: PHP - Use elseif, not else if.
Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#use-elseif-not-else-if
//-->
<rule ref="PSR2.ControlStructures.ElseIfDeclaration"/>
<!--
Handbook: PHP - Regular Expressions.
Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#regular-expressions
Rule: Perl compatible regular expressions should be used in preference
to their POSIX counterparts.
//-->
<rule ref="WordPress.PHP.POSIXFunctions" />
<!--
Handbook: PHP - No Shorthand PHP Tags.
Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#no-shorthand-php-tags
Rule: Never use shorthand PHP start tags. Always use full PHP tags.
//-->
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
<rule ref="Generic.PHP.DisallowAlternativePHPTags"/>
<!--
Handbook: PHP - Remove Trailing Spaces.
Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#remove-trailing-spaces
Rule: Remove trailing whitespace at the end of each line of code.
//-->
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
<!--
Rule: Omitting the closing PHP tag at the end of a file is preferred.
//-->
<rule ref="PSR2.Files.ClosingTag"/>
<!--
Handbook: PHP - Space Usage.
Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#space-usage
Rule: Always put spaces after commas, and on both sides of logical,
comparison, string and assignment operators.
//-->
<rule ref="WordPress.WhiteSpace.OperatorSpacing"/>
<rule ref="Squiz.Strings.ConcatenationSpacing">
<properties>
<property name="spacing" value="1"/>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule>
<!--
Rule: Put spaces on both sides of the opening and closing parenthesis of
if, elseif, foreach, for, and switch blocks.
//-->
<rule ref="WordPress.WhiteSpace.ControlStructureSpacing"/>
<!--
Rule: Define a function like so: function my_function( $param1 = 'foo', $param2 = 'bar' ) {
//-->
<rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie">
<properties>
<property name="checkClosures" value="true" />
</properties>
</rule>
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
<properties>
<property name="equalsSpacing" value="1" />
<property name="requiredSpacesAfterOpen" value="1" />
<property name="requiredSpacesBeforeClose" value="1" />
</properties>
<exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingBeforeClose" />
</rule>
<!--
Rule: Call a function, like so: my_function( $param1, func_param( $param2 ) );
//-->
<rule ref="PEAR.Functions.FunctionCallSignature">
<properties>
<property name="requiredSpacesAfterOpen" value="1" />
<property name="requiredSpacesBeforeClose" value="1" />
</properties>
<exclude name="PEAR.Functions.FunctionCallSignature.Indent"/>
</rule>
<rule ref="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket">
<severity>0</severity>
</rule>
<rule ref="PEAR.Functions.FunctionCallSignature.CloseBracketLine">
<severity>0</severity>
</rule>
<!--
Rule: Perform logical comparisons, like so: if ( ! $foo ) {
Rule: When type casting, do it like so: $foo = (boolean) $bar;
//-->
<rule ref="Generic.Formatting.SpaceAfterCast"/>
<rule ref="Squiz.WhiteSpace.CastSpacing" />
<rule ref="WordPress.WhiteSpace.CastStructureSpacing"/>
<!--
Handbook: PHP - Database Queries.
Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#database-queries
Rule: Avoid touching the database directly.
//-->
<rule ref="WordPress.DB.RestrictedFunctions"/>
<rule ref="WordPress.DB.RestrictedClasses"/>
<!--
Handbook: PHP - Yoda Conditions.
Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#yoda-conditions
Rule: When doing logical comparisons, always put the variable on the right side,
constants or literals on the left.
//-->
<rule ref="WordPress.PHP.YodaConditions"/>
<!--
Handbook: PHP - Clever Code.
Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#clever-code
Rule: In general, readability is more important than cleverness or brevity.
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/607
//-->
<rule ref="Squiz.PHP.DisallowMultipleAssignments"/>
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
<!--
Important to prevent issues with content being sent before headers.
//-->
<rule ref="Generic.Files.ByteOrderMark" />
<!--
All line endings should be \n.
//-->
<rule ref="Generic.Files.LineEndings">
<properties>
<property name="eolChar" value="\n"/>
</properties>
</rule>
<!--
All files should end with a new line.
//-->
<rule ref="Generic.Files.EndFileNewline"/>
<!--
Lowercase PHP constants, like true, false and null.
Ref. http://make.wordpress.org/core/handbook/coding-standards/php/#naming-conventions
//-->
<rule ref="Generic.PHP.LowerCaseConstant"/>
<!--
Lowercase PHP keywords, like class, function and case.
//-->
<rule ref="Generic.PHP.LowerCaseKeyword"/>
<!--
Class opening braces should be on the same line as the statement.
//-->
<rule ref="Generic.Classes.OpeningBraceSameLine"/>
<!--
Not in the coding standard handbook: WP specific sniffs.
Ref: https://make.wordpress.org/core/handbook/best-practices/internationalization/ (limited info)
Ref: https://developer.wordpress.org/plugins/internationalization/ (more extensive)
Check for correct usage of the WP i18n functions.
//-->
<rule ref="WordPress.WP.I18n"/>
<!--
Rule: Escaping
Ref: https://vip.wordpress.com/documentation/code-review-what-we-look-for/#validation-sanitization-and-escaping
Ref: https://vip.wordpress.com/documentation/best-practices/security/validating-sanitizing-escaping/
//-->
<!--
eval() and create_function()
https://vip.wordpress.com/documentation/vip/code-review-what-we-look-for/#eval-and-create_functio
//-->
<rule ref="Squiz.PHP.Eval"/>
<rule ref="Squiz.PHP.Eval.Discouraged">
<type>error</type>
<message>eval() is a security risk so not allowed.</message>
</rule>
<!--
https://vip.wordpress.com/documentation/code-review-what-we-look-for/#using-in_array-without-strict-parameter
//-->
<rule ref="WordPress.PHP.StrictInArray" />
<!--
@made_in_ua
//-->
<rule ref="Squiz.Commenting.InlineComment.InvalidEndChar">
<type>warning</type>
</rule>
<!--
Handbook: PHP Documentation Standards
Ref: https://make.wordpress.org/core/handbook/best-practices/inline-documentation-standards/php/
//-->
<rule ref="Squiz.Commenting">
<!-- Excluded to allow /* translators: ... */ comments -->
<exclude name="Squiz.Commenting.BlockComment.SingleLine"/>
<!-- Sniff seems to require indenting with spaces -->
<exclude name="Squiz.Commenting.BlockComment.FirstLineIndent"/>
<!-- Sniff seems to require indenting with spaces -->
<exclude name="Squiz.Commenting.BlockComment.LineIndent"/>
<!-- Sniff seems to require indenting with spaces -->
<exclude name="Squiz.Commenting.BlockComment.LastLineIndent"/>
<!-- @custom - Need to have a comments a code blocks separation. -->
<exclude name="Squiz.Commenting.BlockComment.NoNewLine"/>
<!-- WP requires /** for require() et al. See https://github.com/squizlabs/PHP_CodeSniffer/pull/581 -->
<exclude name="Squiz.Commenting.BlockComment.WrongStart"/>
<!-- WP handbook doesn't clarify one way or another, so ignore -->
<exclude name="Squiz.Commenting.BlockComment.NoEmptyLineAfter"/>
<!-- WP prefers indicating @since, @package, @subpackage etc in class comments -->
<exclude name="Squiz.Commenting.ClassComment.TagNotAllowed"/>
<!-- WP doesn't require //end ... for classes and functions -->
<exclude name="Squiz.Commenting.ClosingDeclarationComment.Missing"/>
<!-- Excluded to allow param documentation for arrays -->
<exclude name="Squiz.Commenting.DocCommentAlignment.SpaceAfterStar"/>
<!-- WP doesn't require a @author value for Squiz -->
<exclude name="Squiz.Commenting.FileComment.IncorrectAuthor"/>
<!-- WP doesn't require a @copyright value for Squiz -->
<exclude name="Squiz.Commenting.FileComment.IncorrectCopyright"/>
<!-- WP doesn't require @author tags -->
<exclude name="Squiz.Commenting.FileComment.MissingAuthorTag"/>
<!-- WP doesn't require @subpackage tags -->
<exclude name="Squiz.Commenting.FileComment.MissingSubpackageTag"/>
<!-- WP doesn't require @copyright tags -->
<exclude name="Squiz.Commenting.FileComment.MissingCopyrightTag"/>
<!-- WP has a different prefered order of tags -->
<exclude name="Squiz.Commenting.FileComment.PackageTagOrder"/>
<!-- WP has a different prefered order of tags -->
<exclude name="Squiz.Commenting.FileComment.SubpackageTagOrder"/>
<!-- WP has a different prefered order of tags -->
<exclude name="Squiz.Commenting.FileComment.AuthorTagOrder"/>
<!-- WP has a different prefered order of tags -->
<exclude name="Squiz.Commenting.FileComment.CopyrightTagOrder"/>
<!-- WP prefers int and bool instead of integer and boolean -->
<exclude name="Squiz.Commenting.FunctionComment.IncorrectParamVarName"/>
<!-- WP prefers int and bool instead of integer and boolean -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturn"/>
<!-- WP prefers indicating a @return null for early returns -->
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturnNotVoid"/>
<!-- WP states not all functions require @return -->
<exclude name="Squiz.Commenting.FunctionComment.MissingReturn"/>
<!-- Excluded to allow param documentation for arrays -->
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentNotCapital"/>
<!-- Excluded to allow param documentation for arrays -->
<exclude name="Squiz.Commenting.FunctionComment.SpacingAfterParamName"/>
<!-- WP doesn't require type hints -->
<exclude name="Squiz.Commenting.FunctionComment.TypeHintMissing"/>
<!-- Exclude to allow duplicate hooks to be documented -->
<exclude name="Squiz.Commenting.InlineComment.DocBlock"/>
<!-- Excluded to allow /* translators: ... */ comments -->
<exclude name="Squiz.Commenting.InlineComment.NotCapital"/>
<!-- Excluded all issues regarding commented inline code. -->
<exclude name="Squiz.Commenting.InlineComment.SpacingAfter"/>
<!--todo Not in Inline Docs standard, and a code smell -->
<exclude name="Squiz.Commenting.LongConditionClosingComment"/>
<!--TODO Not in Inline Docs standard, and needed to bypass WPCS checks -->
<exclude name="Squiz.Commenting.PostStatementComment"/>
<!--@todo WP prefers int and bool instead of integer and boolean -->
<exclude name="Squiz.Commenting.VariableComment.IncorrectVarType"/>
<!--FIXME WP demands a @since tag for class variables -->
<exclude name="Squiz.Commenting.VariableComment.TagNotAllowed"/>
<!--@fixme WP prefers @since first -->
<exclude name="Squiz.Commenting.VariableComment.VarOrder"/>
<!--@issue It is too early for PHP7 features to be required -->
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing" />
</rule>
<rule ref="Generic.Commenting">
<!-- WP has different alignment of tag values -->
<exclude name="Generic.Commenting.DocComment.TagValueIndent"/>
<!-- WP has a different prefered order of tags -->
<exclude name="Generic.Commenting.DocComment.ParamNotFirst"/>
<!-- Excluded to allow param documentation for arrays -->
<exclude name="Generic.Commenting.DocComment.ParamGroup"/>
<!-- WP prefers no empty line between @param tags and @return -->
<exclude name="Generic.Commenting.DocComment.NonParamGroup"/>
<!-- Excluded to allow param documentation for arrays -->
<exclude name="Generic.Commenting.DocComment.TagsNotGrouped"/>
<!-- Exclude to allow duplicate hooks to be documented -->
<exclude name="Generic.Commenting.DocComment.ContentAfterOpen"/>
<!-- Exclude to allow duplicate hooks to be documented -->
<exclude name="Generic.Commenting.DocComment.SpacingBeforeShort"/>
<!-- Exclude to allow duplicate hooks to be documented -->
<exclude name="Generic.Commenting.DocComment.ContentBeforeClose"/>
<!-- WP allows @todo's in comments -->
<exclude name="Generic.Commenting.Todo.CommentFound"/>
<!-- WP allows @todo's in comments -->
<exclude name="Generic.Commenting.Todo.TaskFound"/>
</rule>
<!-- exclude the 'empty' index files from some documentation checks -->
<rule ref="Squiz.Commenting.FileComment.WrongStyle">
<exclude-pattern>*/index.php</exclude-pattern>
</rule>
<rule ref="Squiz.Commenting.InlineComment.SpacingAfter">
<exclude-pattern>*/index.php</exclude-pattern>
</rule>
</ruleset>