Skip to content

Commit aa5afe9

Browse files
authored
Merge pull request #2247 from WordPress/feature/add-namespace-declaration-rules
2 parents 3f608b2 + bb89bb9 commit aa5afe9

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

WordPress-Core/ruleset.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,29 @@
412412
<!-- Covered by the Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterReference error code. -->
413413

414414

415+
<!--
416+
#############################################################################
417+
Handbook: Declare Statements, Namespace, and Import Statements - Namespace declarations.
418+
Ref: https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#namespace-declarations
419+
#############################################################################
420+
-->
421+
<!-- Rule: Each part of a namespace name should consist of capitalized words separated by underscores. -->
422+
423+
<!-- Rule: Namespace declarations should have exactly one blank line before the declaration and at least one blank line after. -->
424+
425+
<!-- Covers rule: There should be only one namespace declaration per file... -->
426+
<rule ref="Universal.Namespaces.OneDeclarationPerFile"/>
427+
428+
<!-- Rule: ... and it should be at the top of the file.
429+
Note: with only one namespace declaration, it not being at the top of the file would be a parse error. -->
430+
431+
<!-- Covers rule: Namespace declarations using curly brace syntax are not allowed. -->
432+
<rule ref="Universal.Namespaces.DisallowCurlyBraceSyntax"/>
433+
434+
<!-- Covers rule: Explicit global namespace declaration (namespace declaration without name) are also not allowed. -->
435+
<rule ref="Universal.Namespaces.DisallowDeclarationWithoutName"/>
436+
437+
415438
<!--
416439
#############################################################################
417440
Handbook: Object-Oriented Programming - Only One Object Structure (Class/Interface/Trait) per File.

0 commit comments

Comments
 (0)