diff --git a/src/Analyser/TypeSpecifier.php b/src/Analyser/TypeSpecifier.php index 1c1732089d..1f8e46bfbf 100644 --- a/src/Analyser/TypeSpecifier.php +++ b/src/Analyser/TypeSpecifier.php @@ -1130,7 +1130,21 @@ private function specifyTypesForConstantBinaryExpression( return $funcTypes->unionWith($valueTypes); } } + } + if ( + $context->true() + && $exprNode instanceof FuncCall + && $exprNode->name instanceof Name + && $exprNode->name->toLowerString() === 'preg_match' + && (new ConstantIntegerType(1))->isSuperTypeOf($constantType)->yes() + ) { + return $this->specifyTypesInCondition( + $scope, + $exprNode, + $context, + $rootExpr, + ); } return null; @@ -2081,21 +2095,6 @@ public function resolveIdentical(Expr\BinaryOp\Identical $expr, Scope $scope, Ty } $rightType = $scope->getType($rightExpr); - if ( - $context->true() - && $unwrappedLeftExpr instanceof FuncCall - && $unwrappedLeftExpr->name instanceof Name - && $unwrappedLeftExpr->name->toLowerString() === 'preg_match' - && (new ConstantIntegerType(1))->isSuperTypeOf($rightType)->yes() - ) { - return $this->specifyTypesInCondition( - $scope, - $leftExpr, - $context, - $rootExpr, - ); - } - if ( $context->true() && $unwrappedLeftExpr instanceof FuncCall