|
6 | 6 | <arg name="extensions" value="php,inc"/>
|
7 | 7 | <exclude-pattern>*/vendor/*</exclude-pattern>
|
8 | 8 |
|
9 |
| - <!-- ************** --> |
| 9 | + <!-- *************** --> |
10 | 10 | <!-- *** PSR12 *** -->
|
11 |
| - <!-- ************** --> |
| 11 | + <!-- *************** --> |
12 | 12 |
|
13 | 13 | <!-- Include the PSR-12 (so PSR-1) standard without the file length limit -->
|
14 | 14 | <rule ref="PSR12">
|
|
18 | 18 | </rule>
|
19 | 19 | <!-- Instead of PSR12.ControlStructures.ControlStructureSpacing -->
|
20 | 20 | <rule ref="PSR2.ControlStructures.ControlStructureSpacing"/>
|
21 |
| - <!-- Instead of PSR12.Operators.OperatorSpacing--> |
| 21 | + <!-- Instead of PSR12.Operators.OperatorSpacing --> |
22 | 22 | <rule ref="Squiz.WhiteSpace.OperatorSpacing">
|
23 | 23 | <properties>
|
24 | 24 | <property name="ignoreNewlines" value="true"/>
|
25 | 25 | </properties>
|
26 | 26 | </rule>
|
27 |
| - <rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/> |
28 | 27 |
|
29 |
| - <!-- Change warning to error --> |
30 |
| - <rule ref="PSR2.ControlStructures.ElseIfDeclaration.NotAllowed"> |
31 |
| - <type>error</type> |
| 28 | + <!-- Force control structures indentation with 4 spaces --> |
| 29 | + <rule ref="Generic.WhiteSpace.ScopeIndent"> |
| 30 | + <properties> |
| 31 | + <!-- turned off for both comment and phpDoc by PSR2 -> turning back on for phpDoc --> |
| 32 | + <property name="ignoreIndentationTokens" type="array"> |
| 33 | + <element value="T_COMMENT"/> |
| 34 | + </property> |
| 35 | + </properties> |
32 | 36 | </rule>
|
33 | 37 |
|
34 |
| - <!-- Override SuperfluousWhitespace to not ignore blank lines --> |
| 38 | + <!-- Forbid superfluous whitespaces --> |
35 | 39 | <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
|
36 | 40 | <properties>
|
| 41 | + <!-- turned on by PSR2 -> turning back off --> |
37 | 42 | <property name="ignoreBlankLines" value="false"/>
|
38 | 43 | </properties>
|
39 | 44 | </rule>
|
40 | 45 |
|
41 |
| - <!-- Override ScopeIndent to check phpDoc comments indent--> |
42 |
| - <rule ref="Generic.WhiteSpace.ScopeIndent"> |
43 |
| - <properties> |
44 |
| - <property name="ignoreIndentationTokens" type="array"> |
45 |
| - <element value="T_COMMENT"/> |
46 |
| - </property> |
47 |
| - </properties> |
| 46 | + <!-- Disallow else if in favor of elseif --> |
| 47 | + <rule ref="PSR2.ControlStructures.ElseIfDeclaration.NotAllowed"> |
| 48 | + <!-- change warning to error --> |
| 49 | + <type>error</type> |
| 50 | + </rule> |
| 51 | + |
| 52 | + <!-- **************** --> |
| 53 | + <!-- *** CUSTOM *** --> |
| 54 | + <!-- **************** --> |
| 55 | + |
| 56 | + <rule ref="SymfonyCustom.Commenting.FunctionComment"> |
| 57 | + <exclude name="SymfonyCustom.Commenting.FunctionComment.MissingParamComment"/> |
48 | 58 | </rule>
|
49 | 59 |
|
50 | 60 | <!-- ************** -->
|
51 | 61 | <!-- *** MORE *** -->
|
52 | 62 | <!-- ************** -->
|
53 | 63 |
|
54 |
| - <!-- Whitespace --> |
| 64 | + <!-- Forbid `array(...)` --> |
| 65 | + <rule ref="Generic.Arrays.DisallowLongArraySyntax"/> |
| 66 | + <!-- Forbid duplicate classes --> |
| 67 | + <rule ref="Generic.Classes.DuplicateClassName"/> |
| 68 | + <!-- Forbid assignment in condition --> |
| 69 | + <rule ref="Generic.CodeAnalysis.AssignmentInCondition"> |
| 70 | + <type>error</type> |
| 71 | + </rule> |
| 72 | + <!-- Forbid superfluous semi-colon --> |
| 73 | + <rule ref="Generic.CodeAnalysis.EmptyPHPStatement"> |
| 74 | + <type>error</type> |
| 75 | + </rule> |
| 76 | + <!-- Forbid empty statements --> |
| 77 | + <rule ref="Generic.CodeAnalysis.EmptyStatement"> |
| 78 | + <!-- But allow empty catch --> |
| 79 | + <exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedCatch"/> |
| 80 | + </rule> |
| 81 | + <!-- Forbid final methods in final classes --> |
| 82 | + <rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/> |
| 83 | + <!-- Forbid useless empty method overrides --> |
| 84 | + <rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/> |
| 85 | + <!-- Forbid inline HTML in PHP code --> |
| 86 | + <rule ref="Generic.Files.InlineHTML"/> |
| 87 | + <!-- Force whitespace after a type cast --> |
55 | 88 | <rule ref="Generic.Formatting.SpaceAfterCast"/>
|
| 89 | + <!-- Forbid whitespace after `!` --> |
56 | 90 | <rule ref="Generic.Formatting.SpaceAfterNot">
|
57 | 91 | <properties>
|
58 | 92 | <property name="spacing" value="0" />
|
59 | 93 | </properties>
|
60 | 94 | </rule>
|
61 |
| - <rule ref="Generic.WhiteSpace.SpreadOperatorSpacingAfter"/> |
62 |
| - <rule ref="Squiz.Arrays.ArrayBracketSpacing"/> |
63 |
| - <rule ref="Squiz.Strings.ConcatenationSpacing"> |
64 |
| - <properties> |
65 |
| - <property name="ignoreNewlines" value="true" /> |
66 |
| - </properties> |
67 |
| - </rule> |
68 |
| - <rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/> |
69 |
| - <rule ref="Squiz.WhiteSpace.FunctionSpacing"> |
70 |
| - <properties> |
71 |
| - <property name="spacingBeforeFirst" value="0"/> |
72 |
| - <property name="spacing" value="1"/> |
73 |
| - <property name="spacingAfterLast" value="0"/> |
74 |
| - </properties> |
75 |
| - </rule> |
76 |
| - <rule ref="Squiz.WhiteSpace.MemberVarSpacing"> |
| 95 | + <!-- Forbid PHP 4 constructors --> |
| 96 | + <rule ref="Generic.NamingConventions.ConstructorName"/> |
| 97 | + <!-- Forbid any content before opening tag --> |
| 98 | + <rule ref="Generic.PHP.CharacterBeforePHPOpeningTag"/> |
| 99 | + <!-- Forbid deprecated functions --> |
| 100 | + <rule ref="Generic.PHP.DeprecatedFunctions"/> |
| 101 | + <!-- Forbid shorthand PHP open tags `<?=` --> |
| 102 | + <rule ref="Generic.PHP.DisallowShortOpenTag"/> |
| 103 | + <!-- Forbid alias functions, i.e. `sizeof()`, `delete()` --> |
| 104 | + <rule ref="Generic.PHP.ForbiddenFunctions"> |
77 | 105 | <properties>
|
78 |
| - <property name="spacingBeforeFirst" value="0"/> |
| 106 | + <property name="forbiddenFunctions" type="array"> |
| 107 | + <element key="chop" value="rtrim"/> |
| 108 | + <element key="close" value="closedir"/> |
| 109 | + <element key="compact" value="null"/> |
| 110 | + <element key="delete" value="unset"/> |
| 111 | + <element key="doubleval" value="floatval"/> |
| 112 | + <element key="extract" value="null"/> |
| 113 | + <element key="fputs" value="fwrite"/> |
| 114 | + <element key="ini_alter" value="ini_set"/> |
| 115 | + <element key="is_double" value="is_float"/> |
| 116 | + <element key="is_integer" value="is_int"/> |
| 117 | + <element key="is_long" value="is_int"/> |
| 118 | + <element key="is_null" value="null"/> |
| 119 | + <element key="is_real" value="is_float"/> |
| 120 | + <element key="is_writeable" value="is_writable"/> |
| 121 | + <element key="join" value="implode"/> |
| 122 | + <element key="key_exists" value="array_key_exists"/> |
| 123 | + <element key="pos" value="current"/> |
| 124 | + <element key="settype" value="null"/> |
| 125 | + <element key="show_source" value="highlight_file"/> |
| 126 | + <element key="sizeof" value="count"/> |
| 127 | + <element key="strchr" value="strstr"/> |
| 128 | + </property> |
79 | 129 | </properties>
|
80 | 130 | </rule>
|
81 |
| - <rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing"> |
| 131 | + <!-- Forbid useless inline string concatenation --> |
| 132 | + <rule ref="Generic.Strings.UnnecessaryStringConcat"> |
| 133 | + <!-- But multiline is useful for readability --> |
82 | 134 | <properties>
|
83 |
| - <property name="ignoreNewlines" value="true"/> |
| 135 | + <property name="allowMultiline" value="true"/> |
84 | 136 | </properties>
|
85 | 137 | </rule>
|
86 |
| - <rule ref="Squiz.WhiteSpace.SemicolonSpacing"/> |
87 |
| - |
88 |
| - <!-- Disallow --> |
89 |
| - <rule ref="Generic.Arrays.DisallowLongArraySyntax"/> |
90 |
| - <rule ref="Generic.CodeAnalysis.AssignmentInCondition"> |
91 |
| - <type>error</type> |
92 |
| - </rule> |
93 |
| - <rule ref="Generic.CodeAnalysis.EmptyPHPStatement"> |
94 |
| - <type>error</type> |
95 |
| - </rule> |
96 |
| - <rule ref="Generic.CodeAnalysis.EmptyStatement"/> |
| 138 | + <!-- Forbid backtick operator --> |
97 | 139 | <rule ref="Generic.PHP.BacktickOperator"/>
|
98 |
| - <rule ref="Generic.PHP.DisallowShortOpenTag"/> |
99 |
| - <rule ref="Generic.PHP.ForbiddenFunctions"/> |
100 |
| - <rule ref="PEAR.Commenting.InlineComment"/> |
101 |
| - <rule ref="Squiz.PHP.DisallowMultipleAssignments"/> |
102 |
| - <rule ref="Squiz.PHP.DiscouragedFunctions"/> |
103 |
| - <rule ref="Squiz.PHP.Eval"/> |
104 |
| - <rule ref="Squiz.PHP.NonExecutableCode"> |
105 |
| - <type>error</type> |
106 |
| - </rule> |
107 |
| - <rule ref="Squiz.Operators.ValidLogicalOperators"/> |
108 |
| - |
109 |
| - <!-- Others --> |
110 |
| - <rule ref="Generic.Strings.UnnecessaryStringConcat"> |
| 140 | + <!-- Force PHP 7 param and return types to be lowercased --> |
| 141 | + <rule ref="Generic.PHP.LowerCaseType"/> |
| 142 | + <!-- Forbid `php_sapi_name()` function --> |
| 143 | + <rule ref="Generic.PHP.SAPIUsage"/> |
| 144 | + <!-- Require there be no space between increment/decrement operator and its operand --> |
| 145 | + <rule ref="Generic.WhiteSpace.IncrementDecrementSpacing"/> |
| 146 | + <!-- Override ScopeIndent to check phpDoc comments indent--> |
| 147 | + <rule ref="Generic.WhiteSpace.ScopeIndent"> |
111 | 148 | <properties>
|
112 |
| - <property name="allowMultiline" value="true"/> |
| 149 | + <property name="ignoreIndentationTokens" type="array"> |
| 150 | + <element value="T_COMMENT"/> |
| 151 | + </property> |
113 | 152 | </properties>
|
114 | 153 | </rule>
|
| 154 | + <!-- Forbid space after the `...` operator --> |
| 155 | + <rule ref="Generic.WhiteSpace.SpreadOperatorSpacingAfter"/> |
| 156 | + <!-- Forbid comments starting with # --> |
| 157 | + <rule ref="PEAR.Commenting.InlineComment"/> |
| 158 | + <!-- Forbid spaces around square brackets --> |
| 159 | + <rule ref="Squiz.Arrays.ArrayBracketSpacing"/> |
| 160 | + <!-- Forbid class being in a file with different name --> |
115 | 161 | <rule ref="Squiz.Classes.ClassFileName"/>
|
| 162 | + <!-- Force `self::` for self-reference, force lower-case self, forbid spaces around `::` --> |
| 163 | + <rule ref="Squiz.Classes.SelfMemberReference"/> |
| 164 | + <!-- Force phpDoc alignment --> |
116 | 165 | <rule ref="Squiz.Commenting.DocCommentAlignment">
|
| 166 | + <!-- Allow extra spaces after star, i.e. for indented annotations --> |
117 | 167 | <exclude name="Squiz.Commenting.DocCommentAlignment.SpaceAfterStar"/>
|
118 | 168 | </rule>
|
| 169 | + <!-- Require an explanation inside empty catch --> |
119 | 170 | <rule ref="Squiz.Commenting.EmptyCatchComment"/>
|
| 171 | + <!-- Force camelCase variables --> |
120 | 172 | <rule ref="Squiz.NamingConventions.ValidVariableName">
|
121 | 173 | <exclude name="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore"/>
|
122 | 174 | <exclude name="Squiz.NamingConventions.ValidVariableName.ContainsNumbers"/>
|
123 | 175 | </rule>
|
| 176 | + <!-- Forbid `AND` and `OR`, require `&&` and `||` --> |
| 177 | + <rule ref="Squiz.Operators.ValidLogicalOperators"/> |
| 178 | + <!-- Forbid functions inside functions --> |
| 179 | + <rule ref="Squiz.PHP.InnerFunctions"/> |
| 180 | + <!-- Require PHP function calls in lowercase --> |
124 | 181 | <rule ref="Squiz.PHP.LowercasePHPFunctions"/>
|
| 182 | + <!-- Forbid multiple assignments --> |
| 183 | + <rule ref="Squiz.PHP.DisallowMultipleAssignments"/> |
| 184 | + <!-- Forbid dead code --> |
| 185 | + <rule ref="Squiz.PHP.NonExecutableCode"> |
| 186 | + <type>error</type> |
| 187 | + </rule> |
| 188 | + <!-- Forbid `$this` inside static function --> |
| 189 | + <rule ref="Squiz.Scope.StaticThisUsage"/> |
| 190 | + <!-- Require class function to have scope modifiers --> |
125 | 191 | <rule ref="Squiz.Scope.MemberVarScope"/>
|
| 192 | + <!-- Forbid whitespace before and after concatenation --> |
| 193 | + <rule ref="Squiz.Strings.ConcatenationSpacing"> |
| 194 | + <properties> |
| 195 | + <property name="ignoreNewlines" value="true"/> |
| 196 | + </properties> |
| 197 | + </rule> |
| 198 | + <!-- Forbid strings in `"` unless necessary --> |
126 | 199 | <rule ref="Squiz.Strings.DoubleQuoteUsage">
|
127 | 200 | <exclude name="Squiz.Strings.DoubleQuoteUsage.ContainsVar"/>
|
128 | 201 | </rule>
|
| 202 | + <!-- Forbid braces around string in `echo` --> |
129 | 203 | <rule ref="Squiz.Strings.EchoedStrings"/>
|
130 |
| - |
131 |
| - <!-- Custom --> |
132 |
| - <rule ref="SymfonyCustom.Commenting.FunctionComment"> |
133 |
| - <exclude name="SymfonyCustom.Commenting.FunctionComment.MissingParamComment"/> |
| 204 | + <!-- Forbid spaces in type casts --> |
| 205 | + <rule ref="Squiz.WhiteSpace.CastSpacing"/> |
| 206 | + <!-- Forbid blank line after function opening brace --> |
| 207 | + <rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/> |
| 208 | + <!-- Require 1 line before and after function, except at the top and bottom --> |
| 209 | + <rule ref="Squiz.WhiteSpace.FunctionSpacing"> |
| 210 | + <properties> |
| 211 | + <property name="spacingBeforeFirst" value="0"/> |
| 212 | + <property name="spacing" value="1"/> |
| 213 | + <property name="spacingAfterLast" value="0"/> |
| 214 | + </properties> |
| 215 | + </rule> |
| 216 | + <!-- Require space after language constructs --> |
| 217 | + <rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/> |
| 218 | + <!-- Require space around logical operators --> |
| 219 | + <rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/> |
| 220 | + <!-- Require 1 line before and after class properties, except at the top --> |
| 221 | + <rule ref="Squiz.WhiteSpace.MemberVarSpacing"> |
| 222 | + <properties> |
| 223 | + <property name="spacingBeforeFirst" value="0"/> |
| 224 | + </properties> |
134 | 225 | </rule>
|
| 226 | + <!-- Forbid spaces around `->` operator --> |
| 227 | + <rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing"> |
| 228 | + <properties> |
| 229 | + <property name="ignoreNewlines" value="true"/> |
| 230 | + </properties> |
| 231 | + </rule> |
| 232 | + <!-- Forbid spaces before semicolon `;` --> |
| 233 | + <rule ref="Squiz.WhiteSpace.SemicolonSpacing"/> |
135 | 234 | </ruleset>
|
0 commit comments