You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
False positive: Argument type error when passing backed enum to function expecting UnitEnum or BackedEnum #930
When passing a backed enum to a function that expects a UnitEnum or BackedEnum, PHP Tools reports a type error even though the argument type is valid according to PHP’s type system.
Here, Permissions is a backed enum, so it should be accepted as a valid UnitEnum.
✅ Expected behavior
No warning should be shown when passing a backed enum to a parameter typed as UnitEnum or BackedEnum.
Activity
jakubmisek commentedon Oct 12, 2025
There must be something else,
UnitEnum<->enumdoes not produce any warnings (I used enum Month just for test):Is
Permissionsdefined invendoror in user's code?ahmed-rashad-alnaggar commentedon Oct 13, 2025
After some tweaking, I found where the issue lies.
This is the
Permissionsenum:The issue occurs because the enum implements an interface.
If I remove the interface, it is correctly recognized as a backed enum.
So the problem is that any backed or unit enum implementing an interface is no longer recognized as a backed/unit enum.
jakubmisek commentedon Oct 13, 2025
Thank you for digging the details! That makes sense, we're obviously treating
enumwith an interface incorrectly.Will be fixed