`@template T of BackedEnum` + `value-of<T>` = BOOM!
Bug report
PHPStan has had little love for templates based on BackedEnum for quite some time. Now the situation has gotten even worse. Current version is 2.1.30, but at least some of the additional weirdness started with 2.1.12.
list<?value-of<T>>, where T is @template T of BackedEnum, becomes list<null> when inside a conditional return type: https://phpstan.org/r/9ce98815-ac5f-4f71-864a-0058503c827c
Nested conditionals complicate things further (this worked in v2.1.11 though): https://phpstan.org/r/b1c23fb5-0342-402a-a1b3-b015eb7913aa
While preparing the two anippts above, I bumped into one more bug. value-of<T>, where T is @template T of BackedEnum, apparently does not even reference T: https://phpstan.org/r/b1c23fb5-0342-402a-a1b3-b015eb7913aa
I don't know whether the root cause here is the same as with #12219, but it sure looks like they're at least in the same zip code.
Code snippet that reproduces the problem
No response
Expected output
There should be no errors reported in the snippets linked above.
Did PHPStan help you today? Did it make you happy in any way?
PHPStan is always helpful. It just seems to suffer from a BackedEnum intolerance. 😬