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

PSR2.Namespaces.NamespaceDeclaration does not handle namespaces defined over multiple lines #2095

Closed
niconoe- opened this issue Jul 17, 2018 · 3 comments
Milestone

Comments

@niconoe-
Copy link

Hi guys,

In the PSR-2 (and so the incomming PSR-12), it is said that it should have a blank line after the namespace declaration.

For very long namespaces (line will get over 120 chars), the Sniff bugs as it declares the following invalid while it actually is:

<?php

namespace My\Very\Ultra\SuperLongNamespace\That\Get\Over\OneHundredAndTwenty\Characters\EvenIf\This\Is\Actually\Not
    \Good;

use External\A;
use External\B;

//...

What is required by the sniff is to do this:

<?php

namespace My\Very\Ultra\SuperLongNamespace\That\Get\Over\OneHundredAndTwenty\Characters\EvenIf\This\Is\Actually\Not
    
    \Good;

use External\A;
use External\B;

//...

Giving a useless blank line between the keyword "namespace" and the final ";" ending the statement.

Is it possible to fix that?
And please, don't tell me to reconsider my architecture so my namespaces must be shorter, I know that, but I can't do it right now and it must not give style issue to have long names ;).

Thanks a lot.

@gsherwood
Copy link
Member

gsherwood commented Jul 18, 2018

Looks like a bug to me, presumably because the sniff never considered that a namespace would be split over multiple lines.

@gsherwood gsherwood added this to the 3.3.1 milestone Jul 18, 2018
@gsherwood gsherwood changed the title PSR-2: unhandled too long namespaces PSR2.Namespaces.NamespaceDeclaration does not handle namespaces defined over multiple lines Jul 18, 2018
gsherwood added a commit that referenced this issue Jul 18, 2018
…e namespaces defined over multiple lines
@gsherwood
Copy link
Member

Thanks for the bug report. This has been fixed and will be released in 3.3.1

@niconoe-
Copy link
Author

Wow, thank you so much for this very fast fix!
Have a nice day

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

2 participants