From 49d78fd2f96f4d2ce8bb98249aba1ee594806074 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Tue, 3 Sep 2024 09:13:07 +0200 Subject: [PATCH] Simplify specifyTypesForConstantBinaryExpression --- src/Analyser/TypeSpecifier.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/Analyser/TypeSpecifier.php b/src/Analyser/TypeSpecifier.php index 9bf24f318d..356d0b30be 100644 --- a/src/Analyser/TypeSpecifier.php +++ b/src/Analyser/TypeSpecifier.php @@ -1074,13 +1074,7 @@ private function specifyTypesForConstantBinaryExpression( ?Expr $rootExpr, ): ?SpecifiedTypes { - $scalarValues = $constantType->getConstantScalarValues(); - if (count($scalarValues) !== 1) { - return null; - } - $constValue = $scalarValues[0]; - - if (!$context->null() && $constValue === false) { + if (!$context->null() && $constantType->isFalse()->yes()) { $types = $this->create($exprNode, $constantType, $context, false, $scope, $rootExpr); if ($exprNode instanceof Expr\NullsafeMethodCall || $exprNode instanceof Expr\NullsafePropertyFetch) { return $types; @@ -1094,7 +1088,7 @@ private function specifyTypesForConstantBinaryExpression( )); } - if (!$context->null() && $constValue === true) { + if (!$context->null() && $constantType->isTrue()->yes()) { $types = $this->create($exprNode, $constantType, $context, false, $scope, $rootExpr); if ($exprNode instanceof Expr\NullsafeMethodCall || $exprNode instanceof Expr\NullsafePropertyFetch) { return $types;