@@ -1622,8 +1622,9 @@ private function ensureShallowNonNullability(MutatingScope $scope, Scope $origin
1622
1622
$ exprTypeWithoutNull = TypeCombinator::removeNull ($ exprType );
1623
1623
if ($ exprType ->equals ($ exprTypeWithoutNull )) {
1624
1624
$ originalExprType = $ originalScope ->getType ($ exprToSpecify );
1625
- $ originalNativeType = $ originalScope ->getNativeType ($ exprToSpecify );
1626
1625
if (!$ originalExprType ->equals ($ exprTypeWithoutNull )) {
1626
+ $ originalNativeType = $ originalScope ->getNativeType ($ exprToSpecify );
1627
+
1627
1628
return new EnsuredNonNullabilityResult ($ scope , [
1628
1629
new EnsuredNonNullabilityResultExpression ($ exprToSpecify , $ originalExprType , $ originalNativeType ),
1629
1630
]);
@@ -2643,14 +2644,17 @@ static function (Node $node, Scope $scope) use ($nodeCallback): void {
2643
2644
$ elseResult = $ this ->processExprNode ($ expr ->else , $ ifFalseScope , $ nodeCallback , $ context );
2644
2645
$ throwPoints = array_merge ($ throwPoints , $ elseResult ->getThrowPoints ());
2645
2646
$ ifFalseScope = $ elseResult ->getScope ();
2646
- $ ifFalseType = $ ifFalseScope ->getType ($ expr ->else );
2647
2647
2648
2648
if ($ ifTrueType instanceof NeverType && $ ifTrueType ->isExplicit ()) {
2649
2649
$ finalScope = $ ifFalseScope ;
2650
- } elseif ($ ifFalseType instanceof NeverType && $ ifFalseType ->isExplicit ()) {
2651
- $ finalScope = $ ifTrueScope ;
2652
2650
} else {
2653
- $ finalScope = $ ifTrueScope ->mergeWith ($ ifFalseScope );
2651
+ $ ifFalseType = $ ifFalseScope ->getType ($ expr ->else );
2652
+
2653
+ if ($ ifFalseType instanceof NeverType && $ ifFalseType ->isExplicit ()) {
2654
+ $ finalScope = $ ifTrueScope ;
2655
+ } else {
2656
+ $ finalScope = $ ifTrueScope ->mergeWith ($ ifFalseScope );
2657
+ }
2654
2658
}
2655
2659
2656
2660
return new ExpressionResult (
0 commit comments