@@ -17,16 +17,19 @@ class Sql2Generator extends BaseSqlGenerator
1717 * Selector ::= nodeTypeName ['AS' selectorName]
1818 * nodeTypeName ::= Name
1919 *
20- * @param string $nodeTypeName The node type of the selector. If it does not contain starting and ending brackets ([]) they will be added automatically
21- * @param string $selectorName
20+ * @param string $nodeTypeName The node type of the selector. If it
21+ * does not contain starting and ending brackets ([]) they will be
22+ * added automatically.
23+ * @param string|null $selectorName The selector name. If it is different than
24+ * the nodeTypeName, the alias is declared.
2225 *
2326 * @return string
2427 */
2528 public function evalSelector ($ nodeTypeName , $ selectorName = null )
2629 {
2730 $ sql2 = $ this ->addBracketsIfNeeded ($ nodeTypeName );
2831
29- if (! is_null ( $ selectorName) && $ nodeTypeName !== $ selectorName ) {
32+ if (null !== $ selectorName && $ nodeTypeName !== $ selectorName ) {
3033 // if the selector name is the same as the type name, this is implicit for sql2
3134 $ sql2 .= ' AS ' . $ selectorName ;
3235 }
@@ -112,7 +115,9 @@ public function evalSameNodeJoinCondition($sel1Name, $sel2Name, $sel2Path = null
112115 . $ this ->addBracketsIfNeeded ($ sel1Name ) . ', '
113116 . $ this ->addBracketsIfNeeded ($ sel2Name )
114117 ;
115- $ sql2 .= ! is_null ($ sel2Path ) ? ', ' . $ sel2Path : '' ;
118+ if (null !== $ sel2Path ) {
119+ $ sql2 .= ', ' . $ sel2Path ;
120+ }
116121 $ sql2 .= ') ' ;
117122
118123 return $ sql2 ;
@@ -165,7 +170,7 @@ public function evalDescendantNodeJoinCondition($descendantSelectorName, $ancest
165170 public function evalSameNode ($ path , $ selectorName = null )
166171 {
167172 $ sql2 = 'ISSAMENODE( ' ;
168- $ sql2 .= is_null ( $ selectorName) ? $ path : $ this ->addBracketsIfNeeded ($ selectorName ) . ', ' . $ path ;
173+ $ sql2 .= null === $ selectorName ? $ path : $ this ->addBracketsIfNeeded ($ selectorName ) . ', ' . $ path ;
169174 $ sql2 .= ') ' ;
170175
171176 return $ sql2 ;
@@ -180,7 +185,7 @@ public function evalSameNode($path, $selectorName = null)
180185 public function evalChildNode ($ path , $ selectorName = null )
181186 {
182187 $ sql2 = 'ISCHILDNODE( ' ;
183- $ sql2 .= is_null ( $ selectorName) ? $ path : $ this ->addBracketsIfNeeded ($ selectorName ) . ', ' . $ path ;
188+ $ sql2 .= null === $ selectorName ? $ path : $ this ->addBracketsIfNeeded ($ selectorName ) . ', ' . $ path ;
184189 $ sql2 .= ') ' ;
185190
186191 return $ sql2 ;
@@ -195,7 +200,7 @@ public function evalChildNode($path, $selectorName = null)
195200 public function evalDescendantNode ($ path , $ selectorName = null )
196201 {
197202 $ sql2 = 'ISDESCENDANTNODE( ' ;
198- $ sql2 .= is_null ( $ selectorName) ? $ path : $ this ->addBracketsIfNeeded ($ selectorName ) . ', ' . $ path ;
203+ $ sql2 .= null === $ selectorName ? $ path : $ this ->addBracketsIfNeeded ($ selectorName ) . ', ' . $ path ;
199204 $ sql2 .= ') ' ;
200205
201206 return $ sql2 ;
@@ -289,7 +294,7 @@ public function evalFullTextSearchScore($selectorValue = null)
289294 */
290295 public function evalPropertyValue ($ propertyName , $ selectorName = null )
291296 {
292- $ sql2 = ! is_null ( $ selectorName) ? $ this ->addBracketsIfNeeded ($ selectorName ) . '. ' : '' ;
297+ $ sql2 = null !== $ selectorName ? $ this ->addBracketsIfNeeded ($ selectorName ) . '. ' : '' ;
293298 if (false !== strpos ($ propertyName , ': ' )) {
294299 $ propertyName = "[ $ propertyName] " ;
295300 }
@@ -340,11 +345,11 @@ public function evalColumns($columns)
340345 public function evalColumn ($ selectorName , $ propertyName = null , $ colname = null )
341346 {
342347 $ sql2 = '' ;
343- if (! is_null ( $ selectorName) && is_null ( $ propertyName) && is_null ( $ colname) ) {
348+ if (null !== $ selectorName && null === $ propertyName && null === $ colname ) {
344349 $ sql2 .= $ this ->addBracketsIfNeeded ($ selectorName ) . '.* ' ;
345350 } else {
346351 $ sql2 .= $ this ->evalPropertyValue ($ propertyName , $ selectorName );
347- if (! is_null ( $ colname) && $ colname !== $ propertyName ) {
352+ if (null !== $ colname && $ colname !== $ propertyName ) {
348353 // if the column name is the same as the property name, this is implicit for sql2
349354 $ sql2 .= ' AS ' . $ colname ;
350355 }
0 commit comments