Skip to content

Commit e3ea780

Browse files
staabmondrejmirtes
authored andcommitted
MutatingScope: prevent unnecessary work in removeTypeFromExpression()
1 parent df91618 commit e3ea780

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Analyser/MutatingScope.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3684,13 +3684,15 @@ public function addTypeToExpression(Expr $expr, Type $type): self
36843684

36853685
public function removeTypeFromExpression(Expr $expr, Type $typeToRemove): self
36863686
{
3687+
if ($typeToRemove instanceof NeverType) {
3688+
return $this;
3689+
}
3690+
36873691
$exprType = $this->getType($expr);
3688-
if (
3689-
$exprType instanceof NeverType ||
3690-
$typeToRemove instanceof NeverType
3691-
) {
3692+
if ($exprType instanceof NeverType) {
36923693
return $this;
36933694
}
3695+
36943696
return $this->specifyExpressionType(
36953697
$expr,
36963698
TypeCombinator::remove($exprType, $typeToRemove),

0 commit comments

Comments
 (0)