phpstan / phpstan

PHP Static Analysis Tool - discover bugs in your code without running it!
https://phpstan.org/
MIT License
12.72k stars 861 forks source link

Generic type lost from anonymous function return? #11182

Open devnix opened 1 month ago

devnix commented 1 month ago

Bug report

I don't know how to describe it, it looks like the anonymous function is behaving like it returns a mixed value while the type is already known inside.

Code snippet that reproduces the problem

https://phpstan.org/r/008e34f1-bd49-4e44-a6aa-227665e1b56c

Expected output

I would expect at least a list<int>, working example in Psalm: https://psalm.dev/r/3ed0219c4b

Did PHPStan help you today? Did it make you happy in any way?

No response

devnix commented 1 month ago

It might be related to https://github.com/phpstan/phpstan/issues/5508?