These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /* |
||
3 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||
4 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||
5 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||
6 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||
7 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||
8 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||
9 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||
10 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||
11 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||
12 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||
13 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
14 | * |
||
15 | * This software consists of voluntary contributions made by many individuals |
||
16 | * and is licensed under the MIT license. For more information, see |
||
17 | * <http://www.doctrine-project.org>. |
||
18 | */ |
||
19 | |||
20 | namespace Doctrine\ORM\Query; |
||
21 | |||
22 | /** |
||
23 | * Represents a chain of tree walkers that modify an AST and finally emit output. |
||
24 | * Only the last walker in the chain can emit output. Any previous walkers can modify |
||
25 | * the AST to influence the final output produced by the last walker. |
||
26 | * |
||
27 | * @author Roman Borschel <[email protected]> |
||
28 | * @since 2.0 |
||
29 | */ |
||
30 | class TreeWalkerChain implements TreeWalker |
||
31 | { |
||
32 | /** |
||
33 | * The tree walkers. |
||
34 | * |
||
35 | * @var TreeWalker[] |
||
36 | */ |
||
37 | private $_walkers; |
||
38 | |||
39 | /** |
||
40 | * The original Query. |
||
41 | * |
||
42 | * @var \Doctrine\ORM\AbstractQuery |
||
43 | */ |
||
44 | private $_query; |
||
45 | |||
46 | /** |
||
47 | * The ParserResult of the original query that was produced by the Parser. |
||
48 | * |
||
49 | * @var \Doctrine\ORM\Query\ParserResult |
||
50 | */ |
||
51 | private $_parserResult; |
||
52 | |||
53 | /** |
||
54 | * The query components of the original query (the "symbol table") that was produced by the Parser. |
||
55 | * |
||
56 | * @var array |
||
57 | */ |
||
58 | private $_queryComponents; |
||
59 | |||
60 | /** |
||
61 | * Returns the internal queryComponents array. |
||
62 | * |
||
63 | * @return array |
||
64 | */ |
||
65 | 92 | public function getQueryComponents() |
|
66 | { |
||
67 | 92 | return $this->_queryComponents; |
|
68 | } |
||
69 | |||
70 | /** |
||
71 | * {@inheritdoc} |
||
72 | */ |
||
73 | View Code Duplication | public function setQueryComponent($dqlAlias, array $queryComponent) |
|
74 | { |
||
75 | $requiredKeys = ['metadata', 'parent', 'relation', 'map', 'nestingLevel', 'token']; |
||
76 | |||
77 | if (array_diff($requiredKeys, array_keys($queryComponent))) { |
||
78 | throw QueryException::invalidQueryComponent($dqlAlias); |
||
79 | } |
||
80 | |||
81 | $this->_queryComponents[$dqlAlias] = $queryComponent; |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * {@inheritdoc} |
||
86 | */ |
||
87 | 92 | public function __construct($query, $parserResult, array $queryComponents) |
|
88 | { |
||
89 | 92 | $this->_query = $query; |
|
90 | 92 | $this->_parserResult = $parserResult; |
|
91 | 92 | $this->_queryComponents = $queryComponents; |
|
92 | 92 | $this->_walkers = new TreeWalkerChainIterator($this, $query, $parserResult); |
|
0 ignored issues
–
show
|
|||
93 | 92 | } |
|
94 | |||
95 | /** |
||
96 | * Adds a tree walker to the chain. |
||
97 | * |
||
98 | * @param string $walkerClass The class of the walker to instantiate. |
||
99 | * |
||
100 | * @return void |
||
101 | */ |
||
102 | 92 | public function addTreeWalker($walkerClass) |
|
103 | { |
||
104 | 92 | $this->_walkers[] = $walkerClass; |
|
105 | 92 | } |
|
106 | |||
107 | /** |
||
108 | * {@inheritdoc} |
||
109 | */ |
||
110 | 92 | public function walkSelectStatement(AST\SelectStatement $AST) |
|
111 | { |
||
112 | 92 | foreach ($this->_walkers as $walker) { |
|
113 | 92 | $walker->walkSelectStatement($AST); |
|
114 | |||
115 | 86 | $this->_queryComponents = $walker->getQueryComponents(); |
|
116 | } |
||
117 | 86 | } |
|
118 | |||
119 | /** |
||
120 | * {@inheritdoc} |
||
121 | */ |
||
122 | public function walkSelectClause($selectClause) |
||
123 | { |
||
124 | foreach ($this->_walkers as $walker) { |
||
125 | $walker->walkSelectClause($selectClause); |
||
126 | } |
||
127 | } |
||
128 | |||
129 | /** |
||
130 | * {@inheritdoc} |
||
131 | */ |
||
132 | public function walkFromClause($fromClause) |
||
133 | { |
||
134 | foreach ($this->_walkers as $walker) { |
||
135 | $walker->walkFromClause($fromClause); |
||
136 | } |
||
137 | } |
||
138 | |||
139 | /** |
||
140 | * {@inheritdoc} |
||
141 | */ |
||
142 | public function walkFunction($function) |
||
143 | { |
||
144 | foreach ($this->_walkers as $walker) { |
||
145 | $walker->walkFunction($function); |
||
146 | } |
||
147 | } |
||
148 | |||
149 | /** |
||
150 | * {@inheritdoc} |
||
151 | */ |
||
152 | public function walkOrderByClause($orderByClause) |
||
153 | { |
||
154 | foreach ($this->_walkers as $walker) { |
||
155 | $walker->walkOrderByClause($orderByClause); |
||
156 | } |
||
157 | } |
||
158 | |||
159 | /** |
||
160 | * {@inheritdoc} |
||
161 | */ |
||
162 | public function walkOrderByItem($orderByItem) |
||
163 | { |
||
164 | foreach ($this->_walkers as $walker) { |
||
165 | $walker->walkOrderByItem($orderByItem); |
||
166 | } |
||
167 | } |
||
168 | |||
169 | /** |
||
170 | * {@inheritdoc} |
||
171 | */ |
||
172 | public function walkHavingClause($havingClause) |
||
173 | { |
||
174 | foreach ($this->_walkers as $walker) { |
||
175 | $walker->walkHavingClause($havingClause); |
||
176 | } |
||
177 | } |
||
178 | |||
179 | /** |
||
180 | * {@inheritdoc} |
||
181 | */ |
||
182 | public function walkJoin($join) |
||
183 | { |
||
184 | foreach ($this->_walkers as $walker) { |
||
185 | $walker->walkJoin($join); |
||
186 | } |
||
187 | } |
||
188 | |||
189 | /** |
||
190 | * {@inheritdoc} |
||
191 | */ |
||
192 | public function walkSelectExpression($selectExpression) |
||
193 | { |
||
194 | foreach ($this->_walkers as $walker) { |
||
195 | $walker->walkSelectExpression($selectExpression); |
||
196 | } |
||
197 | } |
||
198 | |||
199 | /** |
||
200 | * {@inheritdoc} |
||
201 | */ |
||
202 | public function walkQuantifiedExpression($qExpr) |
||
203 | { |
||
204 | foreach ($this->_walkers as $walker) { |
||
205 | $walker->walkQuantifiedExpression($qExpr); |
||
206 | } |
||
207 | } |
||
208 | |||
209 | /** |
||
210 | * {@inheritdoc} |
||
211 | */ |
||
212 | public function walkSubselect($subselect) |
||
213 | { |
||
214 | foreach ($this->_walkers as $walker) { |
||
215 | $walker->walkSubselect($subselect); |
||
216 | } |
||
217 | } |
||
218 | |||
219 | /** |
||
220 | * {@inheritdoc} |
||
221 | */ |
||
222 | public function walkSubselectFromClause($subselectFromClause) |
||
223 | { |
||
224 | foreach ($this->_walkers as $walker) { |
||
225 | $walker->walkSubselectFromClause($subselectFromClause); |
||
226 | } |
||
227 | } |
||
228 | |||
229 | /** |
||
230 | * {@inheritdoc} |
||
231 | */ |
||
232 | public function walkSimpleSelectClause($simpleSelectClause) |
||
233 | { |
||
234 | foreach ($this->_walkers as $walker) { |
||
235 | $walker->walkSimpleSelectClause($simpleSelectClause); |
||
236 | } |
||
237 | } |
||
238 | |||
239 | /** |
||
240 | * {@inheritdoc} |
||
241 | */ |
||
242 | public function walkSimpleSelectExpression($simpleSelectExpression) |
||
243 | { |
||
244 | foreach ($this->_walkers as $walker) { |
||
245 | $walker->walkSimpleSelectExpression($simpleSelectExpression); |
||
246 | } |
||
247 | } |
||
248 | |||
249 | /** |
||
250 | * {@inheritdoc} |
||
251 | */ |
||
252 | public function walkAggregateExpression($aggExpression) |
||
253 | { |
||
254 | foreach ($this->_walkers as $walker) { |
||
255 | $walker->walkAggregateExpression($aggExpression); |
||
256 | } |
||
257 | } |
||
258 | |||
259 | /** |
||
260 | * {@inheritdoc} |
||
261 | */ |
||
262 | public function walkGroupByClause($groupByClause) |
||
263 | { |
||
264 | foreach ($this->_walkers as $walker) { |
||
265 | $walker->walkGroupByClause($groupByClause); |
||
266 | } |
||
267 | } |
||
268 | |||
269 | /** |
||
270 | * {@inheritdoc} |
||
271 | */ |
||
272 | public function walkGroupByItem($groupByItem) |
||
273 | { |
||
274 | foreach ($this->_walkers as $walker) { |
||
275 | $walker->walkGroupByItem($groupByItem); |
||
276 | } |
||
277 | } |
||
278 | |||
279 | /** |
||
280 | * {@inheritdoc} |
||
281 | */ |
||
282 | public function walkUpdateStatement(AST\UpdateStatement $AST) |
||
283 | { |
||
284 | foreach ($this->_walkers as $walker) { |
||
285 | $walker->walkUpdateStatement($AST); |
||
286 | } |
||
287 | } |
||
288 | |||
289 | /** |
||
290 | * {@inheritdoc} |
||
291 | */ |
||
292 | public function walkDeleteStatement(AST\DeleteStatement $AST) |
||
293 | { |
||
294 | foreach ($this->_walkers as $walker) { |
||
295 | $walker->walkDeleteStatement($AST); |
||
296 | } |
||
297 | } |
||
298 | |||
299 | /** |
||
300 | * {@inheritdoc} |
||
301 | */ |
||
302 | public function walkDeleteClause(AST\DeleteClause $deleteClause) |
||
303 | { |
||
304 | foreach ($this->_walkers as $walker) { |
||
305 | $walker->walkDeleteClause($deleteClause); |
||
306 | } |
||
307 | } |
||
308 | |||
309 | /** |
||
310 | * {@inheritdoc} |
||
311 | */ |
||
312 | public function walkUpdateClause($updateClause) |
||
313 | { |
||
314 | foreach ($this->_walkers as $walker) { |
||
315 | $walker->walkUpdateClause($updateClause); |
||
316 | } |
||
317 | } |
||
318 | |||
319 | /** |
||
320 | * {@inheritdoc} |
||
321 | */ |
||
322 | public function walkUpdateItem($updateItem) |
||
323 | { |
||
324 | foreach ($this->_walkers as $walker) { |
||
325 | $walker->walkUpdateItem($updateItem); |
||
326 | } |
||
327 | } |
||
328 | |||
329 | /** |
||
330 | * {@inheritdoc} |
||
331 | */ |
||
332 | public function walkWhereClause($whereClause) |
||
333 | { |
||
334 | foreach ($this->_walkers as $walker) { |
||
335 | $walker->walkWhereClause($whereClause); |
||
336 | } |
||
337 | } |
||
338 | |||
339 | /** |
||
340 | * {@inheritdoc} |
||
341 | */ |
||
342 | public function walkConditionalExpression($condExpr) |
||
343 | { |
||
344 | foreach ($this->_walkers as $walker) { |
||
345 | $walker->walkConditionalExpression($condExpr); |
||
346 | } |
||
347 | } |
||
348 | |||
349 | /** |
||
350 | * {@inheritdoc} |
||
351 | */ |
||
352 | public function walkConditionalTerm($condTerm) |
||
353 | { |
||
354 | foreach ($this->_walkers as $walker) { |
||
355 | $walker->walkConditionalTerm($condTerm); |
||
356 | } |
||
357 | } |
||
358 | |||
359 | /** |
||
360 | * {@inheritdoc} |
||
361 | */ |
||
362 | public function walkConditionalFactor($factor) |
||
363 | { |
||
364 | foreach ($this->_walkers as $walker) { |
||
365 | $walker->walkConditionalFactor($factor); |
||
366 | } |
||
367 | } |
||
368 | |||
369 | /** |
||
370 | * {@inheritdoc} |
||
371 | */ |
||
372 | public function walkConditionalPrimary($condPrimary) |
||
373 | { |
||
374 | foreach ($this->_walkers as $walker) { |
||
375 | $walker->walkConditionalPrimary($condPrimary); |
||
376 | } |
||
377 | } |
||
378 | |||
379 | /** |
||
380 | * {@inheritdoc} |
||
381 | */ |
||
382 | public function walkExistsExpression($existsExpr) |
||
383 | { |
||
384 | foreach ($this->_walkers as $walker) { |
||
385 | $walker->walkExistsExpression($existsExpr); |
||
386 | } |
||
387 | } |
||
388 | |||
389 | /** |
||
390 | * {@inheritdoc} |
||
391 | */ |
||
392 | public function walkCollectionMemberExpression($collMemberExpr) |
||
393 | { |
||
394 | foreach ($this->_walkers as $walker) { |
||
395 | $walker->walkCollectionMemberExpression($collMemberExpr); |
||
396 | } |
||
397 | } |
||
398 | |||
399 | /** |
||
400 | * {@inheritdoc} |
||
401 | */ |
||
402 | public function walkEmptyCollectionComparisonExpression($emptyCollCompExpr) |
||
403 | { |
||
404 | foreach ($this->_walkers as $walker) { |
||
405 | $walker->walkEmptyCollectionComparisonExpression($emptyCollCompExpr); |
||
406 | } |
||
407 | } |
||
408 | |||
409 | /** |
||
410 | * {@inheritdoc} |
||
411 | */ |
||
412 | public function walkNullComparisonExpression($nullCompExpr) |
||
413 | { |
||
414 | foreach ($this->_walkers as $walker) { |
||
415 | $walker->walkNullComparisonExpression($nullCompExpr); |
||
416 | } |
||
417 | } |
||
418 | |||
419 | /** |
||
420 | * {@inheritdoc} |
||
421 | */ |
||
422 | public function walkInExpression($inExpr) |
||
423 | { |
||
424 | foreach ($this->_walkers as $walker) { |
||
425 | $walker->walkInExpression($inExpr); |
||
426 | } |
||
427 | } |
||
428 | |||
429 | /** |
||
430 | * {@inheritdoc} |
||
431 | */ |
||
432 | public function walkInstanceOfExpression($instanceOfExpr) |
||
433 | { |
||
434 | foreach ($this->_walkers as $walker) { |
||
435 | $walker->walkInstanceOfExpression($instanceOfExpr); |
||
436 | } |
||
437 | } |
||
438 | |||
439 | /** |
||
440 | * {@inheritdoc} |
||
441 | */ |
||
442 | public function walkLiteral($literal) |
||
443 | { |
||
444 | foreach ($this->_walkers as $walker) { |
||
445 | $walker->walkLiteral($literal); |
||
446 | } |
||
447 | } |
||
448 | |||
449 | /** |
||
450 | * {@inheritdoc} |
||
451 | */ |
||
452 | public function walkBetweenExpression($betweenExpr) |
||
453 | { |
||
454 | foreach ($this->_walkers as $walker) { |
||
455 | $walker->walkBetweenExpression($betweenExpr); |
||
456 | } |
||
457 | } |
||
458 | |||
459 | /** |
||
460 | * {@inheritdoc} |
||
461 | */ |
||
462 | public function walkLikeExpression($likeExpr) |
||
463 | { |
||
464 | foreach ($this->_walkers as $walker) { |
||
465 | $walker->walkLikeExpression($likeExpr); |
||
466 | } |
||
467 | } |
||
468 | |||
469 | /** |
||
470 | * {@inheritdoc} |
||
471 | */ |
||
472 | public function walkStateFieldPathExpression($stateFieldPathExpression) |
||
473 | { |
||
474 | foreach ($this->_walkers as $walker) { |
||
475 | $walker->walkStateFieldPathExpression($stateFieldPathExpression); |
||
476 | } |
||
477 | } |
||
478 | |||
479 | /** |
||
480 | * {@inheritdoc} |
||
481 | */ |
||
482 | public function walkComparisonExpression($compExpr) |
||
483 | { |
||
484 | foreach ($this->_walkers as $walker) { |
||
485 | $walker->walkComparisonExpression($compExpr); |
||
486 | } |
||
487 | } |
||
488 | |||
489 | /** |
||
490 | * {@inheritdoc} |
||
491 | */ |
||
492 | public function walkInputParameter($inputParam) |
||
493 | { |
||
494 | foreach ($this->_walkers as $walker) { |
||
495 | $walker->walkInputParameter($inputParam); |
||
496 | } |
||
497 | } |
||
498 | |||
499 | /** |
||
500 | * {@inheritdoc} |
||
501 | */ |
||
502 | public function walkArithmeticExpression($arithmeticExpr) |
||
503 | { |
||
504 | foreach ($this->_walkers as $walker) { |
||
505 | $walker->walkArithmeticExpression($arithmeticExpr); |
||
506 | } |
||
507 | } |
||
508 | |||
509 | /** |
||
510 | * {@inheritdoc} |
||
511 | */ |
||
512 | public function walkArithmeticTerm($term) |
||
513 | { |
||
514 | foreach ($this->_walkers as $walker) { |
||
515 | $walker->walkArithmeticTerm($term); |
||
516 | } |
||
517 | } |
||
518 | |||
519 | /** |
||
520 | * {@inheritdoc} |
||
521 | */ |
||
522 | public function walkStringPrimary($stringPrimary) |
||
523 | { |
||
524 | foreach ($this->_walkers as $walker) { |
||
525 | $walker->walkStringPrimary($stringPrimary); |
||
526 | } |
||
527 | } |
||
528 | |||
529 | /** |
||
530 | * {@inheritdoc} |
||
531 | */ |
||
532 | public function walkArithmeticFactor($factor) |
||
533 | { |
||
534 | foreach ($this->_walkers as $walker) { |
||
535 | $walker->walkArithmeticFactor($factor); |
||
536 | } |
||
537 | } |
||
538 | |||
539 | /** |
||
540 | * {@inheritdoc} |
||
541 | */ |
||
542 | public function walkSimpleArithmeticExpression($simpleArithmeticExpr) |
||
543 | { |
||
544 | foreach ($this->_walkers as $walker) { |
||
545 | $walker->walkSimpleArithmeticExpression($simpleArithmeticExpr); |
||
546 | } |
||
547 | } |
||
548 | |||
549 | /** |
||
550 | * {@inheritdoc} |
||
551 | */ |
||
552 | public function walkPathExpression($pathExpr) |
||
553 | { |
||
554 | foreach ($this->_walkers as $walker) { |
||
555 | $walker->walkPathExpression($pathExpr); |
||
556 | } |
||
557 | } |
||
558 | |||
559 | /** |
||
560 | * {@inheritdoc} |
||
561 | */ |
||
562 | public function walkResultVariable($resultVariable) |
||
563 | { |
||
564 | foreach ($this->_walkers as $walker) { |
||
565 | $walker->walkResultVariable($resultVariable); |
||
566 | } |
||
567 | } |
||
568 | |||
569 | /** |
||
570 | * {@inheritdoc} |
||
571 | */ |
||
572 | public function getExecutor($AST) |
||
573 | { |
||
574 | } |
||
575 | } |
||
576 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..