website/errors/staticMethod.deprecatedEnum.md
<?php declare(strict_types = 1);
/** @deprecated Use NewStatus instead */
enum OldStatus: string
{
case Active = 'active';
public static function getDefault(): self
{
return self::Active;
}
}
OldStatus::getDefault();
This error is reported by the phpstan-deprecation-rules extension.
A static method is being called on an enum that is marked as @deprecated. Deprecated enums are scheduled for removal or replacement. Calling static methods on them ties the code to an API that will eventually be removed.
This error can also be reported when calling a deprecated static method on an enum, regardless of whether the enum itself is deprecated.
Use the recommended replacement enum:
-OldStatus::getDefault();
+NewStatus::getDefault();
If the calling code is itself deprecated, the error will not be reported. Mark the function or class as deprecated if it is part of a deprecation migration:
+/** @deprecated */
function doFoo(): void
{
OldStatus::getDefault();
}