1 | <?php |
---|
2 | /* |
---|
3 | * $Id$ |
---|
4 | * |
---|
5 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
---|
6 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
---|
7 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
---|
8 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
---|
9 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
---|
10 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
---|
11 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
---|
12 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
---|
13 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
---|
14 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
---|
15 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
16 | * |
---|
17 | * This software consists of voluntary contributions made by many individuals |
---|
18 | * and is licensed under the LGPL. For more information, see |
---|
19 | * <http://www.doctrine-project.org>. |
---|
20 | */ |
---|
21 | |
---|
22 | namespace Doctrine\ORM\Query; |
---|
23 | |
---|
24 | /** |
---|
25 | * Interface for walkers of DQL ASTs (abstract syntax trees). |
---|
26 | * |
---|
27 | * @author Roman Borschel <roman@code-factory.org> |
---|
28 | * @since 2.0 |
---|
29 | */ |
---|
30 | interface TreeWalker |
---|
31 | { |
---|
32 | /** |
---|
33 | * Initializes TreeWalker with important information about the ASTs to be walked |
---|
34 | * |
---|
35 | * @param Query $query The parsed Query. |
---|
36 | * @param ParserResult $parserResult The result of the parsing process. |
---|
37 | * @param array $queryComponents Query components (symbol table) |
---|
38 | */ |
---|
39 | public function __construct($query, $parserResult, array $queryComponents); |
---|
40 | |
---|
41 | /** |
---|
42 | * Walks down a SelectStatement AST node, thereby generating the appropriate SQL. |
---|
43 | * |
---|
44 | * @return string The SQL. |
---|
45 | */ |
---|
46 | function walkSelectStatement(AST\SelectStatement $AST); |
---|
47 | |
---|
48 | /** |
---|
49 | * Walks down a SelectClause AST node, thereby generating the appropriate SQL. |
---|
50 | * |
---|
51 | * @return string The SQL. |
---|
52 | */ |
---|
53 | function walkSelectClause($selectClause); |
---|
54 | |
---|
55 | /** |
---|
56 | * Walks down a FromClause AST node, thereby generating the appropriate SQL. |
---|
57 | * |
---|
58 | * @return string The SQL. |
---|
59 | */ |
---|
60 | function walkFromClause($fromClause); |
---|
61 | |
---|
62 | /** |
---|
63 | * Walks down a FunctionNode AST node, thereby generating the appropriate SQL. |
---|
64 | * |
---|
65 | * @return string The SQL. |
---|
66 | */ |
---|
67 | function walkFunction($function); |
---|
68 | |
---|
69 | /** |
---|
70 | * Walks down an OrderByClause AST node, thereby generating the appropriate SQL. |
---|
71 | * |
---|
72 | * @param OrderByClause |
---|
73 | * @return string The SQL. |
---|
74 | */ |
---|
75 | function walkOrderByClause($orderByClause); |
---|
76 | |
---|
77 | /** |
---|
78 | * Walks down an OrderByItem AST node, thereby generating the appropriate SQL. |
---|
79 | * |
---|
80 | * @param OrderByItem |
---|
81 | * @return string The SQL. |
---|
82 | */ |
---|
83 | function walkOrderByItem($orderByItem); |
---|
84 | |
---|
85 | /** |
---|
86 | * Walks down a HavingClause AST node, thereby generating the appropriate SQL. |
---|
87 | * |
---|
88 | * @param HavingClause |
---|
89 | * @return string The SQL. |
---|
90 | */ |
---|
91 | function walkHavingClause($havingClause); |
---|
92 | |
---|
93 | /** |
---|
94 | * Walks down a JoinVariableDeclaration AST node and creates the corresponding SQL. |
---|
95 | * |
---|
96 | * @param JoinVariableDeclaration $joinVarDecl |
---|
97 | * @return string The SQL. |
---|
98 | */ |
---|
99 | function walkJoinVariableDeclaration($joinVarDecl); |
---|
100 | |
---|
101 | /** |
---|
102 | * Walks down a SelectExpression AST node and generates the corresponding SQL. |
---|
103 | * |
---|
104 | * @param SelectExpression $selectExpression |
---|
105 | * @return string The SQL. |
---|
106 | */ |
---|
107 | function walkSelectExpression($selectExpression); |
---|
108 | |
---|
109 | /** |
---|
110 | * Walks down a QuantifiedExpression AST node, thereby generating the appropriate SQL. |
---|
111 | * |
---|
112 | * @param QuantifiedExpression |
---|
113 | * @return string The SQL. |
---|
114 | */ |
---|
115 | function walkQuantifiedExpression($qExpr); |
---|
116 | |
---|
117 | /** |
---|
118 | * Walks down a Subselect AST node, thereby generating the appropriate SQL. |
---|
119 | * |
---|
120 | * @param Subselect |
---|
121 | * @return string The SQL. |
---|
122 | */ |
---|
123 | function walkSubselect($subselect); |
---|
124 | |
---|
125 | /** |
---|
126 | * Walks down a SubselectFromClause AST node, thereby generating the appropriate SQL. |
---|
127 | * |
---|
128 | * @param SubselectFromClause |
---|
129 | * @return string The SQL. |
---|
130 | */ |
---|
131 | function walkSubselectFromClause($subselectFromClause); |
---|
132 | |
---|
133 | /** |
---|
134 | * Walks down a SimpleSelectClause AST node, thereby generating the appropriate SQL. |
---|
135 | * |
---|
136 | * @param SimpleSelectClause |
---|
137 | * @return string The SQL. |
---|
138 | */ |
---|
139 | function walkSimpleSelectClause($simpleSelectClause); |
---|
140 | |
---|
141 | /** |
---|
142 | * Walks down a SimpleSelectExpression AST node, thereby generating the appropriate SQL. |
---|
143 | * |
---|
144 | * @param SimpleSelectExpression |
---|
145 | * @return string The SQL. |
---|
146 | */ |
---|
147 | function walkSimpleSelectExpression($simpleSelectExpression); |
---|
148 | |
---|
149 | /** |
---|
150 | * Walks down an AggregateExpression AST node, thereby generating the appropriate SQL. |
---|
151 | * |
---|
152 | * @param AggregateExpression |
---|
153 | * @return string The SQL. |
---|
154 | */ |
---|
155 | function walkAggregateExpression($aggExpression); |
---|
156 | |
---|
157 | /** |
---|
158 | * Walks down a GroupByClause AST node, thereby generating the appropriate SQL. |
---|
159 | * |
---|
160 | * @param GroupByClause |
---|
161 | * @return string The SQL. |
---|
162 | */ |
---|
163 | function walkGroupByClause($groupByClause); |
---|
164 | |
---|
165 | /** |
---|
166 | * Walks down a GroupByItem AST node, thereby generating the appropriate SQL. |
---|
167 | * |
---|
168 | * @param GroupByItem |
---|
169 | * @return string The SQL. |
---|
170 | */ |
---|
171 | function walkGroupByItem($groupByItem); |
---|
172 | |
---|
173 | /** |
---|
174 | * Walks down an UpdateStatement AST node, thereby generating the appropriate SQL. |
---|
175 | * |
---|
176 | * @param UpdateStatement |
---|
177 | * @return string The SQL. |
---|
178 | */ |
---|
179 | function walkUpdateStatement(AST\UpdateStatement $AST); |
---|
180 | |
---|
181 | /** |
---|
182 | * Walks down a DeleteStatement AST node, thereby generating the appropriate SQL. |
---|
183 | * |
---|
184 | * @param DeleteStatement |
---|
185 | * @return string The SQL. |
---|
186 | */ |
---|
187 | function walkDeleteStatement(AST\DeleteStatement $AST); |
---|
188 | |
---|
189 | /** |
---|
190 | * Walks down a DeleteClause AST node, thereby generating the appropriate SQL. |
---|
191 | * |
---|
192 | * @param DeleteClause |
---|
193 | * @return string The SQL. |
---|
194 | */ |
---|
195 | function walkDeleteClause(AST\DeleteClause $deleteClause); |
---|
196 | |
---|
197 | /** |
---|
198 | * Walks down an UpdateClause AST node, thereby generating the appropriate SQL. |
---|
199 | * |
---|
200 | * @param UpdateClause |
---|
201 | * @return string The SQL. |
---|
202 | */ |
---|
203 | function walkUpdateClause($updateClause); |
---|
204 | |
---|
205 | /** |
---|
206 | * Walks down an UpdateItem AST node, thereby generating the appropriate SQL. |
---|
207 | * |
---|
208 | * @param UpdateItem |
---|
209 | * @return string The SQL. |
---|
210 | */ |
---|
211 | function walkUpdateItem($updateItem); |
---|
212 | |
---|
213 | /** |
---|
214 | * Walks down a WhereClause AST node, thereby generating the appropriate SQL. |
---|
215 | * |
---|
216 | * @param WhereClause |
---|
217 | * @return string The SQL. |
---|
218 | */ |
---|
219 | function walkWhereClause($whereClause); |
---|
220 | |
---|
221 | /** |
---|
222 | * Walks down a ConditionalExpression AST node, thereby generating the appropriate SQL. |
---|
223 | * |
---|
224 | * @param ConditionalExpression |
---|
225 | * @return string The SQL. |
---|
226 | */ |
---|
227 | function walkConditionalExpression($condExpr); |
---|
228 | |
---|
229 | /** |
---|
230 | * Walks down a ConditionalTerm AST node, thereby generating the appropriate SQL. |
---|
231 | * |
---|
232 | * @param ConditionalTerm |
---|
233 | * @return string The SQL. |
---|
234 | */ |
---|
235 | function walkConditionalTerm($condTerm); |
---|
236 | |
---|
237 | /** |
---|
238 | * Walks down a ConditionalFactor AST node, thereby generating the appropriate SQL. |
---|
239 | * |
---|
240 | * @param ConditionalFactor |
---|
241 | * @return string The SQL. |
---|
242 | */ |
---|
243 | function walkConditionalFactor($factor); |
---|
244 | |
---|
245 | /** |
---|
246 | * Walks down a ConditionalPrimary AST node, thereby generating the appropriate SQL. |
---|
247 | * |
---|
248 | * @param ConditionalPrimary |
---|
249 | * @return string The SQL. |
---|
250 | */ |
---|
251 | function walkConditionalPrimary($primary); |
---|
252 | |
---|
253 | /** |
---|
254 | * Walks down an ExistsExpression AST node, thereby generating the appropriate SQL. |
---|
255 | * |
---|
256 | * @param ExistsExpression |
---|
257 | * @return string The SQL. |
---|
258 | */ |
---|
259 | function walkExistsExpression($existsExpr); |
---|
260 | |
---|
261 | /** |
---|
262 | * Walks down a CollectionMemberExpression AST node, thereby generating the appropriate SQL. |
---|
263 | * |
---|
264 | * @param CollectionMemberExpression |
---|
265 | * @return string The SQL. |
---|
266 | */ |
---|
267 | function walkCollectionMemberExpression($collMemberExpr); |
---|
268 | |
---|
269 | /** |
---|
270 | * Walks down an EmptyCollectionComparisonExpression AST node, thereby generating the appropriate SQL. |
---|
271 | * |
---|
272 | * @param EmptyCollectionComparisonExpression |
---|
273 | * @return string The SQL. |
---|
274 | */ |
---|
275 | function walkEmptyCollectionComparisonExpression($emptyCollCompExpr); |
---|
276 | |
---|
277 | /** |
---|
278 | * Walks down a NullComparisonExpression AST node, thereby generating the appropriate SQL. |
---|
279 | * |
---|
280 | * @param NullComparisonExpression |
---|
281 | * @return string The SQL. |
---|
282 | */ |
---|
283 | function walkNullComparisonExpression($nullCompExpr); |
---|
284 | |
---|
285 | /** |
---|
286 | * Walks down an InExpression AST node, thereby generating the appropriate SQL. |
---|
287 | * |
---|
288 | * @param InExpression |
---|
289 | * @return string The SQL. |
---|
290 | */ |
---|
291 | function walkInExpression($inExpr); |
---|
292 | |
---|
293 | /** |
---|
294 | * Walks down an InstanceOfExpression AST node, thereby generating the appropriate SQL. |
---|
295 | * |
---|
296 | * @param InstanceOfExpression |
---|
297 | * @return string The SQL. |
---|
298 | */ |
---|
299 | function walkInstanceOfExpression($instanceOfExpr); |
---|
300 | |
---|
301 | /** |
---|
302 | * Walks down a literal that represents an AST node, thereby generating the appropriate SQL. |
---|
303 | * |
---|
304 | * @param mixed |
---|
305 | * @return string The SQL. |
---|
306 | */ |
---|
307 | function walkLiteral($literal); |
---|
308 | |
---|
309 | /** |
---|
310 | * Walks down a BetweenExpression AST node, thereby generating the appropriate SQL. |
---|
311 | * |
---|
312 | * @param BetweenExpression |
---|
313 | * @return string The SQL. |
---|
314 | */ |
---|
315 | function walkBetweenExpression($betweenExpr); |
---|
316 | |
---|
317 | /** |
---|
318 | * Walks down a LikeExpression AST node, thereby generating the appropriate SQL. |
---|
319 | * |
---|
320 | * @param LikeExpression |
---|
321 | * @return string The SQL. |
---|
322 | */ |
---|
323 | function walkLikeExpression($likeExpr); |
---|
324 | |
---|
325 | /** |
---|
326 | * Walks down a StateFieldPathExpression AST node, thereby generating the appropriate SQL. |
---|
327 | * |
---|
328 | * @param StateFieldPathExpression |
---|
329 | * @return string The SQL. |
---|
330 | */ |
---|
331 | function walkStateFieldPathExpression($stateFieldPathExpression); |
---|
332 | |
---|
333 | /** |
---|
334 | * Walks down a ComparisonExpression AST node, thereby generating the appropriate SQL. |
---|
335 | * |
---|
336 | * @param ComparisonExpression |
---|
337 | * @return string The SQL. |
---|
338 | */ |
---|
339 | function walkComparisonExpression($compExpr); |
---|
340 | |
---|
341 | /** |
---|
342 | * Walks down an InputParameter AST node, thereby generating the appropriate SQL. |
---|
343 | * |
---|
344 | * @param InputParameter |
---|
345 | * @return string The SQL. |
---|
346 | */ |
---|
347 | function walkInputParameter($inputParam); |
---|
348 | |
---|
349 | /** |
---|
350 | * Walks down an ArithmeticExpression AST node, thereby generating the appropriate SQL. |
---|
351 | * |
---|
352 | * @param ArithmeticExpression |
---|
353 | * @return string The SQL. |
---|
354 | */ |
---|
355 | function walkArithmeticExpression($arithmeticExpr); |
---|
356 | |
---|
357 | /** |
---|
358 | * Walks down an ArithmeticTerm AST node, thereby generating the appropriate SQL. |
---|
359 | * |
---|
360 | * @param mixed |
---|
361 | * @return string The SQL. |
---|
362 | */ |
---|
363 | function walkArithmeticTerm($term); |
---|
364 | |
---|
365 | /** |
---|
366 | * Walks down a StringPrimary that represents an AST node, thereby generating the appropriate SQL. |
---|
367 | * |
---|
368 | * @param mixed |
---|
369 | * @return string The SQL. |
---|
370 | */ |
---|
371 | function walkStringPrimary($stringPrimary); |
---|
372 | |
---|
373 | /** |
---|
374 | * Walks down an ArithmeticFactor that represents an AST node, thereby generating the appropriate SQL. |
---|
375 | * |
---|
376 | * @param mixed |
---|
377 | * @return string The SQL. |
---|
378 | */ |
---|
379 | function walkArithmeticFactor($factor); |
---|
380 | |
---|
381 | /** |
---|
382 | * Walks down an SimpleArithmeticExpression AST node, thereby generating the appropriate SQL. |
---|
383 | * |
---|
384 | * @param SimpleArithmeticExpression |
---|
385 | * @return string The SQL. |
---|
386 | */ |
---|
387 | function walkSimpleArithmeticExpression($simpleArithmeticExpr); |
---|
388 | |
---|
389 | /** |
---|
390 | * Walks down an PathExpression AST node, thereby generating the appropriate SQL. |
---|
391 | * |
---|
392 | * @param mixed |
---|
393 | * @return string The SQL. |
---|
394 | */ |
---|
395 | function walkPathExpression($pathExpr); |
---|
396 | |
---|
397 | /** |
---|
398 | * Walks down an ResultVariable AST node, thereby generating the appropriate SQL. |
---|
399 | * |
---|
400 | * @param string $resultVariable |
---|
401 | * @return string The SQL. |
---|
402 | */ |
---|
403 | function walkResultVariable($resultVariable); |
---|
404 | |
---|
405 | /** |
---|
406 | * Gets an executor that can be used to execute the result of this walker. |
---|
407 | * |
---|
408 | * @return AbstractExecutor |
---|
409 | */ |
---|
410 | function getExecutor($AST); |
---|
411 | } |
---|