@@ -1611,35 +1611,38 @@ private function resolveType(string $exprString, Expr $node): Type
1611
1611
}
1612
1612
1613
1613
if ($ node instanceof Expr \Ternary) {
1614
+ $ noopCallback = static function (): void {
1615
+ };
1616
+ $ condResult = $ this ->nodeScopeResolver ->processExprNode ($ node ->cond , $ this , $ noopCallback , ExpressionContext::createDeep ());
1614
1617
if ($ node ->if === null ) {
1615
1618
$ conditionType = $ this ->getType ($ node ->cond );
1616
1619
$ booleanConditionType = $ conditionType ->toBoolean ();
1617
1620
if ($ booleanConditionType ->isTrue ()->yes ()) {
1618
- return $ this -> filterByTruthyValue ( $ node -> cond )->getType ($ node ->cond );
1621
+ return $ condResult -> getTruthyScope ( )->getType ($ node ->cond );
1619
1622
}
1620
1623
1621
1624
if ($ booleanConditionType ->isFalse ()->yes ()) {
1622
- return $ this -> filterByFalseyValue ( $ node -> cond )->getType ($ node ->else );
1625
+ return $ condResult -> getFalseyScope ( )->getType ($ node ->else );
1623
1626
}
1624
1627
1625
1628
return TypeCombinator::union (
1626
- TypeCombinator::removeFalsey ($ this -> filterByTruthyValue ( $ node -> cond )->getType ($ node ->cond )),
1627
- $ this -> filterByFalseyValue ( $ node -> cond )->getType ($ node ->else ),
1629
+ TypeCombinator::removeFalsey ($ condResult -> getTruthyScope ( )->getType ($ node ->cond )),
1630
+ $ condResult -> getFalseyScope ( )->getType ($ node ->else ),
1628
1631
);
1629
1632
}
1630
1633
1631
1634
$ booleanConditionType = $ this ->getType ($ node ->cond )->toBoolean ();
1632
1635
if ($ booleanConditionType ->isTrue ()->yes ()) {
1633
- return $ this -> filterByTruthyValue ( $ node -> cond )->getType ($ node ->if );
1636
+ return $ condResult -> getTruthyScope ( )->getType ($ node ->if );
1634
1637
}
1635
1638
1636
1639
if ($ booleanConditionType ->isFalse ()->yes ()) {
1637
- return $ this -> filterByFalseyValue ( $ node -> cond )->getType ($ node ->else );
1640
+ return $ condResult -> getFalseyScope ( )->getType ($ node ->else );
1638
1641
}
1639
1642
1640
1643
return TypeCombinator::union (
1641
- $ this -> filterByTruthyValue ( $ node -> cond )->getType ($ node ->if ),
1642
- $ this -> filterByFalseyValue ( $ node -> cond )->getType ($ node ->else ),
1644
+ $ condResult -> getTruthyScope ( )->getType ($ node ->if ),
1645
+ $ condResult -> getFalseyScope ( )->getType ($ node ->else ),
1643
1646
);
1644
1647
}
1645
1648
0 commit comments