forked from GoogleForCreators/web-stories-wp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphpcs.xml.dist
278 lines (251 loc) · 10.4 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
<?xml version="1.0" ?>
<ruleset name="Web Stories PHP Coding Standards Rules">
<config name="minimum_supported_wp_version" value="5.7" />
<rule ref="WordPress-Core">
<type>error</type>
<exclude name="Generic.Arrays.DisallowShortArraySyntax" />
<exclude name="WordPress.PHP.DisallowShortTernary" />
<exclude
name="WordPress.NamingConventions.ValidPostTypeSlug.NotStringLiteral"
/>
</rule>
<rule ref="WordPress-Docs">
<type>error</type>
<exclude-pattern>tests/*</exclude-pattern>
<!-- Documentation is organized with the use of namespaces. -->
<exclude name="Squiz.Commenting.FileComment.MissingPackageTag" />
</rule>
<rule ref="WordPress-Extra">
<type>error</type>
<exclude name="WordPress.Files.FileName" />
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase" />
</rule>
<rule ref="WordPress-VIP-Go">
<type>error</type>
<exclude-pattern>tests/*</exclude-pattern>
<exclude
name="WordPressVIPMinimum.Functions.RestrictedFunctions.flush_rewrite_rules_flush_rewrite_rules"
/>
</rule>
<rule ref="WordPress.Security.NonceVerification">
<exclude-pattern>tests/*</exclude-pattern>
</rule>
<rule ref="WordPress.WP.GlobalVariablesOverride.Prohibited">
<exclude-pattern>tests/*</exclude-pattern>
</rule>
<rule ref="WordPress.WP.EnqueuedResources">
<type>error</type>
<exclude-pattern>tests/*</exclude-pattern>
</rule>
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array">
<element value="web-stories" />
</property>
</properties>
</rule>
<rule ref="WordPress.NamingConventions.ValidVariableName">
<properties>
<property name="customPropertiesWhitelist" type="array">
<element value="childNodes" />
<element value="tagName" />
<element value="textContent" />
<element value="parentNode" />
<element value="nodeType" />
<element value="nodeName" />
<element value="nextSibling" />
<element value="previousSibling" />
<element value="firstChild" />
<element value="lastChild" />
<element value="nodeValue" />
<element value="ownerElement" />
<element value="documentElement" />
<element value="removeChild" />
<element value="ownerDocument" />
<element value="strictErrorChecking" />
<element value="preserveWhiteSpace" />
</property>
</properties>
</rule>
<rule ref="VariableAnalysis.CodeAnalysis.VariableAnalysis" />
<!-- Check for cross-version support for PHP 7.2 and higher. -->
<config name="testVersion" value="7.2-" />
<rule ref="PHPCompatibilityWP" />
<!-- The main plugin file should be parsable by PHP 5.6. -->
<rule ref="Generic.Arrays.DisallowLongArraySyntax.Found">
<exclude-pattern>web-stories.php</exclude-pattern>
<exclude-pattern
>includes/compat/Web_Stories_Compatibility.php</exclude-pattern>
</rule>
<rule ref="WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid">
<exclude-pattern
>tests/phpunit/integration/includes/REST_Setup.php</exclude-pattern>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
<properties>
<property name="enableStaticTypeHint" value="false" />
<property name="enableMixedTypeHint" value="false" />
<property name="enableUnionTypeHint" value="false" />
</properties>
<exclude
name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification"
/>
<!-- The main plugin file should be parsable by PHP 5.6. -->
<exclude-pattern>web-stories.php</exclude-pattern>
<exclude-pattern
>includes/compat/Web_Stories_Compatibility.php</exclude-pattern>
<!-- To ensure backward compatibility for developers using these. -->
<exclude-pattern>includes/Interfaces/FieldState.php</exclude-pattern>
<exclude-pattern>includes/Interfaces/FieldStateFactory.php</exclude-pattern>
<exclude-pattern>includes/Renderer/Stories/*</exclude-pattern>
</rule>
<!-- Checks whether the nullablity ? symbol is present before each nullable and optional parameter. -->
<rule
ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"
/>
<!-- Enforce no space between closing brace and colon of return typehint. -->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing">
<properties>
<property name="spacesCountBeforeColon" value="0" />
</properties>
</rule>
<!-- Checks that there's no whitespace between a nullability symbol and a typehint. -->
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing" />
<!-- Enforces using shorthand scalar typehint variants in phpDocs. -->
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints" />
<!-- Reports useless @var annotation for constants because the type of constant is always clear. -->
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint" />
<!-- Enforces correct space usage in array functions. -->
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration">
<properties>
<property name="spacesCountAfterKeyword" value="0" />
<property name="spacesCountBeforeArrow" value="1" />
<property name="spacesCountAfterArrow" value="1" />
<property name="allowMultiLine" value="true" />
</properties>
</rule>
<!-- Disallows grouped use declarations. -->
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse" />
<!-- Disallows leading backslash in use statement. -->
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash" />
<!-- Checks whether uses at the top of a file are alphabetically sorted. -->
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses" />
<!-- Enforces one space after namespace, disallows content between namespace name and semicolon and disallows use of bracketed syntax. -->
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceDeclaration" />
<!-- Prohibits multiple uses separated by commas. -->
<rule ref="SlevomatCodingStandard.Namespaces.MultipleUsesPerLine" />
<!-- Enforces one blank line before and after namespace. -->
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceSpacing">
<properties>
<property name="linesCountBeforeNamespace" value="1" />
<property name="linesCountAfterNamespace" value="1" />
</properties>
</rule>
<!-- Enforces one blank before first use, after last use and none between two different types of use. -->
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing">
<properties>
<property name="linesCountBeforeFirstUse" value="1" />
<property name="linesCountBetweenUseTypes" value="0" />
<property name="linesCountAfterLastUse" value="1" />
</properties>
</rule>
<!-- Prohibits uses from the same namespace. -->
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace" />
<!-- All references to types named Exception or ending with Exception must be referenced via a fully qualified name. -->
<!-- Looks for unused imports from other namespaces. -->
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="searchAnnotations" value="true" />
</properties>
</rule>
<!-- Require root namespace for special compiled PHP functions. -->
<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalFunctions">
<properties>
<property name="includeSpecialFunctions" value="true" />
</properties>
</rule>
<!-- Class names should be referenced via ::class constant when possible. -->
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference">
<properties>
<property name="enableOnObjects" value="false" />
</properties>
</rule>
<!-- Requires declaring visibility for class constants. -->
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility" />
<!-- Requires use of null coalesce operator (??) when possible. -->
<rule
ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"
/>
<!-- Reports forbidden annotations. -->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations">
<properties>
<property name="forbiddenAnnotations" type="array">
<element value="@package" />
<element value="@subpackage" />
<element value="@author" />
<element value="@created" />
<element value="@access" />
<element value="@version" />
</property>
</properties>
</rule>
<!-- Require specific order of PHPDoc annotations with empty newline between specific groups. -->
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing">
<properties>
<property name="linesCountBeforeFirstContent" value="0" />
<property name="linesCountAfterLastContent" value="0" />
<property name="linesCountBetweenDescriptionAndAnnotations" value="1" />
<property name="linesCountBetweenAnnotationsGroups" value="1" />
<property name="annotationsGroups" type="array">
<element
value="
@SuppressWarnings,
@codeCoverageIgnore
"
/>
<element value="@internal" />
<element value="
@since,
@deprecated,
" />
<element value="
@link,
@see,
@uses,
" />
<element value="
@global,
" />
<element value="
@throws,
" />
<element value="
@param,
@return,
" />
</property>
</properties>
</rule>
<!-- Show details about violated sniffs -->
<arg value="s" />
<!-- Iterate over all PHP files by default -->
<arg name="extensions" value="php" />
<file>.</file>
<!-- Strip the filepaths down to the relevant bit. -->
<arg name="basepath" value="./" />
<!-- Check up to 20 files simultaneously. -->
<arg name="parallel" value="20" />
<!-- Third-party or auto-generated code -->
<exclude-pattern>*/build/*</exclude-pattern>
<exclude-pattern>*/data/*</exclude-pattern>
<exclude-pattern>packages/e2e-tests/src/plugins/*</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/third-party/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>assets/js/*.asset.php</exclude-pattern>
<exclude-pattern>assets/js/*.chunks.php</exclude-pattern>
<exclude-pattern>includes/polyfills/mbstring.php</exclude-pattern>
<exclude-pattern>tests/phpstan/*</exclude-pattern>
<exclude-pattern
>tests/phpunit/unit/includes/MarkupComparison.php</exclude-pattern>
</ruleset>