Skip to content

Commit 7e511de

Browse files
committed
Update MutatingScope.php
1 parent 24bdba4 commit 7e511de

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Analyser/MutatingScope.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4485,8 +4485,9 @@ public function addTypeToExpression(Expr $expr, Type $type): self
44854485

44864486
if ($originalExprType->equals($nativeType)) {
44874487
$newType = TypeCombinator::intersect($type, $originalExprType);
4488-
if (!$newType->isObject()->yes() && $newType->equals($originalExprType)) {
4489-
// don't add the same type over and over again to improve performance
4488+
if ($newType->isObject()->no() && $newType->equals($originalExprType)) {
4489+
// don't add the same type over and over again to improve performance.
4490+
// objects can get narrowed even though ObjectType->equal() will return true (e.g. via impicit "final" via new())
44904491
return $this;
44914492
}
44924493
return $this->specifyExpressionType($expr, $newType, $newType, TrinaryLogic::createYes());

0 commit comments

Comments
 (0)