Open
Description
Is your feature request related to a problem?
A sniff should be added to address the following handbook rule:
Namespace declarations should have exactly one blank line before the declaration and at least one blank line after.
Additional context (optional)
From an analysis done of available sniffs:
The "Namespace declarations should have exactly one blank line before the declaration and at least one blank line after" will probably also need a new sniff.
My research shows the following:
- The
PSR2.Namespaces.NamespaceDeclaration
sniff, which is included inExtra
can sort of cover the "after" part, as in: it check for exactly one blank line after, which is close to, but not exactly what we want.- The
PSR12.Files.FileHeader
sniff can check both "before" and "after", but will also, again, check for exactly one blank line.
The problem with that sniff is that it currently is "all or nothing", it does not have modular error codes, so we cannot ignore some other things from that sniff (requires blank line between PHP open tag and file docblock), which makes it problematic to include the sniff.
If upstream PR PSR12/FileHeader: make "SpacingAfter" and "SpacingInside" errorcodes modular squizlabs/PHP_CodeSniffer#2729 would (finally) be merged, we could reconsider adding that sniff though.
Ref: #2247