-
Notifications
You must be signed in to change notification settings - Fork 507
Fix bug 8937 with match and treatPhpDocTypesAsCertain #2250
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
e300fd9
to
ca18fac
Compare
@@ -65,13 +66,23 @@ public function processNode(Node $node, Scope $scope): array | |||
$matchCondition, | |||
$armCondition->getCondition(), | |||
); | |||
$armConditionResult = ($this->treatPhpDocTypesAsCertain ? $armConditionScope->getType($armConditionExpr) : $armConditionScope->getNativeType($armConditionExpr)); |
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 split this in nextArmIsDeadForType
and nextArmIsDeadForNativeType
because
Match arm is unreachable
should rely on$nextArmIsDeadForNativeType || $nextArmIsDeadForType && $this->treatPhpDocTypesAsCertain
in order to not be reported in the issue 8932.Match expression does not handle remaining
should rely only onnextArmIsDeadForType
in order to not be reported in the issue 8937.
This way extra checks are allowed when using treatPhpDocTypesAsCertain: false
, but phpstan are not complaining if they are missing.
ca18fac
to
027f3d7
Compare
c43f1b8
to
b79fd6a
Compare
$errors = []; | ||
$armsCount = count($node->getArms()); | ||
$hasDefault = false; | ||
foreach ($node->getArms() as $i => $arm) { | ||
if ($nextArmIsDead) { | ||
if ($nextArmIsDeadForNativeType || $nextArmIsDeadForType && $this->treatPhpDocTypesAsCertain) { |
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.
Please use parentheses to disambiguate the condition. And please rebase on top of 1.10.x so we can see whether there are new failures. Thanks.
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.
It's rebased with parentheses added
Thank you. |
Closes phpstan/phpstan#8937
I dunno if it's the best fix, but seems like it's solving both phpstan/phpstan#8932 and phpstan/phpstan#8937.