Skip to content

Commit 992f476

Browse files
phpstan-botclaude
andcommitted
Inline conditionalExpressionHolderMatches to avoid duplicating equals call
Remove the separate method and inline the isSuperTypeOf check directly at the call site, since the equals() check is already performed in the surrounding code. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 96c0249 commit 992f476

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

src/Analyser/MutatingScope.php

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2144,19 +2144,6 @@ public function enterAnonymousFunctionWithoutReflection(
21442144
);
21452145
}
21462146

2147-
private function conditionalExpressionHolderMatches(ExpressionTypeHolder $specified, ExpressionTypeHolder $condition): bool
2148-
{
2149-
if ($specified->equals($condition)) {
2150-
return true;
2151-
}
2152-
2153-
if (!$specified->getCertainty()->equals($condition->getCertainty())) {
2154-
return false;
2155-
}
2156-
2157-
return $condition->getType()->isSuperTypeOf($specified->getType())->yes();
2158-
}
2159-
21602147
private function expressionTypeIsUnchangeable(ExpressionTypeHolder $typeHolder): bool
21612148
{
21622149
$expr = $typeHolder->getExpr();
@@ -3243,7 +3230,10 @@ public function filterBySpecifiedTypes(SpecifiedTypes $specifiedTypes): self
32433230
}
32443231
if (!$specifiedExpressions[$holderExprString]->equals($conditionalTypeHolder)) {
32453232
$allExact = false;
3246-
if (!$this->conditionalExpressionHolderMatches($specifiedExpressions[$holderExprString], $conditionalTypeHolder)) {
3233+
if (
3234+
!$specifiedExpressions[$holderExprString]->getCertainty()->equals($conditionalTypeHolder->getCertainty())
3235+
|| !$conditionalTypeHolder->getType()->isSuperTypeOf($specifiedExpressions[$holderExprString]->getType())->yes()
3236+
) {
32473237
$allSuperType = false;
32483238
break;
32493239
}

0 commit comments

Comments
 (0)