Menu

Error Identifier: use.nameInUse

← Back to use.*

Every error reported by PHPStan has an error identifier. Here’s a list of all error identifiers. In PHPStan Pro you can see the error identifier next to each error and filter errors by their identifiers.

Code example #

<?php declare(strict_types = 1);

namespace App;

class Foo
{
}

use SomeOtherNamespace\Foo;

Why is it reported? #

A use import introduces a name that is already taken by another declaration in the same namespace scope. In the example, the class Foo is declared in the App namespace, and then a use statement tries to import SomeOtherNamespace\Foo as Foo. This creates a naming conflict that PHP cannot resolve.

This is a PHP compile-time error – having two definitions for the same name in the same scope is not allowed.

How to fix it #

Use an alias for the imported name to avoid the conflict:

 <?php declare(strict_types = 1);
 
 namespace App;

 class Foo
 {
 }

-use SomeOtherNamespace\Foo;
+use SomeOtherNamespace\Foo as OtherFoo;

Or remove the conflicting use statement if it is not needed:

 <?php declare(strict_types = 1);
 
 namespace App;

 class Foo
 {
 }
-
-use SomeOtherNamespace\Foo;

Non-ignorable error #

This error cannot be ignored using @phpstan-ignore or the ignoreErrors configuration. Non-ignorable errors indicate code that would cause a crash or a fatal error at runtime, or a fundamental problem in the analysed code that must be addressed.

Rules that report this error #

  • PHPStan\Rules\Names\UsedNamesRule [1]
Theme
A
© 2026 PHPStan s.r.o.