refactor $conditionalExpressions#1270
Conversation
There was a problem hiding this comment.
This change makes sense to me. The error must be same with line 54.
|
Checked for the failing tests and I think it's unrelated. |
|
Thank you! |
|
@rajyan I think there's opportunity for refactoring, most likely in multiple steps:
There are also other issues in https://github.com/phpstan/phpstan/milestone/12 (potentially very hard to solve) that you might tackle (if you feel like it) after 1) and 2) :) Thanks for considering! |
|
Thank you for your pointers. |
|
FYI @rajyan I noticed there are some commented-out test cases in phpstan-src/tests/PHPStan/Analyser/data/dependent-variable-certainty.php Lines 261 to 480 in 9f1e793 |
|
Thank you! I look into it. |
Working on phpstan/phpstan#3677 and half way done.
If my understanding is correct, the logic in merge of
conditionalExpressionsinfilterBySpecifiedTypesshould be consistent with https://github.com/phpstan/phpstan-src/blob/0b3bfebebdeb3be2fbdcef5c2ba98a2885875228/src/Analyser/MutatingScope.php#L4784-L4786so
continue 2should becontinue. I'm not sure enough with the fix yet, but the fixed test looks better to me.Also, this example (coalesce -> coalesce, coalesce -> ternary) is fixed with this change.
these cases are not fixed yet. (ternary -> ternary, ternary -> coalesce)
While investigating this issue, I noticed some inconsistencies in keys of
$conditionalExpressions.I fixed to set key from
$holder->getKey()like inphpstan-src/src/Analyser/MutatingScope.php
Lines 4514 to 4515 in f8be122