Improve conditionalExpressionTypes#1950
Conversation
edc1a3d to
0ae0fe3
Compare
|
This pull request has been marked as ready for review. |
|
Sorry miss clicked |
5b443e3 to
0537707
Compare
|
I think we can clean up the conditional expression logic, and make it easier to migrate to LateResolvableTypes |
|
Steps left
|
|
Another note, We need to carefully separate assign and specifying // when $b is conditional of $a = 'foo' => 'foo', $a = 'bar' => 'bar'
echo $b; // 'foo'|'bar'
if ($a === 'foo') {
echo $b; // 'foo'
}
if ($a === 'bar') {
echo $b; // 'bar'
}
if ($a === 'foo') {
$a = 'bar';
echo $b; // 'foo'
}
$a = 'foo';
echo $b; // 'foo'|'bar'Assign is a overwrite and needs invalidation of related resolved expression types, while specifying should be an intersection and no need to invalidate in my opinion. |
ee5afc6 to
6bcd89f
Compare
|
BTW just a minor nitpick - "temporal" is related to time, "temporary" is what you want here :) |
|
BTW there are some commented-out tests here https://github.com/phpstan/phpstan-src/blob/1.9.x/tests/PHPStan/Analyser/data/dependent-variable-certainty.php, maybe you could debug that as part of this or some future PR :) |
6bcd89f to
113fe01
Compare
7cee285 to
7af49fe
Compare
|
This fixes some issues: https://github.com/phpstan/phpstan-src/actions/runs/3420191417 Would be nice to add regression tests here for those which are fixed, to make sure they don't get broken in future iterations. |
|
@ondrejmirtes |
e8f1aac to
cbbc81e
Compare
|
Memo |
9def4f8 to
0260db9
Compare
76bb087 to
9659803
Compare
|
I'm gonna revert changes in |
|
What I did in this pull request
|
9659803 to
faf2da9
Compare
faf2da9 to
40ba7ec
Compare
|
I think this pull request is mergable now.
and then, we can change |
|
The phpunit integration test failure seems related |
|
Found that specified types from |
|
Fixed another bug and I think this is finally ready! |
|
The error of rector is legit, but the error message should be improved. ! $currentType instanceof AliasedObjectTypeis always false, because it's narrowed in the previous line. |
|
This pull request has been marked as ready for review. |
|
Does it make sense to also add |
|
Awesome, thank you! Looking to other improvements :) |
|
What doesn't sit well with me and what you haven't changed yet is the places in NodeScopeResolver where |
|
@herndlm @ondrejmirtes |

Steps left
createConditionalExpressionsExpressionTypeHoldersfor conditionsaddConditionalExpressionsfirst arg to exprfixes phpstan/phpstan#3677
fixes phpstan/phpstan#5623
fixes phpstan/phpstan#5401 (the playground in the comment is another issue, we should open a new issue)
fixes phpstan/phpstan#7292
fixes phpstan/phpstan#8212