Skip to content

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

Closed
@niconoe-

Description

@niconoe-

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions