Error Identifier: typeAlias.deprecatedEnum
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.
This error is reported by phpstan/phpstan-deprecation-rules.
Code example #
<?php declare(strict_types = 1);
/**
* @deprecated Use NewStatus instead
*/
enum OldStatus: string
{
case Active = 'active';
case Inactive = 'inactive';
}
/**
* @phpstan-type StatusAlias OldStatus
*/
class Config
{
}
Why is it reported? #
A type alias defined via @phpstan-type references an enum that is marked as @deprecated. Using deprecated symbols in type aliases propagates the dependency on the deprecated code, making future migration harder.
How to fix it #
Update the type alias to reference the non-deprecated replacement.
<?php declare(strict_types = 1);
/**
- * @phpstan-type StatusAlias OldStatus
+ * @phpstan-type StatusAlias NewStatus
*/
class Config
{
}
How to ignore this error #
You can use the identifier typeAlias.deprecatedEnum to ignore this error using a comment:
// @phpstan-ignore typeAlias.deprecatedEnum
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: typeAlias.deprecatedEnum
Rules that report this error #
- PHPStan\Rules\Deprecations\RestrictedDeprecatedClassNameUsageExtension [1] phpstan/phpstan-deprecation-rules