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

Handbook: require one blank line before and after a namespace declaration #2305

Open
jrfnl opened this issue Jul 19, 2023 · 0 comments
Open

Comments

@jrfnl
Copy link
Member

jrfnl commented Jul 19, 2023

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.

Ref: https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#namespace-declarations

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 in Extra 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant