|
1 | 1 | <?xml version="1.0" encoding="UTF-8" ?> |
2 | 2 | <ruleset name="Base Coding Standard"> |
3 | 3 |
|
4 | | - <description>Base Coding Standard</description> |
| 4 | + <description>Base Coding Standard - PSR12</description> |
5 | 5 |
|
6 | 6 | <!-- README: http://edorian.github.io/php-coding-standard-generator/#phpcs --> |
7 | 7 |
|
|
11 | 11 | <!-- Exclude Composer vendor directory. --> |
12 | 12 | <exclude-pattern>*/vendor/*</exclude-pattern> |
13 | 13 |
|
| 14 | + |
14 | 15 | <!-- You can hard-code custom php.ini settings into your custom standard. --> |
15 | 16 | <ini name="memory_limit" value="256M"/> |
16 | 17 |
|
| 18 | + |
17 | 19 | <!-- Call with arguments --> |
18 | 20 | <arg name="encoding" value="utf-8"/> |
19 | 21 | <arg name="extensions" value="php"/> |
|
35 | 37 | <severity>0</severity> |
36 | 38 | </rule> |
37 | 39 |
|
| 40 | + |
38 | 41 | <!-- Don't hide tokenizer exceptions --> |
39 | 42 | <rule ref="Internal.Tokenizer.Exception"> |
40 | 43 | <type>error</type> |
41 | 44 | </rule> |
42 | 45 |
|
| 46 | + |
43 | 47 | <!-- Include the whole PSR-2 standard --> |
44 | | - <rule ref="PSR2"> |
| 48 | + <rule ref="PSR12"> |
45 | 49 | <!-- To address at a later point in time. --> |
46 | 50 | <exclude name="Generic.Files.LineLength.TooLong"/> |
47 | 51 |
|
|
58 | 62 |
|
59 | 63 | <rule ref="Squiz.Arrays.ArrayDeclaration"> |
60 | 64 | <exclude name="Squiz.Arrays.ArrayDeclaration.KeySpecified"/> |
| 65 | + <exclude name="Squiz.Arrays.ArrayDeclaration.NoKeySpecified"/> |
61 | 66 | <exclude name="Squiz.Arrays.ArrayDeclaration.ValueNoNewline"/> |
62 | 67 | </rule> |
63 | 68 |
|
|
117 | 122 | <!-- Checks the declaration of the class and its inheritance is correct --> |
118 | 123 | <rule ref="Squiz.Classes.ClassDeclaration"/> |
119 | 124 |
|
120 | | - <!-- All classes keywords should be lowercase --> |
121 | | - <rule ref="Squiz.Classes.LowercaseClassKeywords"/> |
122 | | - |
123 | 125 | <!-- Tests self member references --> |
124 | 126 | <rule ref="Squiz.Classes.SelfMemberReference"/> |
125 | 127 |
|
126 | | - <!-- Test class names are camel-cased properly --> |
127 | | - <rule ref="Squiz.Classes.ValidClassName"/> |
128 | | - |
129 | 128 |
|
130 | 129 | <!-- ============================ --> |
131 | 130 | <!-- === Code Analysis Sniffs === --> |
|
157 | 156 | <!-- ========================= --> |
158 | 157 |
|
159 | 158 | <rule ref="Squiz.Commenting.BlockComment"> |
| 159 | + <exclude name="Squiz.Commenting.BlockComment.HasEmptyLineBefore"/> |
| 160 | + <exclude name="Squiz.Commenting.BlockComment.NoEmptyLineBefore"/> |
160 | 161 | <exclude name="Squiz.Commenting.BlockComment.NoEmptyLineAfter"/> |
161 | 162 | <exclude name="Squiz.Commenting.BlockComment.SingleLine"/> |
162 | 163 | <exclude name="Squiz.Commenting.BlockComment.CloserSameLine"/> |
|
165 | 166 | <exclude name="Squiz.Commenting.BlockComment.NoNewLine"/> |
166 | 167 | <exclude name="Squiz.Commenting.BlockComment.WrongStart"/> |
167 | 168 | </rule> |
| 169 | + |
168 | 170 | <rule ref="Squiz.Commenting.DocCommentAlignment"/> |
169 | 171 | <rule ref="Squiz.Commenting.EmptyCatchComment"/> |
170 | 172 | <rule ref="Squiz.Commenting.LongConditionClosingComment"/> |
|
218 | 220 | <!-- Inline controls (IF, ELSE, FOR, WHILE) must have brackets --> |
219 | 221 | <rule ref="Generic.ControlStructures.InlineControlStructure"/> |
220 | 222 |
|
221 | | - <!-- Ensures that switch statements are defined according to PSR2. --> |
222 | | - <rule ref="PSR2.ControlStructures.SwitchDeclaration"/> |
223 | | - |
224 | 223 | <!-- The keyword elseif SHOULD be used instead of else if so that all control keywords look like single words. --> |
225 | 224 | <rule ref="PSR2.ControlStructures.ElseIfDeclaration"> |
226 | 225 | <type>error</type> |
|
249 | 248 | </properties> |
250 | 249 | </rule> |
251 | 250 |
|
| 251 | + <!-- Force whitespace after `!` --> |
| 252 | + <rule ref="Generic.Formatting.SpaceAfterNot"/> |
| 253 | + |
252 | 254 |
|
253 | 255 | <!-- ======================== --> |
254 | 256 | <!-- === Functions Sniffs === --> |
|
315 | 317 |
|
316 | 318 | <rule ref="Generic.PHP.DisallowShortOpenTag.EchoFound"/> |
317 | 319 |
|
| 320 | + <!-- Forbid global functions --> |
| 321 | + <rule ref="Squiz.Functions.GlobalFunction"/> |
| 322 | + |
| 323 | + <!-- Forbid `global` --> |
| 324 | + <rule ref="Squiz.PHP.GlobalKeyword"/> |
| 325 | + |
318 | 326 | <!-- Discourage unsafe functions --> |
319 | 327 | <rule ref="Generic.PHP.ForbiddenFunctions"> |
320 | 328 | <properties> |
|
326 | 334 | <element key="print" value="echo"/> |
327 | 335 | <element key="is_null" value="null"/> |
328 | 336 | <element key="create_function" value="null"/> |
| 337 | + <element key="dd" value="null"/> |
| 338 | + <element key="show_source" value="highlight_file"/> |
| 339 | + <element key="pos" value="current"/> |
| 340 | + <element key="settype" value="null"/> |
| 341 | + <element key="eval" value="null"/> |
| 342 | + <element key="strchr" value="strstr"/> |
| 343 | + <element key="chop" value="rtrim"/> |
| 344 | + <element key="close" value="closedir"/> |
| 345 | + <element key="compact" value="null"/> |
| 346 | + <element key="delete" value="unset"/> |
| 347 | + <element key="doubleval" value="floatval"/> |
| 348 | + <element key="extract" value="null"/> |
| 349 | + <element key="fputs" value="fwrite"/> |
| 350 | + <element key="ini_alter" value="ini_set"/> |
| 351 | + <element key="is_double" value="is_float"/> |
| 352 | + <element key="is_integer" value="is_int"/> |
| 353 | + <element key="is_long" value="is_int"/> |
| 354 | + <element key="is_null" value="null"/> |
| 355 | + <element key="is_real" value="is_float"/> |
| 356 | + <element key="is_writeable" value="is_writable"/> |
| 357 | + <element key="join" value="implode"/> |
| 358 | + <element key="key_exists" value="array_key_exists"/> |
329 | 359 | </property> |
330 | 360 | </properties> |
331 | 361 | </rule> |
|
343 | 373 | <!-- Ensures all calls to builtin PHP functions are lowercase. --> |
344 | 374 | <rule ref="Squiz.PHP.LowercasePHPFunctions"/> |
345 | 375 |
|
346 | | - <!-- Checks that all PHP types are lowercase. --> |
| 376 | + <!-- Forbid backtick operator --> |
| 377 | + <rule ref="Generic.PHP.BacktickOperator"/> |
| 378 | + |
| 379 | + <!-- Force PHP 7 param and return types to be lowercased --> |
347 | 380 | <rule ref="Generic.PHP.LowerCaseType"/> |
348 | 381 |
|
| 382 | + <!-- Forbid dead code --> |
| 383 | + <rule ref="Squiz.PHP.NonExecutableCode"/> |
| 384 | + |
349 | 385 |
|
350 | 386 | <!-- ==================== --> |
351 | 387 | <!-- === Scope Sniffs === --> |
|
377 | 413 | </properties> |
378 | 414 | </rule> |
379 | 415 |
|
| 416 | + <rule ref="Squiz.Strings.DoubleQuoteUsage"/> |
380 | 417 | <rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar"> |
381 | | - <type>warning</type> |
| 418 | + <message>Variable "%s" not allowed in double quoted string; use sprintf(), vsprintf() or concatenation instead</message> |
382 | 419 | </rule> |
383 | 420 |
|
| 421 | + <!-- Forbid braces around string in `echo` --> |
| 422 | + <rule ref="Squiz.Strings.EchoedStrings"/> |
| 423 | + |
| 424 | + <!-- Forbid blank line after function opening brace --> |
| 425 | + <rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/> |
| 426 | + |
384 | 427 |
|
385 | 428 | <!-- ============================== --> |
386 | 429 | <!-- === Version Control Sniffs === --> |
|
426 | 469 | </properties> |
427 | 470 | </rule> |
428 | 471 |
|
| 472 | + <!-- Require there be no space between increment/decrement operator and its operand --> |
| 473 | + <rule ref="Generic.WhiteSpace.IncrementDecrementSpacing"/> |
| 474 | + |
429 | 475 | <!-- Object operators must be indented 4 spaces if they are the first thing on a line. --> |
430 | 476 | <rule ref="PEAR.WhiteSpace.ObjectOperatorIndent"/> |
431 | 477 |
|
|
472 | 518 | <!-- === Namespace and Use Declarations Sniffs === --> |
473 | 519 | <!-- ============================================= --> |
474 | 520 |
|
475 | | - <!-- There must be one blank line after the namespace declaration. --> |
476 | | - <rule ref="PSR2.Namespaces.NamespaceDeclaration"/> |
477 | | - |
478 | | - <!-- Ensures USE blocks are declared according to PSR2. --> |
479 | | - <rule ref="PSR2.Namespaces.UseDeclaration"/> |
480 | | - |
481 | 521 |
|
482 | 522 | <!-- ======================================== --> |
483 | 523 | <!-- === Classes, Properties, and Methods === --> |
484 | 524 | <!-- ======================================== --> |
485 | | - <rule ref="PSR12.Classes.ClassInstantiation"/> |
486 | 525 |
|
487 | 526 | <!-- Private properties MUST not be prefixed with an underscore --> |
488 | 527 | <rule ref="PSR2.Classes.PropertyDeclaration.Underscore"> |
489 | 528 | <type>error</type> |
490 | 529 | </rule> |
491 | 530 |
|
492 | | - <!-- Only one argument per line in multi-line function calls --> |
493 | | - <rule ref="PEAR.Functions.FunctionCallSignature"> |
494 | | - <properties> |
495 | | - <property name="allowMultipleArguments" value="false"/> |
496 | | - </properties> |
497 | | - </rule> |
498 | | - |
499 | | - <!-- Private methods MUST not be prefixed with an underscore --> |
500 | | - <rule ref="PSR2.Methods.MethodDeclaration.Underscore"> |
501 | | - <type>error</type> |
502 | | - </rule> |
503 | | - |
504 | | - <rule ref="PSR12.Keywords.ShortFormTypeKeywords"/> |
505 | | - |
506 | 531 | </ruleset> |
0 commit comments