Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: add sniffs to check formatting for type declarations #2132

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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