From https://www.drupal.org/node/1353118

Classes and interfaces with a backslash \ inside their fully-qualified name (for example: Drupal\simpletest\WebTestBase) must not use their fully-qualified name inside the code. If the namespace differs from the namespace of the current file, put a use statement on the top of the file.

We should implement a sniff for that.

Comments

klausi created an issue. See original summary.

  • klausi committed 40ea335 on 8.x-2.x
    Issue #2676100: Added a sniff for fully qualified class names in code...
klausi’s picture

Status: Active » Needs work

Committed a start for this.

The problem is now that the sniff also catches namespaced functions, which it should not do.

And then we also need a fixer for this to automatically insert use statements.

  • klausi committed 74cd859 on 8.x-2.x
    Issue #2676100: Fully namespaced function calls are allowed
    
klausi’s picture

Fixed namespaced function calls.

Now the fixer implementation remains.

  • klausi committed 35285fd on 8.x-2.x
    Issue #2676100: Added fixer for FullyQualifiedNamespaceSniff"
    
klausi’s picture

Status: Needs work » Fixed

Implemented the fixer.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.