|
22 | 22 | <exclude name="PSR1.Files.SideEffects.FoundWithSymbols"/> |
23 | 23 | </rule> |
24 | 24 | <rule ref="PSR1.Classes.ClassDeclaration"/> |
25 | | - <rule ref="PSR1.Methods.CamelCapsMethodName"/> |
| 25 | + <rule ref="PSR1.Methods.CamelCapsMethodName"> |
| 26 | + <!-- PHP-CS-Fixer's php_unit_method_casing renames test methods to snake_case --> |
| 27 | + <exclude-pattern>*/tests/*</exclude-pattern> |
| 28 | + </rule> |
26 | 29 |
|
27 | 30 | <!-- Generic ruleset: --> |
28 | 31 | <!-- Forbid duplicate classes --> |
|
32 | 35 | <!-- But allow empty catch --> |
33 | 36 | <exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedCatch"/> |
34 | 37 | </rule> |
35 | | - <!-- Warn about variable assignments inside conditions --> |
36 | | - <rule ref="Generic.CodeAnalysis.AssignmentInCondition"/> |
37 | 38 | <!-- Forbid useless empty method overrides --> |
38 | 39 | <rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/> |
39 | 40 | <!-- Detects the usage of one and the same incrementer into an outer and an inner --> |
|
48 | 49 | <property name="ignoreComments" value="true"/> |
49 | 50 | </properties> |
50 | 51 | </rule> |
51 | | - <!-- Ensure there is a single class/interface/trait per file --> |
52 | | - <rule ref="Generic.Files.OneObjectStructurePerFile"/> |
53 | | - <!-- |
54 | | - <rule ref="Generic.Formatting.SpaceAfterNot"/><!– Force whitespace after `!` –> |
55 | | - --> |
56 | 52 | <!-- Checks how many level deep that code is nested within a function. --> |
57 | 53 | <rule ref="Generic.Metrics.NestingLevel"> |
58 | 54 | <properties> |
|
69 | 65 | <rule ref="Generic.PHP.CharacterBeforePHPOpeningTag"/> |
70 | 66 | <!-- Forbid deprecated functions --> |
71 | 67 | <rule ref="Generic.PHP.DeprecatedFunctions"/> |
72 | | - <!-- Array values are specified by using a string representation of the array. --> |
| 68 | + <!-- |
| 69 | + Only functions PHP-CS-Fixer cannot handle are listed here. |
| 70 | + Aliases (join, sizeof, chop, …) are fixed by no_alias_functions, |
| 71 | + intval/boolval/… by modernize_types_casting, rand/mt_rand by random_api_migration, |
| 72 | + print by no_mixed_echo_print, is_null by the is_null fixer. |
| 73 | + --> |
73 | 74 | <rule ref="Generic.PHP.ForbiddenFunctions"> |
74 | 75 | <properties> |
75 | 76 | <property name="forbiddenFunctions" type="array"> |
76 | 77 | <element key="array_push" value="null"/> |
77 | | - <element key="chop" value="rtrim"/> |
78 | | - <element key="close" value="closedir"/> |
79 | | - <element key="create_function" value="null"/> |
80 | 78 | <!-- See https://youtu.be/8rdTSYljts4?t=2932 --> |
81 | 79 | <element key="extract" value="null"/> |
82 | 80 | <element key="compact" value="null"/> |
83 | | - <element key="delete" value="unset"/> |
84 | | - <element key="doubleval" value="floatval"/> |
85 | | - <element key="fputs" value="fwrite"/> |
86 | | - <element key="ini_alter" value="ini_alter"/> |
87 | | - <element key="is_double" value="is_float"/> |
88 | | - <element key="is_integer" value="is_int"/> |
89 | | - <element key="is_long" value="is_int"/> |
90 | | - <element key="is_null" value="null"/> |
91 | | - <element key="is_real" value="is_float"/> |
92 | | - <element key="is_writeable" value="is_writable"/> |
93 | | - <element key="join" value="implode"/> |
94 | | - <element key="key_exists" value="array_key_exists"/> |
95 | | - <element key="pos" value="current"/> |
96 | | - <element key="print" value="echo"/> |
97 | | - <element key="show_source" value="highlight_file"/> |
98 | | - <element key="sizeof" value="count"/> |
99 | | - <element key="strchr" value="strstr"/> |
100 | 81 | <element key="die" value="null"/> |
101 | 82 | <element key="exit" value="null"/> |
102 | 83 | <element key="env" value="config"/> |
103 | | - <element key="intval" value="(int)"/> |
104 | | - <element key="floatval" value="(float)"/> |
105 | | - <element key="doubleval" value="(float)"/> |
106 | | - <element key="boolval" value="(bool)"/> |
107 | | - <element key="strval" value="(string)"/> |
108 | | - <element key="mt_rand" value="random_int"/> |
109 | | - <element key="rand" value="random_int"/> |
110 | 84 | <element key="var_dump" value="null"/> |
111 | 85 | </property> |
112 | 86 | </properties> |
113 | 87 | <!-- Added to ignore env() in config files, it's better to remove it and use env() in a separate rule. --> |
114 | 88 | <exclude-pattern>.config/*</exclude-pattern> |
115 | 89 | </rule> |
116 | | - <rule ref="Generic.Strings.UnnecessaryStringConcat"> |
117 | | - <!-- But multiline is useful for readability --> |
118 | | - <properties> |
119 | | - <property name="allowMultiline" value="true"/> |
120 | | - </properties> |
121 | | - </rule> |
122 | 90 | <!-- Detects merge conflict artifacts left in files --> |
123 | 91 | <rule ref="Generic.VersionControl.GitMergeConflict"/> |
124 | 92 | <!-- Generic ruleset end. --> |
|
128 | 96 | <!-- Array must have keys specified for either all or none of the values. --> |
129 | 97 | <rule ref="SlevomatCodingStandard.Arrays.DisallowPartiallyKeyed"/> |
130 | 98 | <rule ref="SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement"/> |
131 | | - <rule ref="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace"/> |
132 | 99 | <rule ref="SlevomatCodingStandard.Attributes.AttributeAndTargetSpacing"> |
133 | 100 | <!-- For code like private function processUser(Member $member, #[\SensitiveParameter] string $password): void --> |
134 | 101 | <exclude name="SlevomatCodingStandard.Attributes.AttributeAndTargetSpacing.IncorrectLinesCountBetweenAttributeAndTarget"/> |
|
137 | 104 | <rule ref="SlevomatCodingStandard.Attributes.DisallowMultipleAttributesPerLine"/> |
138 | 105 | <rule ref="SlevomatCodingStandard.Attributes.RequireAttributeAfterDocComment"/> |
139 | 106 | <rule ref="SlevomatCodingStandard.Classes.BackedEnumTypeSpacing"/> |
140 | | - <rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility"/> |
141 | 107 | <rule ref="SlevomatCodingStandard.Classes.ClassLength"/> |
142 | 108 | <rule ref="SlevomatCodingStandard.Classes.ClassMemberSpacing"/> |
143 | 109 | <rule ref="SlevomatCodingStandard.Classes.ConstantSpacing"/> |
|
149 | 115 | <rule ref="SlevomatCodingStandard.Classes.ParentCallSpacing"/> |
150 | 116 | <rule ref="SlevomatCodingStandard.Classes.PropertyDeclaration"/> |
151 | 117 | <rule ref="SlevomatCodingStandard.Classes.PropertySpacing"/> |
152 | | - <rule ref="SlevomatCodingStandard.Classes.RequireAbstractOrFinal"/> |
153 | 118 | <rule ref="SlevomatCodingStandard.Classes.RequireMultiLineMethodSignature"/> |
154 | | - <rule ref="SlevomatCodingStandard.Classes.RequireSelfReference"/> |
155 | 119 | <rule ref="SlevomatCodingStandard.Classes.RequireSingleLineMethodSignature"/> |
156 | 120 | <rule ref="SlevomatCodingStandard.Classes.SuperfluousErrorNaming"/> |
157 | 121 | <rule ref="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming"/> |
158 | 122 | <rule ref="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming"/> |
159 | 123 | <rule ref="SlevomatCodingStandard.Classes.SuperfluousTraitNaming"/> |
160 | | - <rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration"/> |
161 | 124 | <rule ref="SlevomatCodingStandard.Classes.TraitUseSpacing"> |
162 | 125 | <properties> |
163 | 126 | <property name="linesCountBeforeFirstUse" value="0"/> |
|
172 | 135 | <property name="linesCountBetweenAnnotationsGroups" value="0"/> |
173 | 136 | </properties> |
174 | 137 | </rule> |
175 | | - <rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations"/> |
176 | 138 | <rule ref="SlevomatCodingStandard.Commenting.ForbiddenComments"> |
177 | 139 | <properties> |
178 | 140 | <property name="forbiddenCommentPatterns" type="array"> |
|
189 | 151 | <exclude name="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration.MissingVariable"/> |
190 | 152 | <include-pattern>routes/</include-pattern> |
191 | 153 | </rule> |
| 154 | + <!-- Allow cognitive complexity up to 10, report anything above --> |
192 | 155 | <rule ref="SlevomatCodingStandard.Complexity.Cognitive"> |
193 | 156 | <properties> |
194 | | - <property name="maxComplexity" value="10"/> |
| 157 | + <property name="warningThreshold" value="11"/> |
| 158 | + <property name="errorThreshold" value="11"/> |
195 | 159 | </properties> |
196 | 160 | </rule> |
197 | 161 | <rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/> |
|
200 | 164 | </rule> |
201 | 165 | <rule ref="SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch"/> |
202 | 166 | <rule ref="SlevomatCodingStandard.ControlStructures.DisallowTrailingMultiLineTernaryOperator"/> |
203 | | - <rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses"/> |
204 | 167 | <rule ref="SlevomatCodingStandard.ControlStructures.RequireMultiLineCondition"/> |
205 | 168 | <rule ref="SlevomatCodingStandard.ControlStructures.RequireMultiLineTernaryOperator"> |
206 | 169 | <properties> |
207 | 170 | <property name="lineLengthLimit" value="120"/> |
208 | 171 | </properties> |
209 | 172 | </rule> |
210 | 173 | <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullSafeObjectOperator"/> |
211 | | - <rule ref="SlevomatCodingStandard.ControlStructures.RequireShortTernaryOperator"/> |
212 | 174 | <rule ref="SlevomatCodingStandard.ControlStructures.RequireSingleLineCondition"/> |
213 | 175 | <rule ref="SlevomatCodingStandard.ControlStructures.RequireTernaryOperator"/> |
214 | 176 | <rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn"/> |
|
217 | 179 | <rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"/> |
218 | 180 | <rule ref="SlevomatCodingStandard.Exceptions.RequireNonCapturingCatch"/> |
219 | 181 | <rule ref="SlevomatCodingStandard.Files.FileLength"/> |
220 | | - <rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration"> |
221 | | - <properties> |
222 | | - <property name="spacesCountAfterKeyword" value="0"/> |
223 | | - </properties> |
224 | | - </rule> |
225 | 182 | <rule ref="SlevomatCodingStandard.Functions.DisallowEmptyFunction"/> |
226 | 183 | <rule ref="SlevomatCodingStandard.Functions.DisallowTrailingCommaInCall"/> |
227 | 184 | <rule ref="SlevomatCodingStandard.Functions.DisallowTrailingCommaInClosureUse"> |
|
244 | 201 | </properties> |
245 | 202 | </rule> |
246 | 203 | <rule ref="SlevomatCodingStandard.Functions.RequireSingleLineCall"/> |
247 | | - <rule ref="SlevomatCodingStandard.Functions.StaticClosure"/> |
248 | | - <rule ref="SlevomatCodingStandard.Functions.StrictCall"/> |
249 | 204 | <rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/> |
250 | | - <rule ref="SlevomatCodingStandard.Functions.UselessParameterDefaultValue"/> |
251 | 205 | <rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse"/> |
252 | 206 | <rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation"> |
253 | 207 | <properties> |
|
256 | 210 | </property> |
257 | 211 | </properties> |
258 | 212 | </rule> |
259 | | - <rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalConstants"/> |
260 | 213 | <rule ref="SlevomatCodingStandard.Namespaces.NamespaceDeclaration"/> |
261 | | - <rule ref="SlevomatCodingStandard.Namespaces.NamespaceSpacing"/> |
262 | 214 | <rule ref="SlevomatCodingStandard.Namespaces.RequireOneNamespaceInFile"/> |
263 | | - <rule ref="SlevomatCodingStandard.Namespaces.UnusedUses"> |
264 | | - <properties> |
265 | | - <property name="searchAnnotations" value="true"/> |
266 | | - </properties> |
267 | | - <severity>6</severity> |
268 | | - </rule> |
269 | 215 | <rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/> |
270 | | - <rule ref="SlevomatCodingStandard.Namespaces.UseSpacing"> |
271 | | - <properties> |
272 | | - <property name="linesCountBetweenUseTypes" value="1"/> |
273 | | - </properties> |
274 | | - </rule> |
275 | | - <rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/> |
276 | 216 | <rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/> |
277 | 217 | <rule ref="SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator"/> |
278 | 218 | <rule ref="SlevomatCodingStandard.Operators.RequireOnlyStandaloneIncrementAndDecrementOperators"/> |
|
287 | 227 | <rule ref="SlevomatCodingStandard.PHP.ForbiddenClasses"/> |
288 | 228 | <rule ref="SlevomatCodingStandard.PHP.OptimizedFunctionsWithoutUnpacking"/> |
289 | 229 | <rule ref="SlevomatCodingStandard.PHP.ReferenceSpacing"/> |
290 | | - <rule ref="SlevomatCodingStandard.PHP.RequireNowdoc"/> |
291 | | - <rule ref="SlevomatCodingStandard.Strings.DisallowVariableParsing"/> |
292 | 230 | <rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes"> |
293 | 231 | <properties> |
294 | 232 | <property name="declareOnFirstLine" value="true"/> |
|
297 | 235 | </rule> |
298 | 236 | <rule ref="SlevomatCodingStandard.TypeHints.DisallowMixedTypeHint"/> |
299 | 237 | <rule ref="SlevomatCodingStandard.TypeHints.DNFTypeHintFormat"/> |
300 | | - <rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/> |
301 | | - <rule ref="SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition"/> |
302 | 238 | <rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint"> |
303 | 239 | <!-- Native type hints may break inheritance --> |
304 | 240 | <exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint"/> |
|
362 | 298 | <!-- Squiz ruleset: --> |
363 | 299 | <!-- Checks for empty catch clause without a comment. --> |
364 | 300 | <rule ref="Squiz.Commenting.EmptyCatchComment"/> |
365 | | - <!-- Force phpDoc alignment --> |
366 | | - <rule ref="Squiz.Commenting.DocCommentAlignment"> |
367 | | - <!-- Allow extra spaces after star, i.e. for indented annotations --> |
368 | | - <exclude name="Squiz.Commenting.DocCommentAlignment.SpaceAfterStar"/> |
369 | | - </rule> |
370 | 301 | <!-- Force rules for function PHPDoc --> |
371 | 302 | <rule ref="Squiz.Commenting.FunctionComment"> |
372 | 303 | <!-- Allow `@throws` without description --> |
|
406 | 337 | <!-- It is too strict - we are more flexible --> |
407 | 338 | <exclude name="Squiz.Commenting.FunctionComment.ThrowsNoFullStop"/> |
408 | 339 | </rule> |
409 | | - <!-- Forbid class being in a file with different name --> |
410 | | - <rule ref="Squiz.Classes.ClassFileName"/> |
411 | | - <!-- Forbid `AND` and `OR`, require `&&` and `||` --> |
412 | | - <rule ref="Squiz.Operators.ValidLogicalOperators"/> |
413 | 340 | <!-- Force camelCase variables --> |
414 | 341 | <rule ref="Squiz.NamingConventions.ValidVariableName"> |
415 | 342 | <!-- Eloquent attributes --> |
|
418 | 345 | </rule> |
419 | 346 | <!-- Forbid `global` --> |
420 | 347 | <rule ref="Squiz.PHP.GlobalKeyword"/> |
421 | | - <!-- Require PHP function calls in lowercase --> |
422 | | - <rule ref="Squiz.PHP.LowercasePHPFunctions"/> |
423 | 348 | <!-- Discourages the use of debug functions. --> |
424 | 349 | <rule ref="Squiz.PHP.DiscouragedFunctions"/> |
425 | 350 | <!-- Warns about code that can never been executed. --> |
426 | 351 | <rule ref="Squiz.PHP.NonExecutableCode"/> |
427 | | - <!-- Verifies that class members have scope modifiers. --> |
428 | | - <rule ref="Squiz.Scope.MemberVarScope"/> |
429 | 352 | <!-- Checks for usage of $this in static methods, which will cause runtime errors. --> |
430 | 353 | <rule ref="Squiz.Scope.StaticThisUsage"/> |
431 | | - <!-- Use singular quotes by default --> |
432 | | - <rule ref="Squiz.Strings.DoubleQuoteUsage.NotRequired"/> |
433 | | - <!-- Forbid braces around string in `echo` --> |
434 | | - <rule ref="Squiz.Strings.EchoedStrings"/> |
435 | 354 | <!-- Squiz ruleset end. --> |
436 | 355 |
|
437 | 356 | <!--IxDFCodingStandard custom rules: --> |
|
0 commit comments