Skip to content

Commit aa7cac8

Browse files
committed
Update MutatingScope.php
1 parent 4dc2bc7 commit aa7cac8

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
@@ -4486,8 +4486,9 @@ public function addTypeToExpression(Expr $expr, Type $type): self
44864486

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

0 commit comments

Comments
 (0)