-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PossiblyFalseReference | PossiblyFalseArgument false-positive for Collection interface #77
Comments
Phpstan support the Is it possible to do something similar for psalm @muglug @weirdan @orklah ? |
@VincentLanglet I think something similar had been done on this PR: vimeo/psalm#5333 The goal was to change the result of The PR was ultimately rejected because Matt had a different idea, but I'm pretty sure the code worked and could be reproduced here |
Thanks @orklah, it helps me a lot. I just have two question:
In my case, I assume it will be more like
but how do I get the value I should pass to the TGenericObject ? |
For the statement, it is needed to get access to the variable containing the PHPParser statement here: https://github.com/vimeo/psalm/pull/5333/files#diff-ef767cc8f02262b219a73ec7be49523e0ef0c53710dda71f9be63ef2c5220602R25, so yeah, hard to do without it. For the second question, I expect you'll have to do something similar. If I take the code snippet above, then when you are in a context when isEmpty returned false, then it means you are in the if, and you should "filter out" |
I started vimeo/psalm#6060 then. |
I just read vimeo/psalm#5333 (comment) ; maybe it can be solve with some psalm-assert too ? And I think there is something different between the
Which means that in
Is there a way to do this ? |
The line here: https://github.com/vimeo/psalm/pull/5333/files#diff-ef767cc8f02262b219a73ec7be49523e0ef0c53710dda71f9be63ef2c5220602R45 doesn't say "if hastype was true at one point, then gettype will not return null". It says "if hastype is true for this scope then gettype will not return null. It doesn't say anything about the return value outside of the scope you're currently looking for (outside of the if, gettype may return something else. For hastype/gettype, immutability makes this impossible (and it may be why Matt refused the PR to use assertions), but without immutability, you can only assume the value won't change in your scope. I don't think it's an issue to assume this for doctrine plugin I'm not certain this will work or even if it possible to make it works somehow. Just saying that's how I would try :) |
vimeo/psalm#6060 is merged, so I just need a new release of psalm to continue :) |
Fixed in #94 |
weirdan/doctrine-psalm-plugin 0.11.3
vimeo/psalm 3.17.2
Neither first() nor last() can't return false on Collection that is not empty.
The text was updated successfully, but these errors were encountered: