Error Identifier: enum.implementsInternalInterface
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);
// In package vendor/some-library:
// /** @internal */
// interface InternalInterface {}
enum Status implements \SomeLibrary\InternalInterface
{
case Active;
case Inactive;
}
Why is it reported? #
The enum implements an interface that is marked as @internal by its declaring package. Internal interfaces are not meant to be used outside of the package that defines them. The library author may change or remove the interface without considering it a breaking change.
How to fix it #
Stop implementing the internal interface and use a public interface provided by the library instead:
-enum Status implements \SomeLibrary\InternalInterface
+enum Status implements \SomeLibrary\PublicInterface
{
case Active;
case Inactive;
}
If no suitable public interface exists, contact the library maintainers to request one.
How to ignore this error #
You can use the identifier enum.implementsInternalInterface to ignore this error using a comment:
// @phpstan-ignore enum.implementsInternalInterface
codeThatProducesTheError();
You can also use only the identifier key to ignore all errors of the same type in your configuration file in the ignoreErrors parameter:
parameters:
ignoreErrors:
-
identifier: enum.implementsInternalInterface
Rules that report this error #
- PHPStan\Rules\InternalTag\RestrictedInternalClassNameUsageExtension [1]