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
Add better propagation of truthy and falsey types #339
Conversation
This now allows
to correctly report the inner condition having constant type, among many other situations. I'm not 100% happy with the approach of representing truthy types via |
Yes! The main obstacle right now is that there are many instances of We'd first have to gather all usecases why people do I see this more of a PHPStan 2.0 thing rather than an immediate thing. I plan to release PHPStan 1.0 some time during winter 2020/21 that will be mostly the same from internals perspective as 0.12.x. But we can gradually introduce new Another feature that this will enable is an easy implementation of more complex type variable bounds like |
I noticed this PR causes some weird things to happen, for example:
Produces:
The third one is not desirable. It comes from the merging a scope where I tried something like the following, but that breaks at least some tests, so I'm not sure what's the best approach here.
|
3f8936c
to
0dfd0d0
Compare
I rebased it and made one small change: 0da3eb4 Thank you, I like it a lot! |
About #339 (comment) - I'll look into it on master. |
Yeah, so the problem was created because nonexistent variables in global scope always have certainty "maybe" and The second array should also probably be iterated over and the variables missing in it should be added, but I wasn't able to write a failing test for that scenario, so maybe it's not going to be a problem. Fixed: ebce7de |
This PR found a bug in Composer :) composer/composer#9277 |
No description provided.