psalm icon indicating copy to clipboard operation
psalm copied to clipboard

False UndefinedPropertyFetch with BackedEnum

Open mpesari opened this issue 1 year ago • 1 comments

https://psalm.dev/r/c2491c56ec

mpesari avatar Mar 13 '24 08:03 mpesari

I found these snippets:

https://psalm.dev/r/c2491c56ec
<?php

function toString(BackedEnum|DateTime $x): string {
    if ($x instanceof BackedEnum) {
        return (string)$x->value;
    }
    
    return $x->format(DateTime::ATOM);
}
Psalm output (using commit ef3b018):

ERROR: UndefinedPropertyFetch - 5:24 - Instance property DateTime::$value is not defined

psalm-github-bot[bot] avatar Mar 13 '24 08:03 psalm-github-bot[bot]