diff --git a/src/Analyser/MutatingScope.php b/src/Analyser/MutatingScope.php index 65e5780a9e..721f483ece 100644 --- a/src/Analyser/MutatingScope.php +++ b/src/Analyser/MutatingScope.php @@ -2012,7 +2012,6 @@ static function (Node $node, Scope $scope) use ($arrowScope, &$arrowFunctionImpu if ($node instanceof Expr\BinaryOp\Coalesce) { $issetLeftExpr = new Expr\Isset_([$node->left]); - $leftType = $this->filterByTruthyValue($issetLeftExpr)->getType($node->left); $result = $this->issetCheck($node->left, static function (Type $type): ?bool { $isNull = $type->isNull(); @@ -2024,14 +2023,14 @@ static function (Node $node, Scope $scope) use ($arrowScope, &$arrowFunctionImpu }); if ($result !== null && $result !== false) { - return TypeCombinator::removeNull($leftType); + return TypeCombinator::removeNull($this->filterByTruthyValue($issetLeftExpr)->getType($node->left)); } $rightType = $this->filterByFalseyValue($issetLeftExpr)->getType($node->right); if ($result === null) { return TypeCombinator::union( - TypeCombinator::removeNull($leftType), + TypeCombinator::removeNull($this->filterByTruthyValue($issetLeftExpr)->getType($node->left)), $rightType, ); }