-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathphp-standard.xml
More file actions
228 lines (216 loc) · 10 KB
/
php-standard.xml
File metadata and controls
228 lines (216 loc) · 10 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
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="DmitryRechkin">
<description>Coding standard based on PSR-12 with some additions.</description>
<!-- Set PHP version to 7.4 to prevent PHP 8+ type hints (mixed, union types) -->
<config name="php_version" value="70400"/>
<arg name="tab-width" value="4"/>
<!-- Include the whole PSR-12 standard -->
<rule ref="PSR12">
<!-- exclude usage of spaces for indentation-->
<exclude name="Generic.WhiteSpace.DisallowTabIndent"/>
<exclude name="PSR1.Files.SideEffects"/>
<!-- Allow decorative asterisks in file header comments only -->
<exclude name="Squiz.Commenting.DocCommentAlignment"/>
<exclude name="Squiz.Commenting.BlockComment"/>
</rule>
<rule ref="PSR12"/>
<!-- https://github.com/sirbrillig/VariableAnalysis/ -->
<rule ref="VariableAnalysis"/>
<rule ref="VariableAnalysis.CodeAnalysis.VariableAnalysis">
<properties>
<property name="allowUnusedFunctionParameters" value="true"/>
</properties>
</rule>
<!-- Use tabs for indentation-->
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/>
<rule ref="Generic.WhiteSpace.ScopeIndent">
<properties>
<property name="indent" value="4"/>
<property name="tabIndent" value="true"/>
</properties>
</rule>
<!-- Arrays -->
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<rule ref="Generic.Arrays.ArrayIndent"/>
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
<rule ref="Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast"/>
<!-- Allow double quotes only when there is a variable inside -->
<rule ref="Squiz.Strings.DoubleQuoteUsage">
<exclude name="Squiz.Strings.DoubleQuoteUsage.ContainsVar"/>
</rule>
<rule ref="Squiz.WhiteSpace.OperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true" />
<property name="ignoreSpacingBeforeAssignments" value="false" />
</properties>
</rule>
<!-- Slevomat Coding Standards - @see https://github.com/slevomat/coding-standard -->
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses"/>
<rule ref="SlevomatCodingStandard.Exceptions.DisallowNonCapturingCatch"/>
<rule ref="SlevomatCodingStandard.Classes.UselessLateStaticBinding"/>
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch"/>
<rule ref="SlevomatCodingStandard.PHP.DisallowDirectMagicInvokeCall"/>
<rule ref="SlevomatCodingStandard.Functions.UselessParameterDefaultValue"/>
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/>
<rule ref="SlevomatCodingStandard.PHP.OptimizedFunctionsWithoutUnpacking"/>
<rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable"/>
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>
<rule ref="SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement"/>
<!-- Allow multiple constant definitions for better compatibility with older PHP versions -->
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition">
<exclude name="SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition"/>
</rule>
<!-- Allow multiple property definitions for better compatibility with older PHP versions -->
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiPropertyDefinition">
<exclude name="SlevomatCodingStandard.Classes.DisallowMultiPropertyDefinition"/>
</rule>
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration"/>
<rule ref="SlevomatCodingStandard.Files.LineLength">
<properties>
<property name="lineLengthLimit" value="300"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.RequireOneNamespaceInFile"/>
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceDeclaration"/>
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint"/>
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse"/>
<rule ref="SlevomatCodingStandard.Namespaces.MultipleUsesPerLine"/>
<rule ref="SlevomatCodingStandard.Commenting.DeprecatedAnnotationDeclaration"/>
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/>
<!--<rule ref="SlevomatCodingStandard.Variables.UselessVariable"/>-->
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceSpacing"/>
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon"/>
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
<rule ref="SlevomatCodingStandard.Classes.PropertySpacing"/>
<rule ref="SlevomatCodingStandard.Classes.MethodSpacing"/>
<rule ref="SlevomatCodingStandard.Classes.ParentCallSpacing"/>
<rule ref="SlevomatCodingStandard.Classes.ConstantSpacing"/>
<rule ref="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace"/>
<rule ref="SlevomatCodingStandard.Classes.ClassMemberSpacing"/>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing"/>
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing"/>
<rule ref="SlevomatCodingStandard.PHP.ReferenceSpacing"/>
<rule ref="SlevomatCodingStandard.Operators.NegationOperatorSpacing"/>
<rule ref="SlevomatCodingStandard.Operators.SpreadOperatorSpacing"/>
<rule ref="SlevomatCodingStandard.Arrays.DisallowImplicitArrayCreation"/>
<rule ref="SlevomatCodingStandard.Classes.ClassStructure">
<properties>
<property name="groups" type="array">
<element value="uses"/>
<element value="enum cases"/>
<element value="constants"/>
<element value="properties"/>
<element value="static properties"/>
<element value="static constructors"/>
<element value="constructor"/>
<element value="destructor"/>
<element value="magic methods"/>
<element value="all public methods"/>
<element value="all protected methods"/>
<element value="all private methods"/>
</property>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Functions.StrictCall">
</rule>
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators">
</rule>
<!-- Enforce type hints but exclude PHP 8+ types (mixed, union) for PHP 7.4 compatibility -->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint">
<properties>
<property name="enableMixedTypeHint" value="false"/>
<property name="enableUnionTypeHint" value="false"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingAnyTypeHint">
<properties>
<property name="enableMixedTypeHint" value="false"/>
<property name="enableUnionTypeHint" value="false"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint">
<properties>
<property name="enableMixedTypeHint" value="false"/>
<property name="enableUnionTypeHint" value="false"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingAnyTypeHint">
<properties>
<property name="enableMixedTypeHint" value="false"/>
<property name="enableUnionTypeHint" value="false"/>
</properties>
</rule>
<!-- Allow mixed type hints for WordPress compatibility -->
<rule ref="SlevomatCodingStandard.TypeHints.DisallowMixedTypeHint">
<exclude name="SlevomatCodingStandard.TypeHints.DisallowMixedTypeHint"/>
</rule>
<rule ref="SlevomatCodingStandard.Functions.DisallowEmptyFunction">
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly">
<properties>
<property name="allowFullyQualifiedNameForCollidingClasses" value="true"/>
</properties>
</rule>
<!--<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit.EarlyExitNotUsed">
</rule>-->
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit.UselessElseIf"/>
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit.UselessElse">
</rule>
<!--<rule ref="SlevomatCodingStandard.Variables.DisallowSuperGlobalVariable">
</rule>-->
<rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator">
</rule>
<rule ref="SlevomatCodingStandard.Variables.UnusedVariable">
<properties>
<property name="ignoreUnusedValuesWhenOnlyKeysAreUsedInForeach" value="true"/>
</properties>
</rule>
<!--<rule ref="SlevomatCodingStandard.PHP.UselessParentheses">
</rule>-->
<!-- Allow unused parameters for WordPress hook compatibility -->
<rule ref="SlevomatCodingStandard.Functions.UnusedParameter">
<exclude name="SlevomatCodingStandard.Functions.UnusedParameter"/>
</rule>
<rule ref="SlevomatCodingStandard.Functions.FunctionLength">
<properties>
<property name="maxLinesLength" value="250"/>
</properties>
</rule>
<!-- Documenting -->
<rule ref="Squiz.Commenting.FunctionComment">
<properties>
<property name="skipIfInheritdoc" value="true"/>
</properties>
<exclude name="Squiz.Commenting.FunctionComment.IncorrectParamVarName"/> <!-- Can add back in once https://github.com/squizlabs/PHP_CodeSniffer/pull/3139 is fixed -->
<exclude name="Squiz.Commenting.FunctionComment.EmptyThrows"/>
<exclude name="Squiz.Commenting.FunctionComment.SpacingAfterParamType"/>
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullStop"/>
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentNotCapital"/>
<exclude name="Squiz.Commenting.FunctionComment.ThrowsNoFullStop"/>
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment"/>
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturn"/>
</rule>
<rule ref="Generic.Formatting.SpaceAfterNot">
<properties>
<property name="spacing" value="0" />
</properties>
</rule>
<rule ref="Generic.Files.LineLength">
<exclude-pattern>*/templates/*</exclude-pattern>
<properties>
<property name="lineLimit" value="150"/>
</properties>
</rule>
<!-- exclude minified files -->
<!-- The following rule excludes more files than expected -->
<!--<exclude-pattern>*.min.*</exclude-pattern>-->
<!-- Exclude JavaScript and CSS files - use ESLint/Stylelint instead -->
<exclude-pattern>*.js</exclude-pattern>
<exclude-pattern>*.min.js</exclude-pattern>
<exclude-pattern>*.css</exclude-pattern>
<exclude-pattern>*.min.css</exclude-pattern>
</ruleset>