1414use PHPStan \Rules \RuleError ;
1515use PHPStan \Rules \RuleErrorBuilder ;
1616use PHPStan \ShouldNotHappenException ;
17- use PHPStan \Type \MixedType ;
1817use PHPStan \Type \ObjectType ;
1918use staabm \PHPStanDba \QueryReflection \QueryReflection ;
2019use staabm \PHPStanDba \Tests \QueryPlanAnalyzerRuleTest ;
@@ -89,20 +88,11 @@ public function processNode(Node $callLike, Scope $scope): array
8988 return [];
9089 }
9190
92- $ args = $ callLike ->getArgs ();
93- if (! \array_key_exists ($ queryArgPosition , $ args )) {
94- return [];
95- }
96-
97- if ($ scope ->getType ($ args [$ queryArgPosition ]->value ) instanceof MixedType) {
98- return [];
99- }
100-
10191 try {
10292 return $ this ->analyze ($ callLike , $ scope );
10393 } catch (UnresolvableQueryException $ exception ) {
10494 return [
105- RuleErrorBuilder::message ($ exception ->asRuleMessage ())->tip (UnresolvableQueryException:: RULE_TIP )->line ($ callLike ->getLine ())->build (),
95+ RuleErrorBuilder::message ($ exception ->asRuleMessage ())->tip ($ exception :: getTip () )->line ($ callLike ->getLine ())->build (),
10696 ];
10797 }
10898 }
@@ -125,8 +115,9 @@ private function analyze(CallLike $callLike, Scope $scope): array
125115 }
126116
127117 $ queryExpr = $ args [0 ]->value ;
118+ $ queryReflection = new QueryReflection ();
128119
129- if ($ scope -> getType ($ queryExpr) instanceof MixedType ) {
120+ if ($ queryReflection -> isResolvable ($ queryExpr, $ scope )-> no () ) {
130121 return [];
131122 }
132123
@@ -136,7 +127,6 @@ private function analyze(CallLike $callLike, Scope $scope): array
136127 }
137128
138129 $ ruleErrors = [];
139- $ queryReflection = new QueryReflection ();
140130 $ proposal = "\n\nConsider optimizing the query. \nIn some cases this is not a problem and this error should be ignored. " ;
141131
142132 foreach ($ queryReflection ->analyzeQueryPlan ($ scope , $ queryExpr , $ parameterTypes ) as $ queryPlanResult ) {
0 commit comments