Skip to content

Commit 1e44c9e

Browse files
staabmondrejmirtes
authored andcommitted
Simplify specifyTypesForConstantBinaryExpression
1 parent 0ee67d5 commit 1e44c9e

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

Diff for: src/Analyser/TypeSpecifier.php

+2-8
Original file line numberDiff line numberDiff line change
@@ -1074,13 +1074,7 @@ private function specifyTypesForConstantBinaryExpression(
10741074
?Expr $rootExpr,
10751075
): ?SpecifiedTypes
10761076
{
1077-
$scalarValues = $constantType->getConstantScalarValues();
1078-
if (count($scalarValues) !== 1) {
1079-
return null;
1080-
}
1081-
$constValue = $scalarValues[0];
1082-
1083-
if (!$context->null() && $constValue === false) {
1077+
if (!$context->null() && $constantType->isFalse()->yes()) {
10841078
$types = $this->create($exprNode, $constantType, $context, false, $scope, $rootExpr);
10851079
if ($exprNode instanceof Expr\NullsafeMethodCall || $exprNode instanceof Expr\NullsafePropertyFetch) {
10861080
return $types;
@@ -1094,7 +1088,7 @@ private function specifyTypesForConstantBinaryExpression(
10941088
));
10951089
}
10961090

1097-
if (!$context->null() && $constValue === true) {
1091+
if (!$context->null() && $constantType->isTrue()->yes()) {
10981092
$types = $this->create($exprNode, $constantType, $context, false, $scope, $rootExpr);
10991093
if ($exprNode instanceof Expr\NullsafeMethodCall || $exprNode instanceof Expr\NullsafePropertyFetch) {
11001094
return $types;

0 commit comments

Comments
 (0)