website/errors/return.deprecatedEnum.md
This error is reported by phpstan/phpstan-deprecation-rules.
<?php declare(strict_types = 1);
/** @deprecated Use NewStatus instead */
enum OldStatus
{
case Active;
case Inactive;
}
function getStatus(): OldStatus
{
return OldStatus::Active;
}
The native return type declaration of a function or method references an enum that has been marked as deprecated. Using a deprecated enum in a return type means that callers will receive a type that is scheduled for removal, which will require changes in the future.
Update the return type to use the non-deprecated replacement:
<?php declare(strict_types = 1);
-function getStatus(): OldStatus
+function getStatus(): NewStatus
{
- return OldStatus::Active;
+ return NewStatus::Active;
}