22
33namespace SQLParser \Node ;
44
5+ use Doctrine \DBAL \Platforms \AbstractPlatform ;
56use Mouf \Utils \Common \ConditionInterface \ConditionTrait ;
6- use Doctrine \DBAL \Connection ;
77use Mouf \MoufManager ;
88use Mouf \MoufInstanceDescriptor ;
99use SQLParser \Node \Traverser \NodeTraverser ;
@@ -89,14 +89,15 @@ public function toInstanceDescriptor(MoufManager $moufManager)
8989 /**
9090 * Renders the object as a SQL string.
9191 *
92- * @param Connection $dbConnection
93- * @param array $parameters
94- * @param number $indent
95- * @param int $conditionsMode
92+ * @param array $parameters
93+ * @param AbstractPlatform $platform
94+ * @param int $indent
95+ * @param int $conditionsMode
9696 *
97+ * @param bool $extrapolateParameters
9798 * @return string
9899 */
99- public function toSql (array $ parameters = array (), Connection $ dbConnection = null , $ indent = 0 , $ conditionsMode = self ::CONDITION_APPLY , bool $ extrapolateParameters = true )
100+ public function toSql (array $ parameters, AbstractPlatform $ platform , int $ indent = 0 , $ conditionsMode = self ::CONDITION_APPLY , bool $ extrapolateParameters = true ): ? string
100101 {
101102 if ($ conditionsMode == self ::CONDITION_GUESS ) {
102103 $ bypass = false ;
@@ -107,25 +108,25 @@ public function toSql(array $parameters = array(), Connection $dbConnection = nu
107108 $ bypass = true ;
108109 }
109110 if ($ bypass === true ) {
110- return ;
111+ return null ;
111112 } else {
112113 $ conditionsMode = self ::CONDITION_IGNORE ;
113114 }
114115 }
115116 if ($ conditionsMode == self ::CONDITION_IGNORE || !$ this ->condition || $ this ->condition ->isOk ($ parameters )) {
116- $ sql = $ this ->getSql ($ parameters , $ dbConnection , $ indent , $ conditionsMode , $ extrapolateParameters );
117+ $ sql = $ this ->getSql ($ parameters , $ platform , $ indent , $ conditionsMode , $ extrapolateParameters );
117118 } else {
118119 $ sql = null ;
119120 }
120121
121122 return $ sql ;
122123 }
123124
124- protected function getSql (array $ parameters = array (), Connection $ dbConnection = null , $ indent = 0 , $ conditionsMode = self ::CONDITION_APPLY , bool $ extrapolateParameters = true )
125+ protected function getSql (array $ parameters, AbstractPlatform $ platform , $ indent = 0 , $ conditionsMode = self ::CONDITION_APPLY , bool $ extrapolateParameters = true )
125126 {
126- $ sql = NodeFactory::toSql ($ this ->leftOperand , $ dbConnection , $ parameters , ' ' , false , $ indent , $ conditionsMode , $ extrapolateParameters );
127+ $ sql = NodeFactory::toSql ($ this ->leftOperand , $ platform , $ parameters , ' ' , false , $ indent , $ conditionsMode , $ extrapolateParameters );
127128 $ sql .= ' ' .$ this ->getOperatorSymbol ().' ' ;
128- $ sql .= NodeFactory::toSql ($ this ->rightOperand , $ dbConnection , $ parameters , ' ' , false , $ indent , $ conditionsMode , $ extrapolateParameters );
129+ $ sql .= NodeFactory::toSql ($ this ->rightOperand , $ platform , $ parameters , ' ' , false , $ indent , $ conditionsMode , $ extrapolateParameters );
129130
130131 return $ sql ;
131132 }
0 commit comments