The use statement with non-compound name '%s' has no effect

Description

This warning reports a useless use expression. The use expression imports the final name of a fully qualified name to be used in the current file. When applying use to a simple name, without any \ separator, PHP does not import it, as it is already treated as such by default.

Example

<?php

use Some\Space\Functions; // allow Functions to be used in this file
use Closure;              // Closure is already handled that way, no need to import it

function foo(Closure $closure) {}

?>

Solutions

  • Remove the single name use expressions.

  • Fix the imported name to include a namespace, if applicable.

Changed Behavior

This error may appear following an evolution in behavior, in previous versions. See ` <https://php-changed-behaviors.readthedocs.io/en/latest/behavior/.html>`_.