Skip to content

Commit 209142a

Browse files
authored
fixed regression (#453)
1 parent f9d94b1 commit 209142a

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

src/Rules/QueryPlanAnalyzerRule.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,25 @@ public function processNode(Node $callLike, Scope $scope): array
6767
}
6868

6969
$queryArgPosition = null;
70+
$unsupportedMethod = true;
7071
foreach ($this->classMethods as $classMethod) {
7172
sscanf($classMethod, '%[^::]::%[^#]#%i', $className, $methodName, $queryArgPosition);
7273
if (!\is_string($className) || !\is_string($methodName) || !\is_int($queryArgPosition)) {
7374
throw new ShouldNotHappenException('Invalid classMethod definition');
7475
}
7576

7677
if ($methodName === $methodReflection->getName() &&
77-
($methodReflection->getDeclaringClass()->getName() === $className || $methodReflection->getDeclaringClass()->isSubclassOf($className))) {
78+
($methodReflection->getDeclaringClass()->getName() === $className || $methodReflection->getDeclaringClass()->isSubclassOf($className))
79+
) {
80+
$unsupportedMethod = false;
7881
break;
7982
}
8083
}
8184

8285
if (null === $queryArgPosition) {
86+
throw new ShouldNotHappenException('Invalid classMethod definition');
87+
}
88+
if ($unsupportedMethod) {
8389
return [];
8490
}
8591

src/Rules/SyntaxErrorInQueryFunctionRule.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,23 @@ public function processNode(Node $node, Scope $scope): array
5959
}
6060

6161
$queryArgPosition = null;
62+
$unsupportedFunction = true;
6263
foreach ($this->functionNames as $functionName) {
6364
sscanf($functionName, '%[^#]#%i', $functionName, $queryArgPosition);
6465
if (!\is_string($functionName) || !\is_int($queryArgPosition)) {
6566
throw new ShouldNotHappenException('Invalid functionName definition');
6667
}
6768

6869
if (strtolower($functionName) === strtolower($calledFunctionName)) {
70+
$unsupportedFunction = false;
6971
break;
7072
}
7173
}
7274

7375
if (null === $queryArgPosition) {
76+
throw new ShouldNotHappenException('Invalid classMethod definition');
77+
}
78+
if ($unsupportedFunction) {
7479
return [];
7580
}
7681

src/Rules/SyntaxErrorInQueryMethodRule.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,25 @@ public function processNode(Node $node, Scope $scope): array
5151
}
5252

5353
$queryArgPosition = null;
54+
$unsupportedMethod = true;
5455
foreach ($this->classMethods as $classMethod) {
5556
sscanf($classMethod, '%[^::]::%[^#]#%i', $className, $methodName, $queryArgPosition);
5657
if (!\is_string($className) || !\is_string($methodName) || !\is_int($queryArgPosition)) {
5758
throw new ShouldNotHappenException('Invalid classMethod definition');
5859
}
5960

6061
if ($methodName === $methodReflection->getName() &&
61-
($methodReflection->getDeclaringClass()->getName() === $className || $methodReflection->getDeclaringClass()->isSubclassOf($className))) {
62+
($methodReflection->getDeclaringClass()->getName() === $className || $methodReflection->getDeclaringClass()->isSubclassOf($className))
63+
) {
64+
$unsupportedMethod = false;
6265
break;
6366
}
6467
}
6568

6669
if (null === $queryArgPosition) {
70+
throw new ShouldNotHappenException('Invalid classMethod definition');
71+
}
72+
if ($unsupportedMethod) {
6773
return [];
6874
}
6975

0 commit comments

Comments
 (0)