|
11 | 11 | <!-- Forbid `array(...)` -->
|
12 | 12 | <rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
|
13 | 13 |
|
| 14 | + <!-- Forbid duplicate classes --> |
| 15 | + <rule ref="Generic.Classes.DuplicateClassName"/> |
| 16 | + |
14 | 17 | <!-- Forbid empty statements -->
|
15 | 18 | <rule ref="Generic.CodeAnalysis.EmptyStatement">
|
16 | 19 | <!-- But allow empty catch -->
|
|
23 | 26 | <!-- Forbid useless empty method overrides -->
|
24 | 27 | <rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
|
25 | 28 |
|
| 29 | + <!-- Forbid inline HTML in PHP code --> |
| 30 | + <rule ref="Generic.Files.InlineHTML"/> |
| 31 | + |
26 | 32 | <rule ref="Generic.Files.LineLength">
|
27 | 33 | <properties>
|
28 | 34 | <property name="lineLimit" value="160"/>
|
|
31 | 37 | </rule>
|
32 | 38 |
|
33 | 39 | <!-- Force whitespace after a type cast -->
|
34 |
| - <rule ref="Generic.Formatting.SpaceAfterCast"/> |
| 40 | + <rule ref="Generic.Formatting.SpaceAfterCast"> |
| 41 | + <properties> |
| 42 | + <property name="spacing" value="1"/> |
| 43 | + </properties> |
| 44 | + </rule> |
35 | 45 |
|
36 | 46 | <!-- Forbid PHP 4 constructors -->
|
37 | 47 | <rule ref="Generic.NamingConventions.ConstructorName"/>
|
|
42 | 52 | <!-- Forbid deprecated functions -->
|
43 | 53 | <rule ref="Generic.PHP.DeprecatedFunctions"/>
|
44 | 54 |
|
| 55 | + <!-- Forbid alias functions, i.e. `sizeof()`, `delete()` --> |
| 56 | + <rule ref="Generic.PHP.ForbiddenFunctions"> |
| 57 | + <properties> |
| 58 | + <property name="forbiddenFunctions" type="array"> |
| 59 | + <element key="chop" value="rtrim"/> |
| 60 | + <element key="close" value="closedir"/> |
| 61 | + <element key="compact" value="null"/> |
| 62 | + <element key="delete" value="unset"/> |
| 63 | + <element key="doubleval" value="floatval"/> |
| 64 | + <element key="extract" value="null"/> |
| 65 | + <element key="fputs" value="fwrite"/> |
| 66 | + <element key="ini_alter" value="ini_set"/> |
| 67 | + <element key="is_double" value="is_float"/> |
| 68 | + <element key="is_integer" value="is_int"/> |
| 69 | + <element key="is_long" value="is_int"/> |
| 70 | + <element key="is_null" value="null"/> |
| 71 | + <element key="is_real" value="is_float"/> |
| 72 | + <element key="is_writeable" value="is_writable"/> |
| 73 | + <element key="join" value="implode"/> |
| 74 | + <element key="key_exists" value="array_key_exists"/> |
| 75 | + <element key="pos" value="current"/> |
| 76 | + <element key="settype" value="null"/> |
| 77 | + <element key="show_source" value="highlight_file"/> |
| 78 | + <element key="sizeof" value="count"/> |
| 79 | + <element key="strchr" value="strstr"/> |
| 80 | + </property> |
| 81 | + </properties> |
| 82 | + </rule> |
| 83 | + |
45 | 84 | <!-- Forbid backtick operator -->
|
46 | 85 | <rule ref="Generic.PHP.BacktickOperator"/>
|
47 | 86 |
|
|
75 | 114 | </properties>
|
76 | 115 | </rule>
|
77 | 116 |
|
| 117 | + <!-- Forbid LSB for constants (static::FOO) --> |
| 118 | + <rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants"/> |
| 119 | + |
| 120 | + <!-- Forbid empty lines around type declarations --> |
| 121 | + <rule ref="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces"> |
| 122 | + <properties> |
| 123 | + <property name="linesCountAfterOpeningBrace" value="0"/> |
| 124 | + <property name="linesCountBeforeClosingBrace" value="0"/> |
| 125 | + </properties> |
| 126 | + </rule> |
| 127 | + |
78 | 128 | <!-- Require usage of ::class instead of __CLASS__, get_class(), get_class($this), get_called_class() and get_parent_class() -->
|
79 | 129 | <rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/>
|
80 | 130 |
|
81 | 131 | <!-- Forbid uses of multiple traits separated by comma -->
|
82 | 132 | <rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration"/>
|
83 | 133 |
|
84 |
| - <!-- Disabling this rule |
| 134 | + <!-- Forbid dead code --> |
| 135 | + <rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements"/> |
| 136 | + |
| 137 | + <!-- Require specific order of phpDoc annotations with empty newline between specific groups --> |
85 | 138 | <rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing">
|
86 | 139 | <properties>
|
87 | 140 | <property name="linesCountBeforeFirstContent" value="0"/>
|
|
98 | 151 | @see,
|
99 | 152 | @uses,
|
100 | 153 | "/>
|
101 |
| - <element value="@param"/> |
102 |
| - <element value="@return"/> |
103 |
| - <element value="@throws"/> |
| 154 | + <element value=" |
| 155 | + @param, |
| 156 | + @return, |
| 157 | + @throws, |
| 158 | + "/> |
104 | 159 | </property>
|
105 | 160 | </properties>
|
106 | 161 | </rule>
|
107 |
| - --> |
108 | 162 |
|
109 | 163 | <!-- Forbid useless annotations - Git and LICENCE file provide more accurate information -->
|
110 | 164 | <rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations">
|
|
127 | 181 | <!-- Forbid empty comments -->
|
128 | 182 | <rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
|
129 | 183 |
|
| 184 | + <!-- Forbid useless comments --> |
| 185 | + <rule ref="SlevomatCodingStandard.Commenting.ForbiddenComments"> |
| 186 | + <properties> |
| 187 | + <property name="forbiddenCommentPatterns" type="array"> |
| 188 | + <element value="~^(?:(?!private|protected|static)\S+ )?(?:con|de)structor\.\z~i"/> |
| 189 | + <element value="~^Created by .+\.\z~i"/> |
| 190 | + <element value="~^(User|Date|Time): \S+\z~i"/> |
| 191 | + <element value="~^\S+ [gs]etter\.\z~i"/> |
| 192 | + <element value="~^Class \S+\z~i"/> |
| 193 | + </property> |
| 194 | + </properties> |
| 195 | + </rule> |
| 196 | + |
130 | 197 | <!-- report invalid format of inline phpDocs with @var -->
|
131 | 198 | <rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration"/>
|
132 | 199 |
|
| 200 | + <!-- Require comments with single line written as one-liners --> |
| 201 | + <rule ref="SlevomatCodingStandard.Commenting.RequireOneLinePropertyDocComment"/> |
| 202 | + |
| 203 | + <!-- Forbid assignments in conditions --> |
| 204 | + <rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/> |
| 205 | + |
| 206 | + <!-- Require consistent spacing for control structures --> |
| 207 | + <rule ref="SlevomatCodingStandard.ControlStructures.ControlStructureSpacing"> |
| 208 | + <properties> |
| 209 | + <property name="tokensToCheck" type="array"> |
| 210 | + <element value="T_RETURN" /> |
| 211 | + </property> |
| 212 | + </properties> |
| 213 | + </rule> |
| 214 | + |
133 | 215 | <!-- Forbid fancy yoda conditions -->
|
134 | 216 | <rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison"/>
|
135 | 217 |
|
|
142 | 224 | <!-- Require usage of null coalesce operator when possible -->
|
143 | 225 | <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/>
|
144 | 226 |
|
| 227 | + <!-- Forbid usage of conditions when a simple return can be used --> |
| 228 | + <rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn"/> |
| 229 | + |
| 230 | + <!-- Forbid usage of boolean-only ternary operator usage (e.g. $foo ? true : false) --> |
| 231 | + <rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator"/> |
| 232 | + |
| 233 | + <!-- Forbid useless unreachable catch blocks --> |
| 234 | + <rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/> |
| 235 | + |
145 | 236 | <!-- Require using Throwable instead of Exception -->
|
146 | 237 | <rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"/>
|
147 | 238 |
|
| 239 | + <!-- Require closures not referencing $this be static --> |
| 240 | + <rule ref="SlevomatCodingStandard.Functions.StaticClosure"/> |
| 241 | + |
| 242 | + <!-- Require trailing comma in multiline calls |
| 243 | + <rule ref="SlevomatCodingStandard.Functions.TrailingCommaInCall"/> |
| 244 | + --> |
| 245 | + |
148 | 246 | <!-- Forbid unused variables passed to closures via `use` -->
|
149 | 247 | <rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/>
|
150 | 248 |
|
|
157 | 255 | <!-- Forbid multiple use statements on same line -->
|
158 | 256 | <rule ref="SlevomatCodingStandard.Namespaces.MultipleUsesPerLine"/>
|
159 | 257 |
|
| 258 | + <!-- Require newlines around namespace declaration --> |
| 259 | + <rule ref="SlevomatCodingStandard.Namespaces.NamespaceSpacing"/> |
| 260 | + |
160 | 261 | <!-- Forbid using absolute class name references (except global ones) -->
|
161 | 262 | <rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly">
|
162 | 263 | <properties>
|
|
172 | 273 | </properties>
|
173 | 274 | </rule>
|
174 | 275 |
|
| 276 | + <!-- Require only one namespace declaration in a file --> |
| 277 | + <rule ref="SlevomatCodingStandard.Namespaces.RequireOneNamespaceInFile"/> |
| 278 | + |
175 | 279 | <!-- Forbid unused use statements -->
|
176 | 280 | <rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
|
177 | 281 | <properties>
|
|
194 | 298 | </properties>
|
195 | 299 | </rule>
|
196 | 300 |
|
| 301 | + <!-- Forbid useless alias for classes, constants and functions --> |
| 302 | + <rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/> |
| 303 | + |
197 | 304 | <!-- Forbid weak comparisons -->
|
198 | 305 | <rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
|
199 | 306 |
|
200 |
| - <!-- Forbid whitespace after the spread operator --> |
| 307 | + <!-- Require the usage of assignment operators, eg `+=`, `.=` when possible --> |
| 308 | + <rule ref="SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator"/> |
| 309 | + |
| 310 | + <!-- Require no spacing after spread operator --> |
201 | 311 | <rule ref="SlevomatCodingStandard.Operators.SpreadOperatorSpacing"/>
|
202 | 312 |
|
| 313 | + <!-- forbid argument unpacking for functions specialized by PHP VM --> |
| 314 | + <rule ref="SlevomatCodingStandard.PHP.OptimizedFunctionsWithoutUnpacking"/> |
| 315 | + |
203 | 316 | <!-- Forbid `list(...)` syntax -->
|
204 | 317 | <rule ref="SlevomatCodingStandard.PHP.ShortList"/>
|
205 | 318 |
|
|
218 | 331 | <!-- Forbid useless parentheses -->
|
219 | 332 | <rule ref="SlevomatCodingStandard.PHP.UselessParentheses"/>
|
220 | 333 |
|
| 334 | + <!-- Forbid useless semicolon `;` --> |
| 335 | + <rule ref="SlevomatCodingStandard.PHP.UselessSemicolon"/> |
| 336 | + |
221 | 337 | <!-- Require use of short versions of scalar types (i.e. int instead of integer) -->
|
222 | 338 | <rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
|
223 | 339 |
|
|
230 | 346 | <!-- Require one space between typehint and variable, require no space between nullability sign and typehint -->
|
231 | 347 | <rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
|
232 | 348 |
|
| 349 | + <!-- Require types to be written as natively if possible; |
| 350 | + require iterable types to specify phpDoc with their content; |
| 351 | + forbid useless/duplicated information in phpDoc --> |
| 352 | + <rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration"> |
| 353 | + <properties> |
| 354 | + <property name="allAnnotationsAreUseful" value="true"/> |
| 355 | + <property name="enableEachParameterAndReturnInspection" value="true"/> |
| 356 | + </properties> |
| 357 | + </rule> |
| 358 | + |
| 359 | + <!-- Forbid useless @var for constants --> |
| 360 | + <rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint"/> |
| 361 | + |
| 362 | + <!-- Forbid duplicated variables assignments --> |
| 363 | + <rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable"/> |
| 364 | + |
| 365 | + <!-- Forbid useless variables --> |
| 366 | + <rule ref="SlevomatCodingStandard.Variables.UselessVariable"/> |
| 367 | + |
233 | 368 | <!-- Forbid spaces around square brackets -->
|
234 | 369 | <rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
|
235 | 370 |
|
|
239 | 374 | <!-- Force `self::` for self-reference, force lower-case self, forbid spaces around `::` -->
|
240 | 375 | <rule ref="Squiz.Classes.SelfMemberReference"/>
|
241 | 376 |
|
| 377 | + <!-- Force rules for function phpDoc --> |
| 378 | + <rule ref="Squiz.Commenting.FunctionComment"> |
| 379 | + <!-- Allow `@throws` without description --> |
| 380 | + <exclude name="Squiz.Commenting.FunctionComment.EmptyThrows"/> |
| 381 | + <!-- Does not work properly with PHP 7 / short-named types --> |
| 382 | + <exclude name="Squiz.Commenting.FunctionComment.IncorrectParamVarName"/> |
| 383 | + <!-- Does not support collections, i.e. `string[]` --> |
| 384 | + <exclude name="Squiz.Commenting.FunctionComment.IncorrectTypeHint"/> |
| 385 | + <!-- Forces incorrect types --> |
| 386 | + <exclude name="Squiz.Commenting.FunctionComment.InvalidReturn"/> |
| 387 | + <!-- Breaks with compound return types, i.e. `string|null` --> |
| 388 | + <exclude name="Squiz.Commenting.FunctionComment.InvalidReturnNotVoid"/> |
| 389 | + <!-- Breaks when all params are not documented --> |
| 390 | + <exclude name="Squiz.Commenting.FunctionComment.InvalidTypeHint"/> |
| 391 | + <!-- Doc comment is not required for every method --> |
| 392 | + <exclude name="Squiz.Commenting.FunctionComment.Missing"/> |
| 393 | + <!-- Do not require comments for `@param` --> |
| 394 | + <exclude name="Squiz.Commenting.FunctionComment.MissingParamComment"/> |
| 395 | + <!-- Do not require `@param` for all parameters --> |
| 396 | + <exclude name="Squiz.Commenting.FunctionComment.MissingParamTag"/> |
| 397 | + <!-- Do not require `@return` for void methods --> |
| 398 | + <exclude name="Squiz.Commenting.FunctionComment.MissingReturn"/> |
| 399 | + <!-- Comments don't have to be sentences --> |
| 400 | + <exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullStop"/> |
| 401 | + <!-- Comments don't have to be sentences --> |
| 402 | + <exclude name="Squiz.Commenting.FunctionComment.ParamCommentNotCapital"/> |
| 403 | + <!-- Breaks when all params are not documented --> |
| 404 | + <exclude name="Squiz.Commenting.FunctionComment.ParamNameNoMatch"/> |
| 405 | + <!-- Doesn't respect inheritance --> |
| 406 | + <exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing"/> |
| 407 | + <!-- `@throws` lines can often be read as a sentence, |
| 408 | + i.e. `@throws RuntimeException if the file could not be written.` --> |
| 409 | + <exclude name="Squiz.Commenting.FunctionComment.ThrowsNotCapital"/> |
| 410 | + <!-- Doesn't work with self as typehint --> |
| 411 | + <exclude name="Squiz.Commenting.FunctionComment.TypeHintMissing"/> |
| 412 | + </rule> |
| 413 | + |
| 414 | + <!-- Forbid global functions --> |
| 415 | + <rule ref="Squiz.Functions.GlobalFunction"/> |
| 416 | + |
242 | 417 | <!-- Forbid `AND` and `OR`, require `&&` and `||` -->
|
243 | 418 | <rule ref="Squiz.Operators.ValidLogicalOperators"/>
|
244 | 419 |
|
245 | 420 | <!-- Forbid `global` -->
|
246 | 421 | <rule ref="Squiz.PHP.GlobalKeyword"/>
|
247 | 422 |
|
| 423 | + <!-- Forbid functions inside functions --> |
| 424 | + <rule ref="Squiz.PHP.InnerFunctions"/> |
| 425 | + |
248 | 426 | <!-- Require PHP function calls in lowercase -->
|
249 | 427 | <rule ref="Squiz.PHP.LowercasePHPFunctions"/>
|
250 | 428 |
|
|
289 | 467 |
|
290 | 468 | <!-- Forbid spaces before semicolon `;` -->
|
291 | 469 | <rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
|
| 470 | + |
| 471 | + <!-- Forbid superfluous whitespaces --> |
| 472 | + <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"> |
| 473 | + <properties> |
| 474 | + <!-- turned on by PSR2 -> turning back off --> |
| 475 | + <property name="ignoreBlankLines" value="false"/> |
| 476 | + </properties> |
| 477 | + </rule> |
| 478 | + |
| 479 | + <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines"> |
| 480 | + <!-- turned off by PSR2 -> turning back on --> |
| 481 | + <severity>5</severity> |
| 482 | + </rule> |
292 | 483 | </ruleset>
|
0 commit comments