44
55namespace staabm \PHPStanDba \QueryReflection ;
66
7- use PhpParser \Node \Expr \MethodCall ;
8- use PHPStan \Analyser \Scope ;
9-
107final class PlaceholderValidation
118{
129 /**
10+ * @param array<string|int, scalar|null> $parameters
11+ *
1312 * @return iterable<string>
1413 */
15- public function checkErrors (string $ queryString , MethodCall $ methodCall , Scope $ scope ): iterable
14+ public function checkErrors (string $ queryString , array $ parameters ): iterable
1615 {
1716 $ queryReflection = new QueryReflection ();
18- $ args = $ methodCall ->getArgs ();
1917 $ placeholderCount = $ queryReflection ->countPlaceholders ($ queryString );
2018
21- if (0 === \count ($ args )) {
19+ if (0 === \count ($ parameters )) {
2220 if (0 === $ placeholderCount ) {
2321 return ;
2422 }
@@ -33,22 +31,18 @@ public function checkErrors(string $queryString, MethodCall $methodCall, Scope $
3331 return ;
3432 }
3533
36- yield from $ this ->checkParameterValues ($ methodCall , $ scope , $ queryString , $ placeholderCount );
34+ yield from $ this ->checkParameterValues ($ queryString , $ parameters , $ placeholderCount );
3735 }
3836
3937 /**
38+ * @param array<string|int, scalar|null> $parameters
39+ *
4040 * @return iterable<string>
4141 */
42- private function checkParameterValues (MethodCall $ methodCall , Scope $ scope , string $ queryString , int $ placeholderCount ): iterable
42+ private function checkParameterValues (string $ queryString , array $ parameters , int $ placeholderCount ): iterable
4343 {
4444 $ queryReflection = new QueryReflection ();
45- $ args = $ methodCall ->getArgs ();
4645
47- $ parameterTypes = $ scope ->getType ($ args [0 ]->value );
48- $ parameters = $ queryReflection ->resolveParameters ($ parameterTypes );
49- if (null === $ parameters ) {
50- return ;
51- }
5246 $ parameterCount = \count ($ parameters );
5347
5448 if ($ parameterCount !== $ placeholderCount ) {
0 commit comments