Skip to content

Commit a510c20

Browse files
authored
Merge pull request #2303 from WordPress/feature/core-add-trait-use-rules
2 parents 0734364 + 5c04d9d commit a510c20

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

WordPress-Core/ruleset.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,35 @@
483483
<rule ref="Generic.Files.OneObjectStructurePerFile"/>
484484

485485

486+
<!--
487+
#############################################################################
488+
Handbook: Object-Oriented Programming - Trait Use Statements.
489+
Ref: https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#trait-use-statements
490+
#############################################################################
491+
-->
492+
<!-- Covers rule: Trait use statements should be at the top of a class ... -->
493+
<!-- Covered by the PSR12.Traits.UseDeclaration sniff. -->
494+
495+
<!-- Rule: ... and should have exactly one blank line before the first use statement,
496+
and at least one blank line after the last statement.
497+
The only exception is when the class only contains trait use statements,
498+
in which case the blank line after may be omitted. -->
499+
<!-- Blank line after covered by the PSR12.Traits.UseDeclaration sniff. -->
500+
501+
<!-- Covers rule: (example based rules: spacing, grouping and indentation). -->
502+
<rule ref="PSR12.Traits.UseDeclaration"/>
503+
504+
<!-- Allow for a blank line between the OO statement and the first trait use statement. -->
505+
<rule ref="PSR12.Traits.UseDeclaration.UseAfterBrace">
506+
<severity>0</severity>
507+
</rule>
508+
509+
<!-- Prevent duplicate messages - spacing after use is already covered by `Generic.WhiteSpace.LanguageConstructSpacing`. -->
510+
<rule ref="PSR12.Traits.UseDeclaration.SpaceAfterUse">
511+
<severity>0</severity>
512+
</rule>
513+
514+
486515
<!--
487516
#############################################################################
488517
Handbook: Object-Oriented Programming - Visibility should always be declared.

0 commit comments

Comments
 (0)