2
2
3
3
namespace SQLParser\Node;
4
4
5
+ use Doctrine\DBAL\Platforms\AbstractPlatform;
5
6
use Mouf\Utils\Common\ConditionInterface\ConditionTrait;
6
- use Doctrine\DBAL\Connection;
7
7
use Mouf\MoufManager;
8
8
use Mouf\MoufInstanceDescriptor;
9
9
use SQLParser\Node\Traverser\NodeTraverser;
@@ -89,14 +89,15 @@ public function toInstanceDescriptor(MoufManager $moufManager)
89
89
/**
90
90
* Renders the object as a SQL string.
91
91
*
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
96
96
*
97
+ * @param bool $extrapolateParameters
97
98
* @return string
98
99
*/
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
100
101
{
101
102
if ($conditionsMode == self::CONDITION_GUESS) {
102
103
$bypass = false;
@@ -107,25 +108,25 @@ public function toSql(array $parameters = array(), Connection $dbConnection = nu
107
108
$bypass = true;
108
109
}
109
110
if ($bypass === true) {
110
- return;
111
+ return null ;
111
112
} else {
112
113
$conditionsMode = self::CONDITION_IGNORE;
113
114
}
114
115
}
115
116
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);
117
118
} else {
118
119
$sql = null;
119
120
}
120
121
121
122
return $sql;
122
123
}
123
124
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)
125
126
{
126
- $sql = NodeFactory::toSql($this->leftOperand, $dbConnection , $parameters, ' ', false, $indent, $conditionsMode, $extrapolateParameters);
127
+ $sql = NodeFactory::toSql($this->leftOperand, $platform , $parameters, ' ', false, $indent, $conditionsMode, $extrapolateParameters);
127
128
$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);
129
130
130
131
return $sql;
131
132
}
0 commit comments