-
Notifications
You must be signed in to change notification settings - Fork 508
Fix issue 8467 intersect resolved conditional types #2059
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
Conversation
|
||
if ($initialClone && isset($origCwd)) { | ||
assertType('string', $origCwd); | ||
assertType('null', $cwd); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this one is not covered in createConditionalExpressions
yet and not working before 1.9.2 too.
I think it might be better to solve it in a different PR
The first error of larastan test failure looks like an improvement, but not sure with the second one. |
https://github.com/phpstan/phpstan-src/actions/runs/3635043616/jobs/6133787739 Tested in the playground and I believe both larastan test failure are improvements. First one second one Not sure enough with the second test. Maybe @canvural knows something? |
This pull request has been marked as ready for review. |
The test is failing in #2058 too, it may have nothing to do with this change anyway. |
Thank you 😊 |
I think this was caused because of a change in Laravel, not by this change. Because Larastan's own CI is also failing. So I'll fix this there 👍🏽 |
Yeah, I'll update the commit on our side once you fix it, thank you :) |
Thank you! |
@ondrejmirtes larastan/larastan@1a11021 Larastan's CI is green now. |
PHPStan is green too 🎉 https://github.com/phpstan/phpstan/actions/runs/3649224831/jobs/6163628972 |
I thought about this once in 42bddf0 but wasn't sure when this is needed.
The composer integration test failure was a very good example.
The conditional type knows
$initialClone=true => $origCwd=string|null
, butisset($originCwd)
has already specified$originCwd=>'string'
in theif ($initialClone && isset($origCwd))
truthy scope. Conditional type can be resolved in the scope too, so it overwrites the$originCwd
's type as$origCwd=string|null
.Before my changes (in 1.9.2) resolving conditional types for specified types were skipped, but I think it is better to intersect, because the conditional type can be narrower than the specified type.