TreeWalkerAdapter.php 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  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. namespace Doctrine\ORM\Query;
  20. use Doctrine\ORM\AbstractQuery;
  21. use Doctrine\ORM\Mapping\ClassMetadata;
  22. use function array_diff;
  23. use function array_keys;
  24. /**
  25. * An adapter implementation of the TreeWalker interface. The methods in this class
  26. * are empty. This class exists as convenience for creating tree walkers.
  27. */
  28. abstract class TreeWalkerAdapter implements TreeWalker
  29. {
  30. /**
  31. * The original Query.
  32. *
  33. * @var AbstractQuery
  34. */
  35. private $_query;
  36. /**
  37. * The ParserResult of the original query that was produced by the Parser.
  38. *
  39. * @var ParserResult
  40. */
  41. private $_parserResult;
  42. /**
  43. * The query components of the original query (the "symbol table") that was produced by the Parser.
  44. *
  45. * @psalm-var array<string, array{
  46. * metadata: ClassMetadata,
  47. * parent: string,
  48. * relation: mixed[],
  49. * map: mixed,
  50. * nestingLevel: int,
  51. * token: array
  52. * }>
  53. */
  54. private $_queryComponents;
  55. /**
  56. * {@inheritdoc}
  57. */
  58. public function __construct($query, $parserResult, array $queryComponents)
  59. {
  60. $this->_query = $query;
  61. $this->_parserResult = $parserResult;
  62. $this->_queryComponents = $queryComponents;
  63. }
  64. /**
  65. * {@inheritdoc}
  66. */
  67. public function getQueryComponents()
  68. {
  69. return $this->_queryComponents;
  70. }
  71. /**
  72. * {@inheritdoc}
  73. */
  74. public function setQueryComponent($dqlAlias, array $queryComponent)
  75. {
  76. $requiredKeys = ['metadata', 'parent', 'relation', 'map', 'nestingLevel', 'token'];
  77. if (array_diff($requiredKeys, array_keys($queryComponent))) {
  78. throw QueryException::invalidQueryComponent($dqlAlias);
  79. }
  80. $this->_queryComponents[$dqlAlias] = $queryComponent;
  81. }
  82. /**
  83. * {@inheritDoc}
  84. */
  85. protected function _getQueryComponents()
  86. {
  87. return $this->_queryComponents;
  88. }
  89. /**
  90. * Retrieves the Query Instance responsible for the current walkers execution.
  91. *
  92. * @return AbstractQuery
  93. */
  94. protected function _getQuery()
  95. {
  96. return $this->_query;
  97. }
  98. /**
  99. * Retrieves the ParserResult.
  100. *
  101. * @return ParserResult
  102. */
  103. protected function _getParserResult()
  104. {
  105. return $this->_parserResult;
  106. }
  107. /**
  108. * {@inheritdoc}
  109. *
  110. * @return void
  111. */
  112. public function walkSelectStatement(AST\SelectStatement $AST)
  113. {
  114. }
  115. /**
  116. * {@inheritdoc}
  117. *
  118. * @return void
  119. */
  120. public function walkSelectClause($selectClause)
  121. {
  122. }
  123. /**
  124. * {@inheritdoc}
  125. *
  126. * @return void
  127. */
  128. public function walkFromClause($fromClause)
  129. {
  130. }
  131. /**
  132. * {@inheritdoc}
  133. *
  134. * @return void
  135. */
  136. public function walkFunction($function)
  137. {
  138. }
  139. /**
  140. * {@inheritdoc}
  141. *
  142. * @return void
  143. */
  144. public function walkOrderByClause($orderByClause)
  145. {
  146. }
  147. /**
  148. * {@inheritdoc}
  149. *
  150. * @return void
  151. */
  152. public function walkOrderByItem($orderByItem)
  153. {
  154. }
  155. /**
  156. * {@inheritdoc}
  157. *
  158. * @return void
  159. */
  160. public function walkHavingClause($havingClause)
  161. {
  162. }
  163. /**
  164. * {@inheritdoc}
  165. *
  166. * @return void
  167. */
  168. public function walkJoin($join)
  169. {
  170. }
  171. /**
  172. * {@inheritdoc}
  173. *
  174. * @return void
  175. */
  176. public function walkSelectExpression($selectExpression)
  177. {
  178. }
  179. /**
  180. * {@inheritdoc}
  181. *
  182. * @return void
  183. */
  184. public function walkQuantifiedExpression($qExpr)
  185. {
  186. }
  187. /**
  188. * {@inheritdoc}
  189. *
  190. * @return void
  191. */
  192. public function walkSubselect($subselect)
  193. {
  194. }
  195. /**
  196. * {@inheritdoc}
  197. *
  198. * @return void
  199. */
  200. public function walkSubselectFromClause($subselectFromClause)
  201. {
  202. }
  203. /**
  204. * {@inheritdoc}
  205. *
  206. * @return void
  207. */
  208. public function walkSimpleSelectClause($simpleSelectClause)
  209. {
  210. }
  211. /**
  212. * {@inheritdoc}
  213. *
  214. * @return void
  215. */
  216. public function walkSimpleSelectExpression($simpleSelectExpression)
  217. {
  218. }
  219. /**
  220. * {@inheritdoc}
  221. *
  222. * @return void
  223. */
  224. public function walkAggregateExpression($aggExpression)
  225. {
  226. }
  227. /**
  228. * {@inheritdoc}
  229. *
  230. * @return void
  231. */
  232. public function walkGroupByClause($groupByClause)
  233. {
  234. }
  235. /**
  236. * {@inheritdoc}
  237. *
  238. * @return void
  239. */
  240. public function walkGroupByItem($groupByItem)
  241. {
  242. }
  243. /**
  244. * {@inheritdoc}
  245. *
  246. * @return void
  247. */
  248. public function walkUpdateStatement(AST\UpdateStatement $AST)
  249. {
  250. }
  251. /**
  252. * {@inheritdoc}
  253. *
  254. * @return void
  255. */
  256. public function walkDeleteStatement(AST\DeleteStatement $AST)
  257. {
  258. }
  259. /**
  260. * {@inheritdoc}
  261. *
  262. * @return void
  263. */
  264. public function walkDeleteClause(AST\DeleteClause $deleteClause)
  265. {
  266. }
  267. /**
  268. * {@inheritdoc}
  269. *
  270. * @return void
  271. */
  272. public function walkUpdateClause($updateClause)
  273. {
  274. }
  275. /**
  276. * {@inheritdoc}
  277. *
  278. * @return void
  279. */
  280. public function walkUpdateItem($updateItem)
  281. {
  282. }
  283. /**
  284. * {@inheritdoc}
  285. *
  286. * @return void
  287. */
  288. public function walkWhereClause($whereClause)
  289. {
  290. }
  291. /**
  292. * {@inheritdoc}
  293. *
  294. * @return void
  295. */
  296. public function walkConditionalExpression($condExpr)
  297. {
  298. }
  299. /**
  300. * {@inheritdoc}
  301. *
  302. * @return void
  303. */
  304. public function walkConditionalTerm($condTerm)
  305. {
  306. }
  307. /**
  308. * {@inheritdoc}
  309. *
  310. * @return void
  311. */
  312. public function walkConditionalFactor($factor)
  313. {
  314. }
  315. /**
  316. * {@inheritdoc}
  317. *
  318. * @return void
  319. */
  320. public function walkConditionalPrimary($primary)
  321. {
  322. }
  323. /**
  324. * {@inheritdoc}
  325. *
  326. * @return void
  327. */
  328. public function walkExistsExpression($existsExpr)
  329. {
  330. }
  331. /**
  332. * {@inheritdoc}
  333. *
  334. * @return void
  335. */
  336. public function walkCollectionMemberExpression($collMemberExpr)
  337. {
  338. }
  339. /**
  340. * {@inheritdoc}
  341. *
  342. * @return void
  343. */
  344. public function walkEmptyCollectionComparisonExpression($emptyCollCompExpr)
  345. {
  346. }
  347. /**
  348. * {@inheritdoc}
  349. *
  350. * @return void
  351. */
  352. public function walkNullComparisonExpression($nullCompExpr)
  353. {
  354. }
  355. /**
  356. * {@inheritdoc}
  357. *
  358. * @return void
  359. */
  360. public function walkInExpression($inExpr)
  361. {
  362. }
  363. /**
  364. * {@inheritdoc}
  365. *
  366. * @return void
  367. */
  368. public function walkInstanceOfExpression($instanceOfExpr)
  369. {
  370. }
  371. /**
  372. * {@inheritdoc}
  373. *
  374. * @return void
  375. */
  376. public function walkLiteral($literal)
  377. {
  378. }
  379. /**
  380. * {@inheritdoc}
  381. *
  382. * @return void
  383. */
  384. public function walkBetweenExpression($betweenExpr)
  385. {
  386. }
  387. /**
  388. * {@inheritdoc}
  389. *
  390. * @return void
  391. */
  392. public function walkLikeExpression($likeExpr)
  393. {
  394. }
  395. /**
  396. * {@inheritdoc}
  397. *
  398. * @return void
  399. */
  400. public function walkStateFieldPathExpression($stateFieldPathExpression)
  401. {
  402. }
  403. /**
  404. * {@inheritdoc}
  405. *
  406. * @return void
  407. */
  408. public function walkComparisonExpression($compExpr)
  409. {
  410. }
  411. /**
  412. * {@inheritdoc}
  413. *
  414. * @return void
  415. */
  416. public function walkInputParameter($inputParam)
  417. {
  418. }
  419. /**
  420. * {@inheritdoc}
  421. *
  422. * @return void
  423. */
  424. public function walkArithmeticExpression($arithmeticExpr)
  425. {
  426. }
  427. /**
  428. * {@inheritdoc}
  429. *
  430. * @return void
  431. */
  432. public function walkArithmeticTerm($term)
  433. {
  434. }
  435. /**
  436. * {@inheritdoc}
  437. *
  438. * @return void
  439. */
  440. public function walkStringPrimary($stringPrimary)
  441. {
  442. }
  443. /**
  444. * {@inheritdoc}
  445. *
  446. * @return void
  447. */
  448. public function walkArithmeticFactor($factor)
  449. {
  450. }
  451. /**
  452. * {@inheritdoc}
  453. *
  454. * @return void
  455. */
  456. public function walkSimpleArithmeticExpression($simpleArithmeticExpr)
  457. {
  458. }
  459. /**
  460. * {@inheritdoc}
  461. *
  462. * @return void
  463. */
  464. public function walkPathExpression($pathExpr)
  465. {
  466. }
  467. /**
  468. * {@inheritdoc}
  469. *
  470. * @return void
  471. */
  472. public function walkResultVariable($resultVariable)
  473. {
  474. }
  475. /**
  476. * {@inheritdoc}
  477. *
  478. * @return void
  479. */
  480. public function getExecutor($AST)
  481. {
  482. }
  483. }