14
14
use PHPStan \Rules \RuleError ;
15
15
use PHPStan \Rules \RuleErrorBuilder ;
16
16
use PHPStan \ShouldNotHappenException ;
17
- use PHPStan \Type \MixedType ;
18
17
use PHPStan \Type \ObjectType ;
19
18
use staabm \PHPStanDba \QueryReflection \QueryReflection ;
20
19
use staabm \PHPStanDba \Tests \QueryPlanAnalyzerRuleTest ;
@@ -89,20 +88,11 @@ public function processNode(Node $callLike, Scope $scope): array
89
88
return [];
90
89
}
91
90
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
-
101
91
try {
102
92
return $ this ->analyze ($ callLike , $ scope );
103
93
} catch (UnresolvableQueryException $ exception ) {
104
94
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 (),
106
96
];
107
97
}
108
98
}
@@ -125,8 +115,9 @@ private function analyze(CallLike $callLike, Scope $scope): array
125
115
}
126
116
127
117
$ queryExpr = $ args [0 ]->value ;
118
+ $ queryReflection = new QueryReflection ();
128
119
129
- if ($ scope -> getType ($ queryExpr) instanceof MixedType ) {
120
+ if ($ queryReflection -> isResolvable ($ queryExpr, $ scope )-> no () ) {
130
121
return [];
131
122
}
132
123
@@ -136,7 +127,6 @@ private function analyze(CallLike $callLike, Scope $scope): array
136
127
}
137
128
138
129
$ ruleErrors = [];
139
- $ queryReflection = new QueryReflection ();
140
130
$ proposal = "\n\nConsider optimizing the query. \nIn some cases this is not a problem and this error should be ignored. " ;
141
131
142
132
foreach ($ queryReflection ->analyzeQueryPlan ($ scope , $ queryExpr , $ parameterTypes ) as $ queryPlanResult ) {
0 commit comments