Skip to content

Commit 3f8563f

Browse files
committed
Update ruleset for modern (PHP 8+) code
1 parent c628203 commit 3f8563f

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

MO4/ruleset.xml

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
<!-- exclude sniffs that are disabled on purpose by this standard -->
1515
<exclude name="Symfony.Commenting.ClassComment.Missing"/>
1616
<exclude name="Symfony.Commenting.License"/>
17+
<!-- SlevomatCodingStandard.ControlStructures.RequireYodaComparison supports autofixing -->
18+
<exclude name="Symfony.ControlStructure.YodaConditions.Invalid" />
1719
</rule>
1820

1921
<!-- Also include PSR12 -->
@@ -131,8 +133,16 @@
131133
</rule>
132134
<!-- Require usage of ::class instead of __CLASS__, get_class(), get_class($this), get_called_class() and get_parent_class() -->
133135
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/>
136+
<!-- Require use of constructor property promotion -->
137+
<rule ref="SlevomatCodingStandard.Classes.RequireConstructorPropertyPromotion" />
138+
<!-- Forbid static:: in final class -->
139+
<rule ref="SlevomatCodingStandard.Classes.UselessLateStaticBinding" />
140+
<!-- Forbid empty comments-->
141+
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment" />
134142
<!-- report invalid format of inline phpDocs with @var -->
135143
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration"/>
144+
<!-- Forbid useless function doc comments -->
145+
<rule ref="SlevomatCodingStandard.Commenting.UselessFunctionDocComment" />
136146
<!-- Forbid useless @inheritDoc comments -->
137147
<rule ref="SlevomatCodingStandard.Commenting.UselessInheritDocComment"/>
138148
<!-- Forbid assignments in conditions -->
@@ -159,13 +169,21 @@
159169
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/>
160170
<!-- Require usage of null coalesce operator when possible -->
161171
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/>
172+
<!-- Require usage of null coalesce equal operator when possible -->
173+
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator"/>
174+
<!-- Require usage of null safe operator when possible -->
175+
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullSafeObjectOperator"/>
162176
<!-- Require usage of ternary operator when possible -->
163177
<rule ref="SlevomatCodingStandard.ControlStructures.RequireTernaryOperator">
164178
<!-- But multiline is useful for readability -->
165179
<properties>
166180
<property name="ignoreMultiLine" value="true"/>
167181
</properties>
168182
</rule>
183+
<!-- Require Yoda comparisons -->
184+
<rule ref="SlevomatCodingStandard.ControlStructures.RequireYodaComparison"/>
185+
<!-- Formatting of arrow functions -->
186+
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration" />
169187
<!-- Enforce consistent spacing of named arguments -->
170188
<rule ref="SlevomatCodingStandard.Functions.NamedArgumentSpacing"/>
171189
<!-- Require static closures for microoptimization -->
@@ -237,10 +255,10 @@
237255
</properties>
238256
</rule>
239257
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.UselessAnnotation">
240-
<severity>0</severity>
258+
<severity>9</severity>
241259
</rule>
242260
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification">
243-
<severity>0</severity>
261+
<severity>9</severity>
244262
</rule>
245263
<!-- Require return type hints to be declared -->
246264
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
@@ -251,10 +269,18 @@
251269
</properties>
252270
</rule>
253271
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.UselessAnnotation">
254-
<severity>0</severity>
272+
<severity>9</severity>
255273
</rule>
256274
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification">
257-
<severity>0</severity>
275+
<severity>9</severity>
276+
</rule>
277+
<!-- Union type hint formatting -->
278+
<rule ref="SlevomatCodingStandard.TypeHints.UnionTypeHintFormat">
279+
<properties>
280+
<property name="withSpaces" value="yes"/>
281+
<property name="shortNullable" value="yes"/>
282+
<property name="nullPosition" value="last"/>
283+
</properties>
258284
</rule>
259285
<!-- Forbid useless @var for constants -->
260286
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint"/>

0 commit comments

Comments
 (0)