diff --git a/rules/TypeDeclaration/TypeAnalyzer/AlwaysStrictScalarExprAnalyzer.php b/rules/TypeDeclaration/TypeAnalyzer/AlwaysStrictScalarExprAnalyzer.php index c781e2dc6f3..c34117bc7d5 100644 --- a/rules/TypeDeclaration/TypeAnalyzer/AlwaysStrictScalarExprAnalyzer.php +++ b/rules/TypeDeclaration/TypeAnalyzer/AlwaysStrictScalarExprAnalyzer.php @@ -69,7 +69,7 @@ public function matchStrictScalarExpr(Expr $expr, Scope $scope): ?Type } $exprType = $this->nodeTypeResolver->getNativeType($expr); - if ($this->isScalarType($exprType)) { + if ($exprType->isScalar()->yes()) { return $exprType; } @@ -79,31 +79,13 @@ public function matchStrictScalarExpr(Expr $expr, Scope $scope): ?Type private function resolveCastType(Cast $cast): ?Type { $type = $this->nodeTypeResolver->getNativeType($cast); - if ($this->isScalarType($type)) { + if ($type->isScalar()->yes()) { return $type; } return null; } - private function isScalarType(Type $type): bool - { - if ($type->isString()->yes()) { - return true; - } - - if ($type->isFloat()->yes()) { - return true; - } - - if ($type->isInteger()->yes()) { - return true; - } - - return $type->isBoolean() - ->yes(); - } - private function resolveTypeFromScalar(Scalar $scalar): Type|null { if ($scalar instanceof Encapsed) { @@ -155,10 +137,10 @@ private function resolveFuncCallType(FuncCall $funcCall, Scope $scope): ?Type ); $returnType = $parametersAcceptor->getReturnType(); - if (! $this->isScalarType($returnType)) { - return null; + if ($returnType->isScalar()->yes()) { + return $returnType; } - return $returnType; + return null; } }