Error Identifier: sealed.internalEnum
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 Internal\Status;
/**
* @phpstan-sealed Status
*/
interface StatusProvider
{
}
Why is it reported? #
The @phpstan-sealed PHPDoc tag references an enum that is marked as @internal in another package. Internal symbols are not meant to be used outside of their own package, and referencing them in a @phpstan-sealed tag creates a dependency on an implementation detail that could change without notice.
How to fix it #
Reference only public (non-internal) enums in @phpstan-sealed tags, or create your own enum that mirrors the needed values.
<?php declare(strict_types = 1);
namespace App;
-use Internal\Status;
+use App\Enums\Status;
/**
* @phpstan-sealed Status
*/
interface StatusProvider
{
}
How to ignore this error #
You can use the identifier sealed.internalEnum to ignore this error using a comment:
// @phpstan-ignore sealed.internalEnum
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: sealed.internalEnum
Rules that report this error #
- PHPStan\Rules\InternalTag\RestrictedInternalClassNameUsageExtension [1]