-
Notifications
You must be signed in to change notification settings - Fork 383
/
.phpcs.xml.dist
193 lines (171 loc) · 8.42 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
<?xml version="1.0"?>
<ruleset name="WordPress Coding Standards for AMP">
<!-- Exclude the QA tester plugin -->
<exclude-pattern>qa-tester/*</exclude-pattern>
<!-- Exclude stub files as they are auto-generated -->
<exclude-pattern>tests/php/static-analysis-stubs/*</exclude-pattern>
<exclude-pattern>includes/ecosystem-data/*</exclude-pattern>
<rule ref="WordPress-Core">
<exclude name="Universal.Arrays.DisallowShortArraySyntax" />
<exclude name="Generic.Commenting.DocComment.MissingShort" />
<exclude name="Universal.Operators.DisallowShortTernary" />
<!-- @TODO(P0): Fix these once WPCS is merged on develop and remove the exclusions. -->
<exclude name="PSR2.Methods.FunctionClosingBrace.SpacingBeforeClose" />
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.SpaceAfterFunction" />
<exclude name="Universal.NamingConventions.NoReservedKeywordParameterNames.stringFound" />
<exclude name="PSR2.Files.EndFileNewline.TooMany" />
<exclude name="Universal.CodeAnalysis.NoEchoSprintf.Found" />
<exclude name="PSR2.Classes.ClassDeclaration.CloseBraceAfterBody" />
<exclude name="Universal.ControlStructures.DisallowLonelyIf.Found" />
<exclude name="Generic.WhiteSpace.IncrementDecrementSpacing.SpaceAfterDecrement" />
<exclude name="Generic.WhiteSpace.IncrementDecrementSpacing.SpaceAfterIncrement" />
<exclude name="Modernize.FunctionCalls.Dirname.FileConstant" />
<exclude name="Universal.NamingConventions.NoReservedKeywordParameterNames.classFound" />
<exclude name="WordPress.WP.DeprecatedFunctions.get_page_by_titleFound" />
<exclude name="Universal.ControlStructures.DisallowLonelyIf.Found" />
<exclude name="Universal.UseStatements.NoLeadingBackslash.LeadingBackslashFound" />
<exclude name="PSR12.Traits.UseDeclaration.MultipleImport" />
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.Found" />
<exclude name="Universal.Operators.DisallowStandalonePostIncrementDecrement.PostIncrementFound" />
<exclude name="Universal.NamingConventions.NoReservedKeywordParameterNames.defaultFound" />
<exclude name="Universal.NamingConventions.NoReservedKeywordParameterNames.interfaceFound" />
<exclude name="WordPress.PHP.IniSet.log_errors_Disallowed" />
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed" />
<exclude name="PSR2.Classes.ClassDeclaration.ExtendsLine" />
<exclude name="PSR2.Classes.ClassDeclaration.ImplementsLine" />
<exclude name="Universal.NamingConventions.NoReservedKeywordParameterNames.functionFound" />
<exclude name="Universal.NamingConventions.NoReservedKeywordParameterNames.parentFound" />
<exclude name="Universal.NamingConventions.NoReservedKeywordParameterNames.returnFound" />
<exclude name="WordPress.WP.AlternativeFunctions.file_system_operations_fopen" />
<exclude name="Universal.Operators.DisallowStandalonePostIncrementDecrement.PostDecrementFound" />
<exclude name="Universal.NamingConventions.NoReservedKeywordParameterNames.objectFound" />
<exclude name="Universal.NamingConventions.NoReservedKeywordParameterNames.callableFound" />
<exclude name="PSR2.Classes.ClassDeclaration.SpaceAfterName" />
<exclude name="PSR2.Classes.ClassDeclaration.SpaceBeforeExtends" />
<exclude name="Universal.NamingConventions.NoReservedKeywordParameterNames.staticFound" />
<exclude name="Universal.CodeAnalysis.StaticInFinalClass.ScopeResolution" />
<exclude name="WordPress.WP.DeprecatedParameters.Wp_count_termsParam2Found" />
<exclude name="WordPress.Security.ValidatedSanitizedInput.InputNotValidated" />
<exclude name="WordPress.PHP.IniSet.display_errors_Disallowed" />
<exclude name="Universal.NamingConventions.NoReservedKeywordParameterNames.matchFound" />
<exclude name="WordPress.Security.NonceVerification.Missing" />
<exclude name="WordPress.Security.EscapeOutput.ExceptionNotEscaped" />
</rule>
<rule ref="WordPress-Docs">
<exclude-pattern>tests/*</exclude-pattern>
</rule>
<rule ref="WordPress-Extra" />
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array">
<element value="amp"/>
<element value="default"/>
</property>
</properties>
</rule>
<rule ref="WordPress-VIP-Go">
<exclude-pattern>tests/*</exclude-pattern>
<exclude-pattern>bin/*</exclude-pattern>
<exclude-pattern>docs/*</exclude-pattern>
<!-- This is not theme code -->
<exclude name="WordPressVIPMinimum.Functions.RestrictedFunctions.flush_rewrite_rules_flush_rewrite_rules" />
<!-- This is not a WordPress.com VIP environment -->
<exclude name="WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get" />
<exclude name="WordPressVIPMinimum.Functions.RestrictedFunctions.get_page_by_path_get_page_by_path" />
<exclude name="WordPressVIPMinimum.Performance.FetchingRemoteData.FileGetContentsUnknown" />
</rule>
<rule ref="WordPress.Files.FileName.InvalidClassFileName">
<exclude-pattern>tests/*</exclude-pattern>
<exclude-pattern>src/*</exclude-pattern>
</rule>
<rule ref="WordPress.WP.GlobalVariablesOverride.Prohibited">
<exclude-pattern>tests/*</exclude-pattern>
</rule>
<rule ref="WordPress.Arrays.MultipleStatementAlignment.LongIndexSpaceBeforeDoubleArrow">
<exclude-pattern>tests/test-tag-and-attribute-sanitizer.php</exclude-pattern>
</rule>
<rule ref="WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned">
<exclude-pattern>tests/test-tag-and-attribute-sanitizer.php</exclude-pattern>
</rule>
<rule ref="WordPress.WP.AlternativeFunctions">
<exclude-pattern>bin/*</exclude-pattern>
</rule>
<rule ref="WordPress.WP.EnqueuedResources">
<exclude-pattern>includes/actions/class-amp-paired-post-actions.php</exclude-pattern>
</rule>
<rule ref="WordPress.Files.FileName.NotHyphenatedLowercase">
<exclude-pattern>src/*</exclude-pattern>
</rule>
<rule ref="WordPress.NamingConventions.ValidVariableName">
<properties>
<property name="allowed_custom_properties" 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="DEFAULT_ARGS"/>
<element value="documentElement"/>
<element value="removeChild"/>
<element value="ownerDocument"/>
<element value="DEFAULT_WIDTH"/>
<element value="DEFAULT_HEIGHT"/>
<element value="ampElements"/>
</property>
</properties>
</rule>
<!-- Prevent false positives for translator comments by adjusting the threshold for commented out code. -->
<rule ref="Squiz.PHP.CommentedOutCode">
<properties>
<property name="maxPercentage" value="50" />
</properties>
</rule>
<!-- Enforce PascalCase file names in src/ only. -->
<rule ref="Squiz.Classes.ClassFileName">
<include-pattern>src/*</include-pattern>
</rule>
<!-- Limit max. consecutive blank lines to 1 instead of 2. -->
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
<properties>
<property name="spacing" value="1"/>
<property name="spacingBeforeFirst" value="1"/>
<property name="spacingAfterLast" value="0"/>
</properties>
</rule>
<!-- Include sniffs for PHP cross-version compatibility. -->
<config name="testVersion" value="7.4-"/>
<rule ref="PHPCompatibilityWP">
<exclude-pattern>bin/*</exclude-pattern>
<exclude-pattern>tests/php/src/PhpStan/*</exclude-pattern>
</rule>
<rule ref="Generic.Arrays.DisallowLongArraySyntax.Found">
<exclude-pattern>amp.php</exclude-pattern>
</rule>
<rule ref="VariableAnalysis.CodeAnalysis.VariableAnalysis">
<exclude-pattern>templates/*</exclude-pattern>
<exclude-pattern>includes/templates/*</exclude-pattern>
<exclude-pattern>back-compat/*</exclude-pattern>
<properties>
<property name="allowUnusedParametersBeforeUsed" value="true"/>
</properties>
</rule>
<arg value="s"/>
<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"/>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern type="relative">^build/*</exclude-pattern>
<exclude-pattern>includes/sanitizers/class-amp-allowed-tags-generated.php</exclude-pattern>
<exclude-pattern>assets/js/*.asset.php</exclude-pattern>
</ruleset>