Complex classes like SqlWalker often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use SqlWalker, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
42 | class SqlWalker implements TreeWalker |
||
43 | { |
||
44 | /** |
||
45 | * @var string |
||
46 | */ |
||
47 | const HINT_DISTINCT = 'doctrine.distinct'; |
||
48 | |||
49 | /** |
||
50 | * @var ResultSetMapping |
||
51 | */ |
||
52 | private $rsm; |
||
53 | |||
54 | /** |
||
55 | * Counter for generating unique column aliases. |
||
56 | * |
||
57 | * @var integer |
||
58 | */ |
||
59 | private $aliasCounter = 0; |
||
60 | |||
61 | /** |
||
62 | * Counter for generating unique table aliases. |
||
63 | * |
||
64 | * @var integer |
||
65 | */ |
||
66 | private $tableAliasCounter = 0; |
||
67 | |||
68 | /** |
||
69 | * Counter for generating unique scalar result. |
||
70 | * |
||
71 | * @var integer |
||
72 | */ |
||
73 | private $scalarResultCounter = 1; |
||
74 | |||
75 | /** |
||
76 | * Counter for generating unique parameter indexes. |
||
77 | * |
||
78 | * @var integer |
||
79 | */ |
||
80 | private $sqlParamIndex = 0; |
||
81 | |||
82 | /** |
||
83 | * Counter for generating indexes. |
||
84 | * |
||
85 | * @var integer |
||
86 | */ |
||
87 | private $newObjectCounter = 0; |
||
88 | |||
89 | /** |
||
90 | * @var ParserResult |
||
91 | */ |
||
92 | private $parserResult; |
||
93 | |||
94 | /** |
||
95 | * @var \Doctrine\ORM\EntityManager |
||
96 | */ |
||
97 | private $em; |
||
98 | |||
99 | /** |
||
100 | * @var \Doctrine\DBAL\Connection |
||
101 | */ |
||
102 | private $conn; |
||
103 | |||
104 | /** |
||
105 | * @var \Doctrine\ORM\AbstractQuery |
||
106 | */ |
||
107 | private $query; |
||
108 | |||
109 | /** |
||
110 | * @var array |
||
111 | */ |
||
112 | private $tableAliasMap = array(); |
||
113 | |||
114 | /** |
||
115 | * Map from result variable names to their SQL column alias names. |
||
116 | * |
||
117 | * @var array |
||
118 | */ |
||
119 | private $scalarResultAliasMap = array(); |
||
120 | |||
121 | /** |
||
122 | * Map from Table-Alias + Column-Name to OrderBy-Direction. |
||
123 | * |
||
124 | * @var array |
||
125 | */ |
||
126 | private $orderedColumnsMap = array(); |
||
127 | |||
128 | /** |
||
129 | * Map from DQL-Alias + Field-Name to SQL Column Alias. |
||
130 | * |
||
131 | * @var array |
||
132 | */ |
||
133 | private $scalarFields = array(); |
||
134 | |||
135 | /** |
||
136 | * Map of all components/classes that appear in the DQL query. |
||
137 | * |
||
138 | * @var array |
||
139 | */ |
||
140 | private $queryComponents; |
||
141 | |||
142 | /** |
||
143 | * A list of classes that appear in non-scalar SelectExpressions. |
||
144 | * |
||
145 | * @var array |
||
146 | */ |
||
147 | private $selectedClasses = array(); |
||
148 | |||
149 | /** |
||
150 | * The DQL alias of the root class of the currently traversed query. |
||
151 | * |
||
152 | * @var array |
||
153 | */ |
||
154 | private $rootAliases = array(); |
||
155 | |||
156 | /** |
||
157 | * Flag that indicates whether to generate SQL table aliases in the SQL. |
||
158 | * These should only be generated for SELECT queries, not for UPDATE/DELETE. |
||
159 | * |
||
160 | * @var boolean |
||
161 | */ |
||
162 | private $useSqlTableAliases = true; |
||
163 | |||
164 | /** |
||
165 | * The database platform abstraction. |
||
166 | * |
||
167 | * @var \Doctrine\DBAL\Platforms\AbstractPlatform |
||
168 | */ |
||
169 | private $platform; |
||
170 | |||
171 | /** |
||
172 | * The quote strategy. |
||
173 | * |
||
174 | * @var \Doctrine\ORM\Mapping\QuoteStrategy |
||
175 | */ |
||
176 | private $quoteStrategy; |
||
177 | |||
178 | /** |
||
179 | * {@inheritDoc} |
||
180 | */ |
||
181 | 679 | public function __construct($query, $parserResult, array $queryComponents) |
|
192 | |||
193 | /** |
||
194 | * Gets the Query instance used by the walker. |
||
195 | * |
||
196 | * @return Query. |
||
|
|||
197 | */ |
||
198 | public function getQuery() |
||
202 | |||
203 | /** |
||
204 | * Gets the Connection used by the walker. |
||
205 | * |
||
206 | * @return \Doctrine\DBAL\Connection |
||
207 | */ |
||
208 | 35 | public function getConnection() |
|
212 | |||
213 | /** |
||
214 | * Gets the EntityManager used by the walker. |
||
215 | * |
||
216 | * @return \Doctrine\ORM\EntityManager |
||
217 | */ |
||
218 | 23 | public function getEntityManager() |
|
222 | |||
223 | /** |
||
224 | * Gets the information about a single query component. |
||
225 | * |
||
226 | * @param string $dqlAlias The DQL alias. |
||
227 | * |
||
228 | * @return array |
||
229 | */ |
||
230 | 18 | public function getQueryComponent($dqlAlias) |
|
234 | |||
235 | /** |
||
236 | * {@inheritdoc} |
||
237 | */ |
||
238 | public function getQueryComponents() |
||
242 | |||
243 | /** |
||
244 | * {@inheritdoc} |
||
245 | */ |
||
246 | 1 | public function setQueryComponent($dqlAlias, array $queryComponent) |
|
256 | |||
257 | /** |
||
258 | * {@inheritdoc} |
||
259 | */ |
||
260 | 673 | public function getExecutor($AST) |
|
281 | |||
282 | /** |
||
283 | * Generates a unique, short SQL table alias. |
||
284 | * |
||
285 | * @param string $tableName Table name |
||
286 | * @param string $dqlAlias The DQL alias. |
||
287 | * |
||
288 | * @return string Generated table alias. |
||
289 | */ |
||
290 | 625 | public function getSQLTableAlias($tableName, $dqlAlias = '') |
|
301 | |||
302 | /** |
||
303 | * Forces the SqlWalker to use a specific alias for a table name, rather than |
||
304 | * generating an alias on its own. |
||
305 | * |
||
306 | * @param string $tableName |
||
307 | * @param string $alias |
||
308 | * @param string $dqlAlias |
||
309 | * |
||
310 | * @return string |
||
311 | */ |
||
312 | 65 | public function setSQLTableAlias($tableName, $alias, $dqlAlias = '') |
|
320 | |||
321 | /** |
||
322 | * Gets an SQL column alias for a column name. |
||
323 | * |
||
324 | * @param string $columnName |
||
325 | * |
||
326 | * @return string |
||
327 | */ |
||
328 | 613 | public function getSQLColumnAlias($columnName) |
|
332 | |||
333 | /** |
||
334 | * Generates the SQL JOINs that are necessary for Class Table Inheritance |
||
335 | * for the given class. |
||
336 | * |
||
337 | * @param ClassMetadata $class The class for which to generate the joins. |
||
338 | * @param string $dqlAlias The DQL alias of the class. |
||
339 | * |
||
340 | * @return string The SQL. |
||
341 | */ |
||
342 | 91 | private function _generateClassTableInheritanceJoins($class, $dqlAlias) |
|
394 | |||
395 | /** |
||
396 | * @return string |
||
397 | */ |
||
398 | 606 | private function _generateOrderedCollectionOrderByItems() |
|
432 | |||
433 | /** |
||
434 | * Generates a discriminator column SQL condition for the class with the given DQL alias. |
||
435 | * |
||
436 | * @param array $dqlAliases List of root DQL aliases to inspect for discriminator restrictions. |
||
437 | * |
||
438 | * @return string |
||
439 | */ |
||
440 | 667 | private function _generateDiscriminatorColumnConditionSQL(array $dqlAliases) |
|
441 | { |
||
442 | 667 | $sqlParts = array(); |
|
443 | |||
444 | 667 | foreach ($dqlAliases as $dqlAlias) { |
|
445 | 667 | $class = $this->queryComponents[$dqlAlias]['metadata']; |
|
446 | |||
447 | 667 | if ( ! $class->isInheritanceTypeSingleTable()) continue; |
|
448 | |||
449 | 36 | $conn = $this->em->getConnection(); |
|
450 | 36 | $values = array(); |
|
451 | |||
452 | 36 | if ($class->discriminatorValue !== null) { // discriminators can be 0 |
|
453 | 18 | $values[] = $conn->quote($class->discriminatorValue); |
|
454 | } |
||
455 | |||
456 | 36 | foreach ($class->subClasses as $subclassName) { |
|
457 | 26 | $values[] = $conn->quote($this->em->getClassMetadata($subclassName)->discriminatorValue); |
|
458 | } |
||
459 | |||
460 | 36 | $sqlTableAlias = ($this->useSqlTableAliases) |
|
461 | 31 | ? $this->getSQLTableAlias($class->getTableName(), $dqlAlias) . '.' |
|
462 | 36 | : ''; |
|
463 | |||
464 | 36 | $sqlParts[] = $sqlTableAlias . $class->discriminatorColumn['name'] . ' IN (' . implode(', ', $values) . ')'; |
|
465 | } |
||
466 | |||
467 | 667 | $sql = implode(' AND ', $sqlParts); |
|
468 | |||
469 | 667 | return (count($sqlParts) > 1) ? '(' . $sql . ')' : $sql; |
|
470 | } |
||
471 | |||
472 | /** |
||
473 | * Generates the filter SQL for a given entity and table alias. |
||
474 | * |
||
475 | * @param ClassMetadata $targetEntity Metadata of the target entity. |
||
476 | * @param string $targetTableAlias The table alias of the joined/selected table. |
||
477 | * |
||
478 | * @return string The SQL query part to add to a query. |
||
479 | */ |
||
480 | 317 | private function generateFilterConditionSQL(ClassMetadata $targetEntity, $targetTableAlias) |
|
516 | |||
517 | /** |
||
518 | * {@inheritdoc} |
||
519 | */ |
||
520 | 613 | public function walkSelectStatement(AST\SelectStatement $AST) |
|
573 | |||
574 | /** |
||
575 | * {@inheritdoc} |
||
576 | */ |
||
577 | 25 | public function walkUpdateStatement(AST\UpdateStatement $AST) |
|
585 | |||
586 | /** |
||
587 | * {@inheritdoc} |
||
588 | */ |
||
589 | 37 | public function walkDeleteStatement(AST\DeleteStatement $AST) |
|
597 | |||
598 | /** |
||
599 | * Walks down an IdentificationVariable AST node, thereby generating the appropriate SQL. |
||
600 | * This one differs of ->walkIdentificationVariable() because it generates the entity identifiers. |
||
601 | * |
||
602 | * @param string $identVariable |
||
603 | * |
||
604 | * @return string |
||
605 | */ |
||
606 | 2 | public function walkEntityIdentificationVariable($identVariable) |
|
618 | |||
619 | /** |
||
620 | * Walks down an IdentificationVariable (no AST node associated), thereby generating the SQL. |
||
621 | * |
||
622 | * @param string $identificationVariable |
||
623 | * @param string $fieldName |
||
624 | * |
||
625 | * @return string The SQL. |
||
626 | */ |
||
627 | 415 | public function walkIdentificationVariable($identificationVariable, $fieldName = null) |
|
640 | |||
641 | /** |
||
642 | * {@inheritdoc} |
||
643 | */ |
||
644 | 484 | public function walkPathExpression($pathExpr) |
|
696 | |||
697 | /** |
||
698 | * {@inheritdoc} |
||
699 | */ |
||
700 | 613 | public function walkSelectClause($selectClause) |
|
701 | { |
||
702 | 613 | $sql = 'SELECT ' . (($selectClause->isDistinct) ? 'DISTINCT ' : ''); |
|
703 | 613 | $sqlSelectExpressions = array_filter(array_map(array($this, 'walkSelectExpression'), $selectClause->selectExpressions)); |
|
704 | |||
705 | 613 | if ($this->query->getHint(Query::HINT_INTERNAL_ITERATION) == true && $selectClause->isDistinct) { |
|
706 | 1 | $this->query->setHint(self::HINT_DISTINCT, true); |
|
707 | } |
||
708 | |||
709 | 613 | $addMetaColumns = ! $this->query->getHint(Query::HINT_FORCE_PARTIAL_LOAD) && |
|
710 | 450 | $this->query->getHydrationMode() == Query::HYDRATE_OBJECT |
|
711 | || |
||
712 | 288 | $this->query->getHydrationMode() != Query::HYDRATE_OBJECT && |
|
713 | 613 | $this->query->getHint(Query::HINT_INCLUDE_META_COLUMNS); |
|
714 | |||
715 | 613 | foreach ($this->selectedClasses as $selectedClass) { |
|
716 | 477 | $class = $selectedClass['class']; |
|
717 | 477 | $dqlAlias = $selectedClass['dqlAlias']; |
|
718 | 477 | $resultAlias = $selectedClass['resultAlias']; |
|
719 | |||
720 | // Register as entity or joined entity result |
||
721 | 477 | if ($this->queryComponents[$dqlAlias]['relation'] === null) { |
|
722 | 477 | $this->rsm->addEntityResult($class->name, $dqlAlias, $resultAlias); |
|
723 | } else { |
||
724 | 157 | $this->rsm->addJoinedEntityResult( |
|
725 | 157 | $class->name, |
|
726 | $dqlAlias, |
||
727 | 157 | $this->queryComponents[$dqlAlias]['parent'], |
|
728 | 157 | $this->queryComponents[$dqlAlias]['relation']['fieldName'] |
|
729 | ); |
||
730 | } |
||
731 | |||
732 | 477 | if ($class->isInheritanceTypeSingleTable() || $class->isInheritanceTypeJoined()) { |
|
733 | // Add discriminator columns to SQL |
||
734 | 85 | $rootClass = $this->em->getClassMetadata($class->rootEntityName); |
|
735 | 85 | $tblAlias = $this->getSQLTableAlias($rootClass->getTableName(), $dqlAlias); |
|
736 | 85 | $discrColumn = $rootClass->discriminatorColumn; |
|
737 | 85 | $columnAlias = $this->getSQLColumnAlias($discrColumn['name']); |
|
738 | |||
739 | 85 | $sqlSelectExpressions[] = $tblAlias . '.' . $discrColumn['name'] . ' AS ' . $columnAlias; |
|
740 | |||
741 | 85 | $this->rsm->setDiscriminatorColumn($dqlAlias, $columnAlias); |
|
742 | 85 | $this->rsm->addMetaResult($dqlAlias, $columnAlias, $discrColumn['fieldName'], false, $discrColumn['type']); |
|
743 | } |
||
744 | |||
745 | // Add foreign key columns to SQL, if necessary |
||
746 | 477 | if ( ! $addMetaColumns && ! $class->containsForeignIdentifier) { |
|
747 | 180 | continue; |
|
748 | } |
||
749 | |||
750 | // Add foreign key columns of class and also parent classes |
||
751 | 346 | foreach ($class->associationMappings as $assoc) { |
|
752 | 310 | if ( ! ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE)) { |
|
753 | 263 | continue; |
|
754 | 278 | } else if ( !$addMetaColumns && !isset($assoc['id'])) { |
|
755 | continue; |
||
756 | } |
||
757 | |||
758 | 278 | $targetClass = $this->em->getClassMetadata($assoc['targetEntity']); |
|
759 | 278 | $isIdentifier = (isset($assoc['id']) && $assoc['id'] === true); |
|
760 | 278 | $owningClass = (isset($assoc['inherited'])) ? $this->em->getClassMetadata($assoc['inherited']) : $class; |
|
761 | 278 | $sqlTableAlias = $this->getSQLTableAlias($owningClass->getTableName(), $dqlAlias); |
|
762 | |||
763 | 278 | foreach ($assoc['joinColumns'] as $joinColumn) { |
|
764 | 278 | $columnName = $joinColumn['name']; |
|
765 | 278 | $columnAlias = $this->getSQLColumnAlias($columnName); |
|
766 | 278 | $columnType = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em); |
|
767 | |||
768 | 278 | $sqlSelectExpressions[] = $sqlTableAlias . '.' . $columnName . ' AS ' . $columnAlias; |
|
769 | |||
770 | 278 | $this->rsm->addMetaResult($dqlAlias, $columnAlias, $columnName, $isIdentifier, $columnType); |
|
771 | } |
||
772 | } |
||
773 | |||
774 | // Add foreign key columns to SQL, if necessary |
||
775 | 346 | if ( ! $addMetaColumns) { |
|
776 | 8 | continue; |
|
777 | } |
||
778 | |||
779 | // Add foreign key columns of subclasses |
||
780 | 341 | foreach ($class->subClasses as $subClassName) { |
|
781 | 27 | $subClass = $this->em->getClassMetadata($subClassName); |
|
782 | 27 | $sqlTableAlias = $this->getSQLTableAlias($subClass->getTableName(), $dqlAlias); |
|
783 | |||
784 | 27 | foreach ($subClass->associationMappings as $assoc) { |
|
785 | // Skip if association is inherited |
||
786 | 24 | if (isset($assoc['inherited'])) continue; |
|
787 | |||
788 | 15 | if ($assoc['isOwningSide'] && $assoc['type'] & ClassMetadata::TO_ONE) { |
|
789 | 13 | $targetClass = $this->em->getClassMetadata($assoc['targetEntity']); |
|
790 | |||
791 | 13 | foreach ($assoc['joinColumns'] as $joinColumn) { |
|
792 | 13 | $columnName = $joinColumn['name']; |
|
793 | 13 | $columnAlias = $this->getSQLColumnAlias($columnName); |
|
794 | 13 | $columnType = PersisterHelper::getTypeOfColumn($joinColumn['referencedColumnName'], $targetClass, $this->em); |
|
795 | |||
796 | 13 | $sqlSelectExpressions[] = $sqlTableAlias . '.' . $columnName . ' AS ' . $columnAlias; |
|
797 | |||
798 | 341 | $this->rsm->addMetaResult($dqlAlias, $columnAlias, $columnName, $subClass->isIdentifier($columnName), $columnType); |
|
799 | } |
||
800 | } |
||
801 | } |
||
802 | } |
||
803 | } |
||
804 | |||
805 | 613 | $sql .= implode(', ', $sqlSelectExpressions); |
|
806 | |||
807 | 613 | return $sql; |
|
808 | } |
||
809 | |||
810 | /** |
||
811 | * {@inheritdoc} |
||
812 | */ |
||
813 | 615 | public function walkFromClause($fromClause) |
|
824 | |||
825 | /** |
||
826 | * Walks down a IdentificationVariableDeclaration AST node, thereby generating the appropriate SQL. |
||
827 | * |
||
828 | * @param AST\IdentificationVariableDeclaration $identificationVariableDecl |
||
829 | * |
||
830 | * @return string |
||
831 | */ |
||
832 | 616 | public function walkIdentificationVariableDeclaration($identificationVariableDecl) |
|
846 | |||
847 | /** |
||
848 | * Walks down a IndexBy AST node. |
||
849 | * |
||
850 | * @param AST\IndexBy $indexBy |
||
851 | * |
||
852 | * @return void |
||
853 | */ |
||
854 | 8 | public function walkIndexBy($indexBy) |
|
868 | |||
869 | /** |
||
870 | * Walks down a RangeVariableDeclaration AST node, thereby generating the appropriate SQL. |
||
871 | * |
||
872 | * @param AST\RangeVariableDeclaration $rangeVariableDeclaration |
||
873 | * |
||
874 | * @return string |
||
875 | */ |
||
876 | 616 | public function walkRangeVariableDeclaration($rangeVariableDeclaration) |
|
897 | |||
898 | /** |
||
899 | * Walks down a JoinAssociationDeclaration AST node, thereby generating the appropriate SQL. |
||
900 | * |
||
901 | * @param AST\JoinAssociationDeclaration $joinAssociationDeclaration |
||
902 | * @param int $joinType |
||
903 | * @param AST\ConditionalExpression $condExpr |
||
904 | * |
||
905 | * @return string |
||
906 | * |
||
907 | * @throws QueryException |
||
908 | */ |
||
909 | 226 | public function walkJoinAssociationDeclaration($joinAssociationDeclaration, $joinType = AST\Join::JOIN_TYPE_INNER, $condExpr = null) |
|
1064 | |||
1065 | /** |
||
1066 | * {@inheritdoc} |
||
1067 | */ |
||
1068 | 64 | public function walkFunction($function) |
|
1072 | |||
1073 | /** |
||
1074 | * {@inheritdoc} |
||
1075 | */ |
||
1076 | 153 | public function walkOrderByClause($orderByClause) |
|
1086 | |||
1087 | /** |
||
1088 | * {@inheritdoc} |
||
1089 | */ |
||
1090 | 171 | public function walkOrderByItem($orderByItem) |
|
1106 | |||
1107 | /** |
||
1108 | * {@inheritdoc} |
||
1109 | */ |
||
1110 | 14 | public function walkHavingClause($havingClause) |
|
1114 | |||
1115 | /** |
||
1116 | * {@inheritdoc} |
||
1117 | */ |
||
1118 | 243 | public function walkJoin($join) |
|
1119 | { |
||
1120 | 243 | $joinType = $join->joinType; |
|
1121 | 243 | $joinDeclaration = $join->joinAssociationDeclaration; |
|
1122 | |||
1123 | 243 | $sql = ($joinType == AST\Join::JOIN_TYPE_LEFT || $joinType == AST\Join::JOIN_TYPE_LEFTOUTER) |
|
1124 | 54 | ? ' LEFT JOIN ' |
|
1125 | 243 | : ' INNER JOIN '; |
|
1126 | |||
1127 | switch (true) { |
||
1128 | 243 | case ($joinDeclaration instanceof \Doctrine\ORM\Query\AST\RangeVariableDeclaration): |
|
1129 | 17 | $class = $this->em->getClassMetadata($joinDeclaration->abstractSchemaName); |
|
1130 | 17 | $dqlAlias = $joinDeclaration->aliasIdentificationVariable; |
|
1131 | 17 | $tableAlias = $this->getSQLTableAlias($class->table['name'], $dqlAlias); |
|
1132 | 17 | $conditions = []; |
|
1133 | |||
1134 | 17 | if ($join->conditionalExpression) { |
|
1135 | 15 | $conditions[] = '(' . $this->walkConditionalExpression($join->conditionalExpression) . ')'; |
|
1136 | } |
||
1137 | |||
1138 | 17 | $condExprConjunction = ($class->isInheritanceTypeJoined() && $joinType != AST\Join::JOIN_TYPE_LEFT && $joinType != AST\Join::JOIN_TYPE_LEFTOUTER) |
|
1139 | 3 | ? ' AND ' |
|
1140 | 17 | : ' ON '; |
|
1141 | |||
1142 | 17 | $sql .= $this->walkRangeVariableDeclaration($joinDeclaration); |
|
1143 | |||
1144 | // Apply remaining inheritance restrictions |
||
1145 | 17 | $discrSql = $this->_generateDiscriminatorColumnConditionSQL(array($dqlAlias)); |
|
1146 | |||
1147 | 17 | if ($discrSql) { |
|
1148 | 3 | $conditions[] = $discrSql; |
|
1149 | } |
||
1150 | |||
1151 | // Apply the filters |
||
1152 | 17 | $filterExpr = $this->generateFilterConditionSQL($class, $tableAlias); |
|
1153 | |||
1154 | 17 | if ($filterExpr) { |
|
1155 | $conditions[] = $filterExpr; |
||
1156 | } |
||
1157 | |||
1158 | 17 | if ($conditions) { |
|
1159 | 15 | $sql .= $condExprConjunction . implode(' AND ', $conditions); |
|
1160 | } |
||
1161 | |||
1162 | 17 | break; |
|
1163 | |||
1164 | case ($joinDeclaration instanceof \Doctrine\ORM\Query\AST\JoinAssociationDeclaration): |
||
1165 | 226 | $sql .= $this->walkJoinAssociationDeclaration($joinDeclaration, $joinType, $join->conditionalExpression); |
|
1166 | 223 | break; |
|
1167 | } |
||
1168 | |||
1169 | 240 | return $sql; |
|
1170 | } |
||
1171 | |||
1172 | /** |
||
1173 | * Walks down a CaseExpression AST node and generates the corresponding SQL. |
||
1174 | * |
||
1175 | * @param AST\CoalesceExpression|AST\NullIfExpression|AST\GeneralCaseExpression|AST\SimpleCaseExpression $expression |
||
1176 | * |
||
1177 | * @return string The SQL. |
||
1178 | */ |
||
1179 | public function walkCaseExpression($expression) |
||
1198 | |||
1199 | /** |
||
1200 | * Walks down a CoalesceExpression AST node and generates the corresponding SQL. |
||
1201 | * |
||
1202 | * @param AST\CoalesceExpression $coalesceExpression |
||
1203 | * |
||
1204 | * @return string The SQL. |
||
1205 | */ |
||
1206 | 2 | public function walkCoalesceExpression($coalesceExpression) |
|
1220 | |||
1221 | /** |
||
1222 | * Walks down a NullIfExpression AST node and generates the corresponding SQL. |
||
1223 | * |
||
1224 | * @param AST\NullIfExpression $nullIfExpression |
||
1225 | * |
||
1226 | * @return string The SQL. |
||
1227 | */ |
||
1228 | 3 | public function walkNullIfExpression($nullIfExpression) |
|
1240 | |||
1241 | /** |
||
1242 | * Walks down a GeneralCaseExpression AST node and generates the corresponding SQL. |
||
1243 | * |
||
1244 | * @param AST\GeneralCaseExpression $generalCaseExpression |
||
1245 | * |
||
1246 | * @return string The SQL. |
||
1247 | */ |
||
1248 | 9 | public function walkGeneralCaseExpression(AST\GeneralCaseExpression $generalCaseExpression) |
|
1261 | |||
1262 | /** |
||
1263 | * Walks down a SimpleCaseExpression AST node and generates the corresponding SQL. |
||
1264 | * |
||
1265 | * @param AST\SimpleCaseExpression $simpleCaseExpression |
||
1266 | * |
||
1267 | * @return string The SQL. |
||
1268 | */ |
||
1269 | 5 | public function walkSimpleCaseExpression($simpleCaseExpression) |
|
1282 | |||
1283 | /** |
||
1284 | * {@inheritdoc} |
||
1285 | */ |
||
1286 | 613 | public function walkSelectExpression($selectExpression) |
|
1287 | { |
||
1288 | 613 | $sql = ''; |
|
1289 | 613 | $expr = $selectExpression->expression; |
|
1290 | 613 | $hidden = $selectExpression->hiddenAliasResultVariable; |
|
1291 | |||
1292 | switch (true) { |
||
1293 | 613 | case ($expr instanceof AST\PathExpression): |
|
1294 | 101 | if ($expr->type !== AST\PathExpression::TYPE_STATE_FIELD) { |
|
1295 | throw QueryException::invalidPathExpression($expr); |
||
1296 | } |
||
1297 | |||
1298 | 101 | $fieldName = $expr->field; |
|
1299 | 101 | $dqlAlias = $expr->identificationVariable; |
|
1300 | 101 | $qComp = $this->queryComponents[$dqlAlias]; |
|
1301 | 101 | $class = $qComp['metadata']; |
|
1302 | |||
1303 | 101 | $resultAlias = $selectExpression->fieldIdentificationVariable ?: $fieldName; |
|
1304 | 101 | $tableName = ($class->isInheritanceTypeJoined()) |
|
1305 | 11 | ? $this->em->getUnitOfWork()->getEntityPersister($class->name)->getOwningTable($fieldName) |
|
1306 | 101 | : $class->getTableName(); |
|
1307 | |||
1308 | 101 | $sqlTableAlias = $this->getSQLTableAlias($tableName, $dqlAlias); |
|
1309 | 101 | $fieldMapping = $class->fieldMappings[$fieldName]; |
|
1310 | 101 | $columnName = $this->quoteStrategy->getColumnName($fieldName, $class, $this->platform); |
|
1311 | 101 | $columnAlias = $this->getSQLColumnAlias($fieldMapping['columnName']); |
|
1312 | 101 | $col = $sqlTableAlias . '.' . $columnName; |
|
1313 | |||
1314 | 101 | if (isset($fieldMapping['requireSQLConversion'])) { |
|
1315 | 2 | $type = Type::getType($fieldMapping['type']); |
|
1316 | 2 | $col = $type->convertToPHPValueSQL($col, $this->conn->getDatabasePlatform()); |
|
1317 | } |
||
1318 | |||
1319 | 101 | $sql .= $col . ' AS ' . $columnAlias; |
|
1320 | |||
1321 | 101 | $this->scalarResultAliasMap[$resultAlias] = $columnAlias; |
|
1322 | |||
1323 | 101 | if ( ! $hidden) { |
|
1324 | 101 | $this->rsm->addScalarResult($columnAlias, $resultAlias, $fieldMapping['type']); |
|
1325 | 101 | $this->scalarFields[$dqlAlias][$fieldName] = $columnAlias; |
|
1326 | } |
||
1327 | |||
1328 | 101 | break; |
|
1329 | |||
1330 | case ($expr instanceof AST\AggregateExpression): |
||
1331 | case ($expr instanceof AST\Functions\FunctionNode): |
||
1332 | 10 | case ($expr instanceof AST\SimpleArithmeticExpression): |
|
1333 | 22 | case ($expr instanceof AST\ArithmeticTerm): |
|
1334 | 64 | case ($expr instanceof AST\ArithmeticFactor): |
|
1335 | 28 | case ($expr instanceof AST\ParenthesisExpression): |
|
1336 | case ($expr instanceof AST\Literal): |
||
1337 | 37 | case ($expr instanceof AST\NullIfExpression): |
|
1338 | 37 | case ($expr instanceof AST\CoalesceExpression): |
|
1339 | 9 | case ($expr instanceof AST\GeneralCaseExpression): |
|
1340 | 43 | case ($expr instanceof AST\SimpleCaseExpression): |
|
1341 | 105 | $columnAlias = $this->getSQLColumnAlias('sclr'); |
|
1342 | 105 | $resultAlias = $selectExpression->fieldIdentificationVariable ?: $this->scalarResultCounter++; |
|
1343 | |||
1344 | 105 | $sql .= $expr->dispatch($this) . ' AS ' . $columnAlias; |
|
1345 | |||
1346 | 105 | $this->scalarResultAliasMap[$resultAlias] = $columnAlias; |
|
1347 | |||
1348 | 105 | if ( ! $hidden) { |
|
1349 | // We cannot resolve field type here; assume 'string'. |
||
1350 | 105 | $this->rsm->addScalarResult($columnAlias, $resultAlias, 'string'); |
|
1351 | } |
||
1352 | 105 | break; |
|
1353 | |||
1354 | case ($expr instanceof AST\Subselect): |
||
1355 | 15 | $columnAlias = $this->getSQLColumnAlias('sclr'); |
|
1356 | 15 | $resultAlias = $selectExpression->fieldIdentificationVariable ?: $this->scalarResultCounter++; |
|
1357 | |||
1358 | 15 | $sql .= '(' . $this->walkSubselect($expr) . ') AS ' . $columnAlias; |
|
1359 | |||
1360 | 15 | $this->scalarResultAliasMap[$resultAlias] = $columnAlias; |
|
1361 | |||
1362 | 15 | if ( ! $hidden) { |
|
1363 | // We cannot resolve field type here; assume 'string'. |
||
1364 | 13 | $this->rsm->addScalarResult($columnAlias, $resultAlias, 'string'); |
|
1365 | } |
||
1366 | 15 | break; |
|
1367 | |||
1368 | 477 | case ($expr instanceof AST\NewObjectExpression): |
|
1369 | 22 | $sql .= $this->walkNewObject($expr,$selectExpression->fieldIdentificationVariable); |
|
1370 | 22 | break; |
|
1371 | |||
1372 | default: |
||
1373 | // IdentificationVariable or PartialObjectExpression |
||
1374 | 477 | if ($expr instanceof AST\PartialObjectExpression) { |
|
1375 | 16 | $dqlAlias = $expr->identificationVariable; |
|
1376 | 16 | $partialFieldSet = $expr->partialFieldSet; |
|
1377 | } else { |
||
1378 | 472 | $dqlAlias = $expr; |
|
1379 | 472 | $partialFieldSet = array(); |
|
1380 | } |
||
1381 | |||
1382 | 477 | $queryComp = $this->queryComponents[$dqlAlias]; |
|
1383 | 477 | $class = $queryComp['metadata']; |
|
1384 | 477 | $resultAlias = $selectExpression->fieldIdentificationVariable ?: null; |
|
1385 | |||
1386 | 477 | if ( ! isset($this->selectedClasses[$dqlAlias])) { |
|
1387 | 477 | $this->selectedClasses[$dqlAlias] = array( |
|
1388 | 477 | 'class' => $class, |
|
1389 | 477 | 'dqlAlias' => $dqlAlias, |
|
1390 | 477 | 'resultAlias' => $resultAlias |
|
1391 | ); |
||
1392 | } |
||
1393 | |||
1394 | 477 | $sqlParts = array(); |
|
1395 | |||
1396 | // Select all fields from the queried class |
||
1397 | 477 | foreach ($class->fieldMappings as $fieldName => $mapping) { |
|
1398 | 476 | if ($partialFieldSet && ! in_array($fieldName, $partialFieldSet)) { |
|
1399 | 14 | continue; |
|
1400 | } |
||
1401 | |||
1402 | 475 | $tableName = (isset($mapping['inherited'])) |
|
1403 | 51 | ? $this->em->getClassMetadata($mapping['inherited'])->getTableName() |
|
1404 | 475 | : $class->getTableName(); |
|
1405 | |||
1406 | 475 | $sqlTableAlias = $this->getSQLTableAlias($tableName, $dqlAlias); |
|
1407 | 475 | $columnAlias = $this->getSQLColumnAlias($mapping['columnName']); |
|
1408 | 475 | $quotedColumnName = $this->quoteStrategy->getColumnName($fieldName, $class, $this->platform); |
|
1409 | |||
1410 | 475 | $col = $sqlTableAlias . '.' . $quotedColumnName; |
|
1411 | |||
1412 | 475 | if (isset($mapping['requireSQLConversion'])) { |
|
1413 | 5 | $type = Type::getType($mapping['type']); |
|
1414 | 5 | $col = $type->convertToPHPValueSQL($col, $this->platform); |
|
1415 | } |
||
1416 | |||
1417 | 475 | $sqlParts[] = $col . ' AS '. $columnAlias; |
|
1418 | |||
1419 | 475 | $this->scalarResultAliasMap[$resultAlias][] = $columnAlias; |
|
1420 | |||
1421 | 475 | $this->rsm->addFieldResult($dqlAlias, $columnAlias, $fieldName, $class->name); |
|
1422 | } |
||
1423 | |||
1424 | // Add any additional fields of subclasses (excluding inherited fields) |
||
1425 | // 1) on Single Table Inheritance: always, since its marginal overhead |
||
1426 | // 2) on Class Table Inheritance only if partial objects are disallowed, |
||
1427 | // since it requires outer joining subtables. |
||
1428 | 477 | if ($class->isInheritanceTypeSingleTable() || ! $this->query->getHint(Query::HINT_FORCE_PARTIAL_LOAD)) { |
|
1429 | 383 | foreach ($class->subClasses as $subClassName) { |
|
1430 | 37 | $subClass = $this->em->getClassMetadata($subClassName); |
|
1431 | 37 | $sqlTableAlias = $this->getSQLTableAlias($subClass->getTableName(), $dqlAlias); |
|
1432 | |||
1433 | 37 | foreach ($subClass->fieldMappings as $fieldName => $mapping) { |
|
1434 | 37 | if (isset($mapping['inherited']) || ($partialFieldSet && !in_array($fieldName, $partialFieldSet))) { |
|
1435 | 37 | continue; |
|
1436 | } |
||
1437 | |||
1438 | 33 | $columnAlias = $this->getSQLColumnAlias($mapping['columnName']); |
|
1439 | 33 | $quotedColumnName = $this->quoteStrategy->getColumnName($fieldName, $subClass, $this->platform); |
|
1440 | |||
1441 | 33 | $col = $sqlTableAlias . '.' . $quotedColumnName; |
|
1442 | |||
1443 | 33 | if (isset($mapping['requireSQLConversion'])) { |
|
1444 | $type = Type::getType($mapping['type']); |
||
1445 | $col = $type->convertToPHPValueSQL($col, $this->platform); |
||
1446 | } |
||
1447 | |||
1448 | 33 | $sqlParts[] = $col . ' AS ' . $columnAlias; |
|
1449 | |||
1450 | 33 | $this->scalarResultAliasMap[$resultAlias][] = $columnAlias; |
|
1451 | |||
1452 | 37 | $this->rsm->addFieldResult($dqlAlias, $columnAlias, $fieldName, $subClassName); |
|
1453 | } |
||
1454 | } |
||
1455 | } |
||
1456 | |||
1457 | 477 | $sql .= implode(', ', $sqlParts); |
|
1458 | } |
||
1459 | |||
1460 | 613 | return $sql; |
|
1461 | } |
||
1462 | |||
1463 | /** |
||
1464 | * {@inheritdoc} |
||
1465 | */ |
||
1466 | public function walkQuantifiedExpression($qExpr) |
||
1470 | |||
1471 | /** |
||
1472 | * {@inheritdoc} |
||
1473 | */ |
||
1474 | 33 | public function walkSubselect($subselect) |
|
1495 | |||
1496 | /** |
||
1497 | * {@inheritdoc} |
||
1498 | */ |
||
1499 | 33 | public function walkSubselectFromClause($subselectFromClause) |
|
1510 | |||
1511 | /** |
||
1512 | * {@inheritdoc} |
||
1513 | */ |
||
1514 | 33 | public function walkSimpleSelectClause($simpleSelectClause) |
|
1519 | |||
1520 | /** |
||
1521 | * @param \Doctrine\ORM\Query\AST\ParenthesisExpression $parenthesisExpression |
||
1522 | * |
||
1523 | * @return string. |
||
1524 | */ |
||
1525 | 21 | public function walkParenthesisExpression(AST\ParenthesisExpression $parenthesisExpression) |
|
1529 | |||
1530 | /** |
||
1531 | * @param AST\NewObjectExpression $newObjectExpression |
||
1532 | * |
||
1533 | * @return string The SQL. |
||
1534 | */ |
||
1535 | 22 | public function walkNewObject($newObjectExpression, $newObjectResultAlias=null) |
|
1536 | { |
||
1537 | 22 | $sqlSelectExpressions = array(); |
|
1538 | 22 | $objIndex = $newObjectResultAlias?:$this->newObjectCounter++; |
|
1539 | |||
1540 | 22 | foreach ($newObjectExpression->args as $argIndex => $e) { |
|
1541 | 22 | $resultAlias = $this->scalarResultCounter++; |
|
1542 | 22 | $columnAlias = $this->getSQLColumnAlias('sclr'); |
|
1543 | 22 | $fieldType = 'string'; |
|
1544 | |||
1545 | switch (true) { |
||
1546 | 22 | case ($e instanceof AST\NewObjectExpression): |
|
1547 | $sqlSelectExpressions[] = $e->dispatch($this); |
||
1548 | break; |
||
1549 | |||
1550 | case ($e instanceof AST\Subselect): |
||
1551 | 1 | $sqlSelectExpressions[] = '(' . $e->dispatch($this) . ') AS ' . $columnAlias; |
|
1552 | 1 | break; |
|
1553 | |||
1554 | case ($e instanceof AST\PathExpression): |
||
1555 | 22 | $dqlAlias = $e->identificationVariable; |
|
1556 | 22 | $qComp = $this->queryComponents[$dqlAlias]; |
|
1557 | 22 | $class = $qComp['metadata']; |
|
1558 | 22 | $fieldType = $class->fieldMappings[$e->field]['type']; |
|
1559 | |||
1560 | 22 | $sqlSelectExpressions[] = trim($e->dispatch($this)) . ' AS ' . $columnAlias; |
|
1561 | 22 | break; |
|
1562 | |||
1563 | 5 | case ($e instanceof AST\Literal): |
|
1564 | 1 | switch ($e->type) { |
|
1565 | 1 | case AST\Literal::BOOLEAN: |
|
1566 | 1 | $fieldType = 'boolean'; |
|
1567 | 1 | break; |
|
1568 | |||
1569 | 1 | case AST\Literal::NUMERIC: |
|
1570 | 1 | $fieldType = is_float($e->value) ? 'float' : 'integer'; |
|
1571 | 1 | break; |
|
1572 | } |
||
1573 | |||
1574 | 1 | $sqlSelectExpressions[] = trim($e->dispatch($this)) . ' AS ' . $columnAlias; |
|
1575 | 1 | break; |
|
1576 | |||
1577 | default: |
||
1578 | 5 | $sqlSelectExpressions[] = trim($e->dispatch($this)) . ' AS ' . $columnAlias; |
|
1579 | 5 | break; |
|
1580 | } |
||
1581 | |||
1582 | 22 | $this->scalarResultAliasMap[$resultAlias] = $columnAlias; |
|
1583 | 22 | $this->rsm->addScalarResult($columnAlias, $resultAlias, $fieldType); |
|
1584 | |||
1585 | 22 | $this->rsm->newObjectMappings[$columnAlias] = array( |
|
1586 | 22 | 'className' => $newObjectExpression->className, |
|
1587 | 22 | 'objIndex' => $objIndex, |
|
1588 | 22 | 'argIndex' => $argIndex |
|
1589 | ); |
||
1590 | } |
||
1591 | |||
1592 | 22 | return implode(', ', $sqlSelectExpressions); |
|
1593 | } |
||
1594 | |||
1595 | /** |
||
1596 | * {@inheritdoc} |
||
1597 | */ |
||
1598 | 33 | public function walkSimpleSelectExpression($simpleSelectExpression) |
|
1599 | { |
||
1600 | 33 | $expr = $simpleSelectExpression->expression; |
|
1601 | 33 | $sql = ' '; |
|
1602 | |||
1603 | switch (true) { |
||
1604 | 33 | case ($expr instanceof AST\PathExpression): |
|
1605 | 9 | $sql .= $this->walkPathExpression($expr); |
|
1606 | 9 | break; |
|
1607 | |||
1608 | case ($expr instanceof AST\AggregateExpression): |
||
1609 | 14 | $alias = $simpleSelectExpression->fieldIdentificationVariable ?: $this->scalarResultCounter++; |
|
1610 | |||
1611 | 14 | $sql .= $this->walkAggregateExpression($expr) . ' AS dctrn__' . $alias; |
|
1612 | 14 | break; |
|
1613 | |||
1614 | case ($expr instanceof AST\Subselect): |
||
1615 | $alias = $simpleSelectExpression->fieldIdentificationVariable ?: $this->scalarResultCounter++; |
||
1616 | |||
1617 | $columnAlias = 'sclr' . $this->aliasCounter++; |
||
1618 | $this->scalarResultAliasMap[$alias] = $columnAlias; |
||
1619 | |||
1620 | $sql .= '(' . $this->walkSubselect($expr) . ') AS ' . $columnAlias; |
||
1621 | break; |
||
1622 | |||
1623 | case ($expr instanceof AST\Functions\FunctionNode): |
||
1624 | case ($expr instanceof AST\SimpleArithmeticExpression): |
||
1625 | case ($expr instanceof AST\ArithmeticTerm): |
||
1626 | 7 | case ($expr instanceof AST\ArithmeticFactor): |
|
1627 | case ($expr instanceof AST\Literal): |
||
1628 | case ($expr instanceof AST\NullIfExpression): |
||
1629 | case ($expr instanceof AST\CoalesceExpression): |
||
1630 | case ($expr instanceof AST\GeneralCaseExpression): |
||
1631 | case ($expr instanceof AST\SimpleCaseExpression): |
||
1632 | 8 | $alias = $simpleSelectExpression->fieldIdentificationVariable ?: $this->scalarResultCounter++; |
|
1633 | |||
1634 | 8 | $columnAlias = $this->getSQLColumnAlias('sclr'); |
|
1635 | 8 | $this->scalarResultAliasMap[$alias] = $columnAlias; |
|
1636 | |||
1637 | 8 | $sql .= $expr->dispatch($this) . ' AS ' . $columnAlias; |
|
1638 | 8 | break; |
|
1639 | |||
1640 | 2 | case ($expr instanceof AST\ParenthesisExpression): |
|
1641 | 1 | $sql .= $this->walkParenthesisExpression($expr); |
|
1642 | 1 | break; |
|
1643 | |||
1644 | default: // IdentificationVariable |
||
1645 | 2 | $sql .= $this->walkEntityIdentificationVariable($expr); |
|
1646 | 2 | break; |
|
1647 | } |
||
1648 | |||
1649 | 33 | return $sql; |
|
1650 | } |
||
1651 | |||
1652 | /** |
||
1653 | * {@inheritdoc} |
||
1654 | */ |
||
1655 | 75 | public function walkAggregateExpression($aggExpression) |
|
1660 | |||
1661 | /** |
||
1662 | * {@inheritdoc} |
||
1663 | */ |
||
1664 | 23 | public function walkGroupByClause($groupByClause) |
|
1674 | |||
1675 | /** |
||
1676 | * {@inheritdoc} |
||
1677 | */ |
||
1678 | 23 | public function walkGroupByItem($groupByItem) |
|
1721 | |||
1722 | /** |
||
1723 | * {@inheritdoc} |
||
1724 | */ |
||
1725 | 37 | public function walkDeleteClause(AST\DeleteClause $deleteClause) |
|
1736 | |||
1737 | /** |
||
1738 | * {@inheritdoc} |
||
1739 | */ |
||
1740 | 25 | public function walkUpdateClause($updateClause) |
|
1753 | |||
1754 | /** |
||
1755 | * {@inheritdoc} |
||
1756 | */ |
||
1757 | 29 | public function walkUpdateItem($updateItem) |
|
1783 | |||
1784 | /** |
||
1785 | * {@inheritdoc} |
||
1786 | */ |
||
1787 | 670 | public function walkWhereClause($whereClause) |
|
1822 | |||
1823 | /** |
||
1824 | * {@inheritdoc} |
||
1825 | */ |
||
1826 | 358 | public function walkConditionalExpression($condExpr) |
|
1836 | |||
1837 | /** |
||
1838 | * {@inheritdoc} |
||
1839 | */ |
||
1840 | 358 | public function walkConditionalTerm($condTerm) |
|
1850 | |||
1851 | /** |
||
1852 | * {@inheritdoc} |
||
1853 | */ |
||
1854 | 358 | public function walkConditionalFactor($factor) |
|
1862 | |||
1863 | /** |
||
1864 | * {@inheritdoc} |
||
1865 | */ |
||
1866 | 358 | public function walkConditionalPrimary($primary) |
|
1878 | |||
1879 | /** |
||
1880 | * {@inheritdoc} |
||
1881 | */ |
||
1882 | 5 | public function walkExistsExpression($existsExpr) |
|
1890 | |||
1891 | /** |
||
1892 | * {@inheritdoc} |
||
1893 | */ |
||
1894 | 6 | public function walkCollectionMemberExpression($collMemberExpr) |
|
2000 | |||
2001 | /** |
||
2002 | * {@inheritdoc} |
||
2003 | */ |
||
2004 | 3 | public function walkEmptyCollectionComparisonExpression($emptyCollCompExpr) |
|
2011 | |||
2012 | /** |
||
2013 | * {@inheritdoc} |
||
2014 | */ |
||
2015 | 10 | public function walkNullComparisonExpression($nullCompExpr) |
|
2032 | |||
2033 | /** |
||
2034 | * {@inheritdoc} |
||
2035 | */ |
||
2036 | 85 | public function walkInExpression($inExpr) |
|
2048 | |||
2049 | /** |
||
2050 | * {@inheritdoc} |
||
2051 | */ |
||
2052 | 9 | public function walkInstanceOfExpression($instanceOfExpr) |
|
2101 | |||
2102 | /** |
||
2103 | * {@inheritdoc} |
||
2104 | */ |
||
2105 | 77 | public function walkInParameter($inParam) |
|
2111 | |||
2112 | /** |
||
2113 | * {@inheritdoc} |
||
2114 | */ |
||
2115 | 148 | public function walkLiteral($literal) |
|
2134 | |||
2135 | /** |
||
2136 | * {@inheritdoc} |
||
2137 | */ |
||
2138 | 6 | public function walkBetweenExpression($betweenExpr) |
|
2151 | |||
2152 | /** |
||
2153 | * {@inheritdoc} |
||
2154 | */ |
||
2155 | 9 | public function walkLikeExpression($likeExpr) |
|
2180 | |||
2181 | /** |
||
2182 | * {@inheritdoc} |
||
2183 | */ |
||
2184 | 5 | public function walkStateFieldPathExpression($stateFieldPathExpression) |
|
2188 | |||
2189 | /** |
||
2190 | * {@inheritdoc} |
||
2191 | */ |
||
2192 | 256 | public function walkComparisonExpression($compExpr) |
|
2210 | |||
2211 | /** |
||
2212 | * {@inheritdoc} |
||
2213 | */ |
||
2214 | 210 | public function walkInputParameter($inputParam) |
|
2226 | |||
2227 | /** |
||
2228 | * {@inheritdoc} |
||
2229 | */ |
||
2230 | 322 | public function walkArithmeticExpression($arithmeticExpr) |
|
2236 | |||
2237 | /** |
||
2238 | * {@inheritdoc} |
||
2239 | */ |
||
2240 | 384 | public function walkSimpleArithmeticExpression($simpleArithmeticExpr) |
|
2248 | |||
2249 | /** |
||
2250 | * {@inheritdoc} |
||
2251 | */ |
||
2252 | 405 | public function walkArithmeticTerm($term) |
|
2268 | |||
2269 | /** |
||
2270 | * {@inheritdoc} |
||
2271 | */ |
||
2272 | 404 | public function walkArithmeticFactor($factor) |
|
2273 | { |
||
2274 | 404 | if (is_string($factor)) { |
|
2275 | 47 | return (isset($this->queryComponents[$factor])) |
|
2276 | 2 | ? $this->walkResultVariable($this->queryComponents[$factor]['token']['value']) |
|
2277 | 47 | : $factor; |
|
2278 | } |
||
2279 | |||
2280 | // Phase 2 AST optimization: Skip processing of ArithmeticFactor |
||
2281 | // if only one ArithmeticPrimary is defined |
||
2282 | 404 | if ( ! ($factor instanceof AST\ArithmeticFactor)) { |
|
2283 | 404 | return $this->walkArithmeticPrimary($factor); |
|
2284 | } |
||
2285 | |||
2286 | $sign = $factor->isNegativeSigned() ? '-' : ($factor->isPositiveSigned() ? '+' : ''); |
||
2287 | |||
2288 | return $sign . $this->walkArithmeticPrimary($factor->arithmeticPrimary); |
||
2289 | } |
||
2290 | |||
2291 | /** |
||
2292 | * Walks down an ArithmeticPrimary that represents an AST node, thereby generating the appropriate SQL. |
||
2293 | * |
||
2294 | * @param mixed $primary |
||
2295 | * |
||
2296 | * @return string The SQL. |
||
2297 | */ |
||
2298 | 404 | public function walkArithmeticPrimary($primary) |
|
2310 | |||
2311 | /** |
||
2312 | * {@inheritdoc} |
||
2313 | */ |
||
2314 | 18 | public function walkStringPrimary($stringPrimary) |
|
2320 | |||
2321 | /** |
||
2322 | * {@inheritdoc} |
||
2323 | */ |
||
2324 | 30 | public function walkResultVariable($resultVariable) |
|
2334 | } |
||
2335 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.