Skip to content

Commit

Permalink
Merge pull request #2132 from WordPress/feature/core-add-type-declara…
Browse files Browse the repository at this point in the history
…tion-formatting-rules

Core: add sniffs to check formatting for type declarations
  • Loading branch information
dingo-d committed Dec 8, 2022
2 parents 2880e5b + cbde80c commit bf4fccd
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions WordPress-Core/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,6 @@
<!-- Rule: In a switch block, there must be no space between the case condition and the colon. -->
<!-- Covered by the PSR2.ControlStructures.SwitchDeclaration sniff. -->

<!-- Rule: Similarly, there should be no space before the colon on return type declarations. -->

<!-- Covers rule: Unless otherwise specified, parentheses should have spaces inside them. -->
<rule ref="Generic.WhiteSpace.ArbitraryParenthesesSpacing">
<properties>
Expand Down Expand Up @@ -343,6 +341,35 @@
https://github.com/WordPress/WordPress-Coding-Standards/issues/1330 -->


<!--
#############################################################################
Handbook: Formatting - Type declarations.
Ref: https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#type-declarations
#############################################################################
-->
<!-- Covers rule: Type declarations must have exactly one space before and after the type. -->
<!-- Covered by the Squiz.Functions.FunctionDeclarationArgumentSpacing sniff. -->

<!-- Covers rule: There should be no space between the nullability operator and the actual type. -->
<rule ref="PSR12.Functions.NullableTypeDeclaration"/>

<!-- Rule: Class/interface/enum name based type declarations should use the case of the
class/interface/enum name as declared... -->
<!-- Not sniffable except for PHP native names and known WP class names (this last part via
the WordPress.WP.ClassNameCase sniff once switched to the (upcoming/future)
PHPCSUtils AbstractClassUseSniff. -->

<!-- Covers rule: ... while the keyword-based type declarations should be lowercased. -->
<!-- Covered by the Generic.PHP.LowerCaseType sniff. -->

<!-- Covers rule: Return type declarations should have no space between the closing parenthesis
of the function declaration and the colon starting a return type. -->
<rule ref="PSR12.Functions.ReturnTypeDeclaration"/>

<!-- Implied through the examples: There should no space around the union or intersection type operators. -->
<rule ref="Universal.Operators.TypeSeparatorSpacing"/>


<!--
#############################################################################
Handbook: Formatting - Spread operator.
Expand Down

0 comments on commit bf4fccd

Please sign in to comment.