1.2.1347. Use With Fully Qualified Name

Use statement doesn’t require a fully qualified name.

PHP manual recommends not to use fully qualified name (starting with ) when using the ‘use’ statement : they are “the leading backslash is unnecessary and not recommended, as import names must be fully qualified, and are not processed relative to the current namespace”.

<?php

// Recommended way to write a use statement.
use  A\B\C\D as E;

// No need to use the initial \
use \A\B\C\D as F;

?>

1.2.1347.1. Suggestions

  • Remove the initial in use expressions.

1.2.1347.2. Specs

Short name

Namespaces/UseWithFullyQualifiedNS

Rulesets

All, Analyze, Changed Behavior, Coding conventions, PHP recommendations

Exakat since

0.8.4

PHP Version

All

Severity

Minor

Time To Fix

Slow (1 hour)

Precision

Very high

Available in

Entreprise Edition, Exakat Cloud