Skip to content

Commit f75bcd2

Browse files
committed
Update MutatingScope.php
1 parent 3b93726 commit f75bcd2

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

44904490
if ($originalExprType->equals($nativeType)) {
44914491
$newType = TypeCombinator::intersect($type, $originalExprType);
4492-
if (!$newType->isObject()->yes() && $newType->equals($originalExprType)) {
4493-
// don't add the same type over and over again to improve performance
4492+
if ($newType->isObject()->no() && $newType->equals($originalExprType)) {
4493+
// don't add the same type over and over again to improve performance.
4494+
// objects can get narrowed even though ObjectType->equal() will return true (e.g. via impicit "final" via new())
44944495
return $this;
44954496
}
44964497
return $this->specifyExpressionType($expr, $newType, $newType, TrinaryLogic::createYes());

0 commit comments

Comments
 (0)