Skip to content

Latest commit

 

History

History
44 lines (26 loc) · 827 Bytes

no-unresolved-use.md

File metadata and controls

44 lines (26 loc) · 827 Bytes

No Unresolved Use Statement

use statements provide the ability to refer to an external fully qualified name. Since it will be used to locate definitions in other namespaces and/or files, it is important to check the validity of the fully qualified name.

<?php

namespace X;

use AnotherNamespace\Aclass;
use AnotherNamespace\Subnamespace;

$a = new Aclass();

?>

PHP will not check the validity of use at compile time, but at execution time. It will then raise a fatal error.

It is recommended to make sure that use statement are always pointing to an existing definition.

Rule Details

The following patterns are considered warnings:

<?php

namespace X;

use AnotherNamespace\UndefinedClass;

?>