SanderRonde / phpstan-vscode

PHPStan plugin for VSCode
https://marketplace.visualstudio.com/items?itemName=SanderRonde.phpstan-vscode
MIT License
47 stars 8 forks source link

Some problems are not reported when `showTypeOnHover` is enabled #109

Closed lkrms closed 2 weeks ago

lkrms commented 2 weeks ago

I have a problem reported by PHPStan only when I run it on the command line--or when I disable showTypeOnHover.

It seems the extension's TreeFetcher somehow changes PHPStan's type inferences in some circumstances--perhaps only when bleeding edge is enabled? (I'm seeing the behaviour after moving to PHPStan 1.12.10 and enabling bleeding edge; it's not clear which was the trigger.)

The difference I'm observing is that PHPStan thinks a string is non-empty normally, but with TreeFetcher in the mix, the non-empty flag is removed. Ironically, the latter behaviour is correct, but that's beside the point ;)

SanderRonde commented 2 weeks ago

Well that's really strange. I can't say that I have a clue what's causing this, maybe a PHPStan-internal bug? Will keep this issue open for a while to see if anybody else is experiencing the same issue but chances are I won't figure it out. Do you maybe have an example repo for it happening? That would help a bunch :)

lkrms commented 2 weeks ago

If you check out this tag: https://github.com/salient-labs/toolkit/releases/tag/v0.99.62

And run composer install, you should get No error with identifier identical.alwaysFalse is reported on line 209 for src/Toolkit/Http/FormData.php, which you won't get when running phpstan directly.

Hopefully it doesn't make a liar of me 😜

Edit: just confirmed it happens on both platforms I use (macOS and Linux). Phew.

SanderRonde commented 2 weeks ago

First of all thanks for the repo, I never would have been able to find this without it. I've debugged it a bunch and it is indeed a PHPStan bug. I've opened an issue: https://github.com/phpstan/phpstan/issues/12065

I'll close this issue for now since it's not directly related to the extension but will keep you up to date on the status of the other issue.

SanderRonde commented 2 weeks ago

Bit of an update: they found the bug and a fix is underway in a new version of PHPStan (so it'll probably be a while before you see it).