33namespace PHPCR \Util \QOM ;
44
55use PHPCR \Query \QOM ;
6- use PHPCR \Query \QOM \QueryObjectModelConstantsInterface as Constants ;
76
87abstract class BaseQomToSqlQueryConverter
98{
109 /**
11- * @var \PHPCR\Util\QOM\ Sql2Generator
10+ * @var Sql2Generator
1211 */
1312 protected $ generator ;
1413
@@ -23,7 +22,8 @@ public function __construct(BaseSqlGenerator $generator)
2322 * ['WHERE' Constraint]
2423 * ['ORDER BY' orderings]
2524 *
26- * @param \PHPCR\Query\QOM\QueryObjectModelInterface $query
25+ * @param QOM\QueryObjectModelInterface $query
26+ *
2727 * @return string
2828 */
2929 public function convert (QOM \QueryObjectModelInterface $ query )
@@ -44,11 +44,17 @@ public function convert(QOM\QueryObjectModelInterface $query)
4444 return $ this ->generator ->evalQuery ($ source , $ columns , $ constraint , $ orderings );
4545 }
4646
47+ abstract protected function convertSource (QOM \SourceInterface $ source );
48+
49+ abstract protected function convertConstraint (QOM \ConstraintInterface $ constraint );
50+
51+ abstract protected function convertDynamicOperand (QOM \DynamicOperandInterface $ operand );
52+
4753 /**
4854 * Selector ::= nodeTypeName ['AS' selectorName]
4955 * nodeTypeName ::= Name
5056 *
51- * @param \PHPCR\Query\ QOM\SelectorInterface $selector
57+ * @param QOM\SelectorInterface $selector
5258 * @return string
5359 */
5460 protected function convertSelector (QOM \SelectorInterface $ selector )
@@ -70,7 +76,7 @@ protected function convertSelector(QOM\SelectorInterface $selector)
7076 * GreaterThanOrEqualTo ::= '>='
7177 * Like ::= 'LIKE'
7278 *
73- * @param \PHPCR\Query\ QOM\ComparisonInterface $comparison
79+ * @param QOM\ComparisonInterface $comparison
7480 * @return string
7581 */
7682 protected function convertComparison (QOM \ComparisonInterface $ comparison )
@@ -92,7 +98,7 @@ protected function convertComparison(QOM\ComparisonInterface $comparison)
9298 * Note: The negation, 'NOT x IS NOT NULL'
9399 * can be written 'x IS NULL'
94100 *
95- * @param \PHPCR\Query\ QOM\PropertyExistenceInterface $constraint
101+ * @param QOM\PropertyExistenceInterface $constraint
96102 * @return string
97103 */
98104 protected function convertPropertyExistence (QOM \PropertyExistenceInterface $ constraint )
@@ -111,34 +117,34 @@ protected function convertPropertyExistence(QOM\PropertyExistenceInterface $cons
111117 * explicit specification of the selectorName
112118 * preceding the propertyName is optional
113119 *
114- * @param \PHPCR\Query\ QOM\FullTextSearchInterface $constraint
120+ * @param QOM\FullTextSearchInterface $constraint
115121 * @return string
116122 */
117123 protected function convertFullTextSearch (QOM \FullTextSearchInterface $ constraint )
118124 {
119125 $ searchExpression = $ this ->convertFullTextSearchExpression ($ constraint ->getFullTextSearchExpression ());
126+
120127 return $ this ->generator ->evalFullTextSearch ($ constraint ->getSelectorName (), $ searchExpression , $ constraint ->getPropertyName ());
121128 }
122129
123130 /**
124131 * FullTextSearchExpression ::= BindVariable | ''' FullTextSearchLiteral '''
125132 *
126- * @param string $expr
133+ * @param string $expr
127134 * @return string
128135 */
129136 protected function convertFullTextSearchExpression ($ literal )
130137 {
131- if ($ literal instanceof QOM \BindVariableValue ) {
138+ if ($ literal instanceof QOM \BindVariableValueInterface ) {
132139 return $ this ->convertBindVariable ($ literal );
133140 }
134- if ($ literal instanceof QOM \Literal ) {
141+ if ($ literal instanceof QOM \LiteralInterface ) {
135142 return $ this ->convertLiteral ($ literal );
136143 }
137144
138145 return "' $ literal' " ;
139146 }
140147
141-
142148 /**
143149 * StaticOperand ::= Literal | BindVariableValue
144150 *
@@ -154,7 +160,7 @@ protected function convertFullTextSearchExpression($literal)
154160 * BindVariableValue ::= '$'bindVariableName
155161 * bindVariableName ::= Prefix
156162 *
157- * @param \PHPCR\Query\ QOM\StaticOperandInterface $operand
163+ * @param QOM\StaticOperandInterface $operand
158164 * @return string
159165 */
160166 protected function convertStaticOperand (QOM \StaticOperandInterface $ operand )
@@ -173,7 +179,7 @@ protected function convertStaticOperand(QOM\StaticOperandInterface $operand)
173179 /**
174180 * PropertyValue ::= [selectorName'.'] propertyName // If only one selector exists
175181 *
176- * @param \PHPCR\Query\ QOM\PropertyValueInterface $value
182+ * @param QOM\PropertyValueInterface $value
177183 * @return string
178184 */
179185 protected function convertPropertyValue (QOM \PropertyValueInterface $ operand )
@@ -183,20 +189,20 @@ protected function convertPropertyValue(QOM\PropertyValueInterface $operand)
183189 $ operand ->getSelectorName ());
184190 }
185191
186-
187192 /**
188193 * orderings ::= Ordering {',' Ordering}
189194 * Ordering ::= DynamicOperand [Order]
190195 * Order ::= Ascending | Descending
191196 * Ascending ::= 'ASC'
192197 * Descending ::= 'DESC'
193198 *
194- * @param array $orderings
199+ * @param QOM\OrderingInterface[] $orderings
195200 * @return string
196201 */
197202 protected function convertOrderings (array $ orderings )
198203 {
199204 $ list = array ();
205+ /** @var $ordering QOM\OrderingInterface */
200206 foreach ($ orderings as $ ordering ) {
201207 $ order = $ this ->generator ->evalOrder ($ ordering ->getOrder ());
202208 $ operand = $ this ->convertDynamicOperand ($ ordering ->getOperand ());
@@ -230,12 +236,13 @@ protected function convertLiteral($literal)
230236 * propertyName ::= Name
231237 * columnName ::= Name
232238 *
233- * @param array $columns
239+ * @param QOM\ColumnInterface[] $columns
234240 * @return string
235241 */
236242 protected function convertColumns (array $ columns )
237243 {
238244 $ list = array ();
245+ /** @var $column QOM\ColumnInterface */
239246 foreach ($ columns as $ column ) {
240247 $ selector = $ column ->getSelectorName ();
241248 $ property = $ column ->getPropertyName ();
0 commit comments