website/errors/traitUse.internalInterface.md
<?php declare(strict_types = 1);
namespace Vendor {
/** @internal */
interface InternalInterface {}
}
namespace App {
class MyClass {
use \Vendor\InternalInterface;
}
}
The use statement inside a class body references an interface that is marked as @internal. Internal interfaces are not part of the public API of the package that defines them. They may change or be removed in any version without notice.
Using an interface in a use statement is already incorrect (only traits can be used this way), but the internal access error is also reported because the referenced symbol is internal to another package.
Only traits can be used in a class body use statement. If you need functionality from the library, look for a public trait that provides it:
namespace App {
class MyClass {
- use \Vendor\InternalInterface;
+ use \Vendor\PublicTrait;
}
}
If the interface should be implemented rather than used as a trait, use implements instead:
namespace App {
- class MyClass {
- use \Vendor\InternalInterface;
+ class MyClass implements \Vendor\PublicInterface {
}
}
If the interface is internal to your own project, the error will not be reported when referencing it from within the same root namespace.