Error Identifier: interface.nameInUse
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;
use Some\Other\Logger;
interface Logger
{
}
Why is it reported? #
The interface declaration uses a name that is already taken by a use import or another class-like declaration in the same namespace. PHP does not allow two class-like symbols (classes, interfaces, traits, enums) to share the same name in the same scope. This results in a fatal error at runtime.
How to fix it #
Rename the interface to avoid the conflict:
namespace App;
use Some\Other\Logger;
-interface Logger
+interface AppLogger
{
}
Or remove the conflicting use import if it is no longer needed:
namespace App;
-use Some\Other\Logger;
interface Logger
{
}
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]