no inspection for invalid enum to string comparison

I would expect to get a warning if I compare a backed enum to a string without using ->value

The code below does not complain when using ==. Only with ===.
However, what should it cast to when using == ? In my opinion it this comparison never makes sense and it should therefore highlight it even when just using ==

enum UserType: string {
    CASE ADMIN = 'admin';

function doSomething (UserType $userType) {
    if('someInvalidType' == $userType) {
        echo 'test';

Thanks for bringing our attention to this scenario.

I have submitted a corresponding YouTrack report:

Please feel free to vote & subscribe.


Please sign in to leave a comment.