Skip to content

Commit a81a132

Browse files
authored
Simplify NonNullabilityHelper (#5158)
1 parent d3e3da3 commit a81a132

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Analyser/ExprHandler/Helper/NonNullabilityHelper.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,7 @@ public function ensureShallowNonNullability(MutatingScope $scope, Scope $origina
2828
return new EnsuredNonNullabilityResult($scope, []);
2929
}
3030

31-
// keep certainty
32-
$certainty = TrinaryLogic::createYes();
3331
$hasExpressionType = $originalScope->hasExpressionType($exprToSpecify);
34-
if (!$hasExpressionType->no()) {
35-
$certainty = $hasExpressionType;
36-
}
3732

3833
$exprTypeWithoutNull = TypeCombinator::removeNull($exprType);
3934
if ($exprType->equals($exprTypeWithoutNull)) {
@@ -63,6 +58,12 @@ public function ensureShallowNonNullability(MutatingScope $scope, Scope $origina
6358
);
6459
}
6560

61+
// keep certainty
62+
$certainty = TrinaryLogic::createYes();
63+
if (!$hasExpressionType->no()) {
64+
$certainty = $hasExpressionType;
65+
}
66+
6667
$nativeType = $scope->getNativeType($exprToSpecify);
6768
$specifiedExpressions[] = new EnsuredNonNullabilityResultExpression($exprToSpecify, $exprType, $nativeType, $certainty);
6869
$scope = $scope->specifyExpressionType(

0 commit comments

Comments
 (0)