diff --git a/src/Rules/QueryPlanAnalyzerRule.php b/src/Rules/QueryPlanAnalyzerRule.php index d2ea4c150..c1ce14591 100644 --- a/src/Rules/QueryPlanAnalyzerRule.php +++ b/src/Rules/QueryPlanAnalyzerRule.php @@ -67,6 +67,7 @@ public function processNode(Node $callLike, Scope $scope): array } $queryArgPosition = null; + $unsupportedMethod = true; foreach ($this->classMethods as $classMethod) { sscanf($classMethod, '%[^::]::%[^#]#%i', $className, $methodName, $queryArgPosition); if (!\is_string($className) || !\is_string($methodName) || !\is_int($queryArgPosition)) { @@ -74,12 +75,17 @@ public function processNode(Node $callLike, Scope $scope): array } if ($methodName === $methodReflection->getName() && - ($methodReflection->getDeclaringClass()->getName() === $className || $methodReflection->getDeclaringClass()->isSubclassOf($className))) { + ($methodReflection->getDeclaringClass()->getName() === $className || $methodReflection->getDeclaringClass()->isSubclassOf($className)) + ) { + $unsupportedMethod = false; break; } } if (null === $queryArgPosition) { + throw new ShouldNotHappenException('Invalid classMethod definition'); + } + if ($unsupportedMethod) { return []; } diff --git a/src/Rules/SyntaxErrorInQueryFunctionRule.php b/src/Rules/SyntaxErrorInQueryFunctionRule.php index 76ff687c6..696963e49 100644 --- a/src/Rules/SyntaxErrorInQueryFunctionRule.php +++ b/src/Rules/SyntaxErrorInQueryFunctionRule.php @@ -59,6 +59,7 @@ public function processNode(Node $node, Scope $scope): array } $queryArgPosition = null; + $unsupportedFunction = true; foreach ($this->functionNames as $functionName) { sscanf($functionName, '%[^#]#%i', $functionName, $queryArgPosition); if (!\is_string($functionName) || !\is_int($queryArgPosition)) { @@ -66,11 +67,15 @@ public function processNode(Node $node, Scope $scope): array } if (strtolower($functionName) === strtolower($calledFunctionName)) { + $unsupportedFunction = false; break; } } if (null === $queryArgPosition) { + throw new ShouldNotHappenException('Invalid classMethod definition'); + } + if ($unsupportedFunction) { return []; } diff --git a/src/Rules/SyntaxErrorInQueryMethodRule.php b/src/Rules/SyntaxErrorInQueryMethodRule.php index 169b2f76a..c10f0f938 100644 --- a/src/Rules/SyntaxErrorInQueryMethodRule.php +++ b/src/Rules/SyntaxErrorInQueryMethodRule.php @@ -51,6 +51,7 @@ public function processNode(Node $node, Scope $scope): array } $queryArgPosition = null; + $unsupportedMethod = true; foreach ($this->classMethods as $classMethod) { sscanf($classMethod, '%[^::]::%[^#]#%i', $className, $methodName, $queryArgPosition); if (!\is_string($className) || !\is_string($methodName) || !\is_int($queryArgPosition)) { @@ -58,12 +59,17 @@ public function processNode(Node $node, Scope $scope): array } if ($methodName === $methodReflection->getName() && - ($methodReflection->getDeclaringClass()->getName() === $className || $methodReflection->getDeclaringClass()->isSubclassOf($className))) { + ($methodReflection->getDeclaringClass()->getName() === $className || $methodReflection->getDeclaringClass()->isSubclassOf($className)) + ) { + $unsupportedMethod = false; break; } } if (null === $queryArgPosition) { + throw new ShouldNotHappenException('Invalid classMethod definition'); + } + if ($unsupportedMethod) { return []; }