TreeWalker.php 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  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. namespace Doctrine\ORM\Query;
  22. /**
  23. * Interface for walkers of DQL ASTs (abstract syntax trees).
  24. *
  25. * @author Roman Borschel <roman@code-factory.org>
  26. * @since 2.0
  27. */
  28. interface TreeWalker
  29. {
  30. /**
  31. * Initializes TreeWalker with important information about the ASTs to be walked
  32. *
  33. * @param Query $query The parsed Query.
  34. * @param ParserResult $parserResult The result of the parsing process.
  35. * @param array $queryComponents Query components (symbol table)
  36. */
  37. public function __construct($query, $parserResult, array $queryComponents);
  38. /**
  39. * Walks down a SelectStatement AST node, thereby generating the appropriate SQL.
  40. *
  41. * @return string The SQL.
  42. */
  43. function walkSelectStatement(AST\SelectStatement $AST);
  44. /**
  45. * Walks down a SelectClause AST node, thereby generating the appropriate SQL.
  46. *
  47. * @return string The SQL.
  48. */
  49. function walkSelectClause($selectClause);
  50. /**
  51. * Walks down a FromClause AST node, thereby generating the appropriate SQL.
  52. *
  53. * @return string The SQL.
  54. */
  55. function walkFromClause($fromClause);
  56. /**
  57. * Walks down a FunctionNode AST node, thereby generating the appropriate SQL.
  58. *
  59. * @return string The SQL.
  60. */
  61. function walkFunction($function);
  62. /**
  63. * Walks down an OrderByClause AST node, thereby generating the appropriate SQL.
  64. *
  65. * @param OrderByClause
  66. * @return string The SQL.
  67. */
  68. function walkOrderByClause($orderByClause);
  69. /**
  70. * Walks down an OrderByItem AST node, thereby generating the appropriate SQL.
  71. *
  72. * @param OrderByItem
  73. * @return string The SQL.
  74. */
  75. function walkOrderByItem($orderByItem);
  76. /**
  77. * Walks down a HavingClause AST node, thereby generating the appropriate SQL.
  78. *
  79. * @param HavingClause
  80. * @return string The SQL.
  81. */
  82. function walkHavingClause($havingClause);
  83. /**
  84. * Walks down a JoinVariableDeclaration AST node and creates the corresponding SQL.
  85. *
  86. * @param JoinVariableDeclaration $joinVarDecl
  87. * @return string The SQL.
  88. */
  89. function walkJoinVariableDeclaration($joinVarDecl);
  90. /**
  91. * Walks down a SelectExpression AST node and generates the corresponding SQL.
  92. *
  93. * @param SelectExpression $selectExpression
  94. * @return string The SQL.
  95. */
  96. function walkSelectExpression($selectExpression);
  97. /**
  98. * Walks down a QuantifiedExpression AST node, thereby generating the appropriate SQL.
  99. *
  100. * @param QuantifiedExpression
  101. * @return string The SQL.
  102. */
  103. function walkQuantifiedExpression($qExpr);
  104. /**
  105. * Walks down a Subselect AST node, thereby generating the appropriate SQL.
  106. *
  107. * @param Subselect
  108. * @return string The SQL.
  109. */
  110. function walkSubselect($subselect);
  111. /**
  112. * Walks down a SubselectFromClause AST node, thereby generating the appropriate SQL.
  113. *
  114. * @param SubselectFromClause
  115. * @return string The SQL.
  116. */
  117. function walkSubselectFromClause($subselectFromClause);
  118. /**
  119. * Walks down a SimpleSelectClause AST node, thereby generating the appropriate SQL.
  120. *
  121. * @param SimpleSelectClause
  122. * @return string The SQL.
  123. */
  124. function walkSimpleSelectClause($simpleSelectClause);
  125. /**
  126. * Walks down a SimpleSelectExpression AST node, thereby generating the appropriate SQL.
  127. *
  128. * @param SimpleSelectExpression
  129. * @return string The SQL.
  130. */
  131. function walkSimpleSelectExpression($simpleSelectExpression);
  132. /**
  133. * Walks down an AggregateExpression AST node, thereby generating the appropriate SQL.
  134. *
  135. * @param AggregateExpression
  136. * @return string The SQL.
  137. */
  138. function walkAggregateExpression($aggExpression);
  139. /**
  140. * Walks down a GroupByClause AST node, thereby generating the appropriate SQL.
  141. *
  142. * @param GroupByClause
  143. * @return string The SQL.
  144. */
  145. function walkGroupByClause($groupByClause);
  146. /**
  147. * Walks down a GroupByItem AST node, thereby generating the appropriate SQL.
  148. *
  149. * @param GroupByItem
  150. * @return string The SQL.
  151. */
  152. function walkGroupByItem(AST\PathExpression $pathExpr);
  153. /**
  154. * Walks down an UpdateStatement AST node, thereby generating the appropriate SQL.
  155. *
  156. * @param UpdateStatement
  157. * @return string The SQL.
  158. */
  159. function walkUpdateStatement(AST\UpdateStatement $AST);
  160. /**
  161. * Walks down a DeleteStatement AST node, thereby generating the appropriate SQL.
  162. *
  163. * @param DeleteStatement
  164. * @return string The SQL.
  165. */
  166. function walkDeleteStatement(AST\DeleteStatement $AST);
  167. /**
  168. * Walks down a DeleteClause AST node, thereby generating the appropriate SQL.
  169. *
  170. * @param DeleteClause
  171. * @return string The SQL.
  172. */
  173. function walkDeleteClause(AST\DeleteClause $deleteClause);
  174. /**
  175. * Walks down an UpdateClause AST node, thereby generating the appropriate SQL.
  176. *
  177. * @param UpdateClause
  178. * @return string The SQL.
  179. */
  180. function walkUpdateClause($updateClause);
  181. /**
  182. * Walks down an UpdateItem AST node, thereby generating the appropriate SQL.
  183. *
  184. * @param UpdateItem
  185. * @return string The SQL.
  186. */
  187. function walkUpdateItem($updateItem);
  188. /**
  189. * Walks down a WhereClause AST node, thereby generating the appropriate SQL.
  190. *
  191. * @param WhereClause
  192. * @return string The SQL.
  193. */
  194. function walkWhereClause($whereClause);
  195. /**
  196. * Walks down a ConditionalExpression AST node, thereby generating the appropriate SQL.
  197. *
  198. * @param ConditionalExpression
  199. * @return string The SQL.
  200. */
  201. function walkConditionalExpression($condExpr);
  202. /**
  203. * Walks down a ConditionalTerm AST node, thereby generating the appropriate SQL.
  204. *
  205. * @param ConditionalTerm
  206. * @return string The SQL.
  207. */
  208. function walkConditionalTerm($condTerm);
  209. /**
  210. * Walks down a ConditionalFactor AST node, thereby generating the appropriate SQL.
  211. *
  212. * @param ConditionalFactor
  213. * @return string The SQL.
  214. */
  215. function walkConditionalFactor($factor);
  216. /**
  217. * Walks down a ConditionalPrimary AST node, thereby generating the appropriate SQL.
  218. *
  219. * @param ConditionalPrimary
  220. * @return string The SQL.
  221. */
  222. function walkConditionalPrimary($primary);
  223. /**
  224. * Walks down an ExistsExpression AST node, thereby generating the appropriate SQL.
  225. *
  226. * @param ExistsExpression
  227. * @return string The SQL.
  228. */
  229. function walkExistsExpression($existsExpr);
  230. /**
  231. * Walks down a CollectionMemberExpression AST node, thereby generating the appropriate SQL.
  232. *
  233. * @param CollectionMemberExpression
  234. * @return string The SQL.
  235. */
  236. function walkCollectionMemberExpression($collMemberExpr);
  237. /**
  238. * Walks down an EmptyCollectionComparisonExpression AST node, thereby generating the appropriate SQL.
  239. *
  240. * @param EmptyCollectionComparisonExpression
  241. * @return string The SQL.
  242. */
  243. function walkEmptyCollectionComparisonExpression($emptyCollCompExpr);
  244. /**
  245. * Walks down a NullComparisonExpression AST node, thereby generating the appropriate SQL.
  246. *
  247. * @param NullComparisonExpression
  248. * @return string The SQL.
  249. */
  250. function walkNullComparisonExpression($nullCompExpr);
  251. /**
  252. * Walks down an InExpression AST node, thereby generating the appropriate SQL.
  253. *
  254. * @param InExpression
  255. * @return string The SQL.
  256. */
  257. function walkInExpression($inExpr);
  258. /**
  259. * Walks down an InstanceOfExpression AST node, thereby generating the appropriate SQL.
  260. *
  261. * @param InstanceOfExpression
  262. * @return string The SQL.
  263. */
  264. function walkInstanceOfExpression($instanceOfExpr);
  265. /**
  266. * Walks down a literal that represents an AST node, thereby generating the appropriate SQL.
  267. *
  268. * @param mixed
  269. * @return string The SQL.
  270. */
  271. function walkLiteral($literal);
  272. /**
  273. * Walks down a BetweenExpression AST node, thereby generating the appropriate SQL.
  274. *
  275. * @param BetweenExpression
  276. * @return string The SQL.
  277. */
  278. function walkBetweenExpression($betweenExpr);
  279. /**
  280. * Walks down a LikeExpression AST node, thereby generating the appropriate SQL.
  281. *
  282. * @param LikeExpression
  283. * @return string The SQL.
  284. */
  285. function walkLikeExpression($likeExpr);
  286. /**
  287. * Walks down a StateFieldPathExpression AST node, thereby generating the appropriate SQL.
  288. *
  289. * @param StateFieldPathExpression
  290. * @return string The SQL.
  291. */
  292. function walkStateFieldPathExpression($stateFieldPathExpression);
  293. /**
  294. * Walks down a ComparisonExpression AST node, thereby generating the appropriate SQL.
  295. *
  296. * @param ComparisonExpression
  297. * @return string The SQL.
  298. */
  299. function walkComparisonExpression($compExpr);
  300. /**
  301. * Walks down an InputParameter AST node, thereby generating the appropriate SQL.
  302. *
  303. * @param InputParameter
  304. * @return string The SQL.
  305. */
  306. function walkInputParameter($inputParam);
  307. /**
  308. * Walks down an ArithmeticExpression AST node, thereby generating the appropriate SQL.
  309. *
  310. * @param ArithmeticExpression
  311. * @return string The SQL.
  312. */
  313. function walkArithmeticExpression($arithmeticExpr);
  314. /**
  315. * Walks down an ArithmeticTerm AST node, thereby generating the appropriate SQL.
  316. *
  317. * @param mixed
  318. * @return string The SQL.
  319. */
  320. function walkArithmeticTerm($term);
  321. /**
  322. * Walks down a StringPrimary that represents an AST node, thereby generating the appropriate SQL.
  323. *
  324. * @param mixed
  325. * @return string The SQL.
  326. */
  327. function walkStringPrimary($stringPrimary);
  328. /**
  329. * Walks down an ArithmeticFactor that represents an AST node, thereby generating the appropriate SQL.
  330. *
  331. * @param mixed
  332. * @return string The SQL.
  333. */
  334. function walkArithmeticFactor($factor);
  335. /**
  336. * Walks down an SimpleArithmeticExpression AST node, thereby generating the appropriate SQL.
  337. *
  338. * @param SimpleArithmeticExpression
  339. * @return string The SQL.
  340. */
  341. function walkSimpleArithmeticExpression($simpleArithmeticExpr);
  342. /**
  343. * Walks down an PathExpression AST node, thereby generating the appropriate SQL.
  344. *
  345. * @param mixed
  346. * @return string The SQL.
  347. */
  348. function walkPathExpression($pathExpr);
  349. /**
  350. * Gets an executor that can be used to execute the result of this walker.
  351. *
  352. * @return AbstractExecutor
  353. */
  354. function getExecutor($AST);
  355. }