File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 147147- Chg #1054 : Rename ` ArrayExpression ` to ` ArrayValue ` , ` JsonExpression ` to ` JsonValue ` ,
148148 ` StructuredExpression ` to ` StructuredValue ` (@Tigrov )
149149- Chg #1056 : Remove unused exceptions (@Tigrov )
150+ - Chg #1058 : Refactor ` Expression ` class: declare ` $expression ` and ` $params ` as public readonly properties, remove
151+ ` getParams() ` method (@vjik )
150152
151153## 1.3.0 March 21, 2024
152154
Original file line number Diff line number Diff line change @@ -280,4 +280,5 @@ Each table column has its own class in the `Yiisoft\Db\Schema\Column` namespace
280280- Rename ` StructuredExpressionBuilder ` to ` StructuredValueBuilder ` and move it to ` Yiisoft\Db\Expression\Value\Builder `
281281 namespace;
282282- Remove ` StaleObjectException ` , ` UnknownMethodException ` , ` UnknownPropertyException ` classes;
283+ - Remove ` Expression::getParams() ` method, use ` $params ` property instead;
283284
Original file line number Diff line number Diff line change 2929final class Expression implements ExpressionInterface, Stringable
3030{
3131 /**
32+ * @param string $expression The DB expression.
33+ * @param array $params List of parameters to bind to this expression. The keys are placeholders appearing in
34+ * {@see expression} and the values are the corresponding parameter values.
35+ *
3236 * @psalm-param ParamsType $params
3337 */
34- public function __construct (private readonly string $ expression , private readonly array $ params = [])
35- {
38+ public function __construct (
39+ public readonly string $ expression ,
40+ public readonly array $ params = [],
41+ ) {
3642 }
3743
3844 /**
@@ -42,15 +48,4 @@ public function __toString(): string
4248 {
4349 return $ this ->expression ;
4450 }
45-
46- /**
47- * @return array List of parameters to bind to this expression. The keys are placeholders appearing in
48- * {@see expression} and the values are the corresponding parameter values.
49- *
50- * @psalm-return ParamsType
51- */
52- public function getParams (): array
53- {
54- return $ this ->params ;
55- }
5651}
Original file line number Diff line number Diff line change @@ -44,8 +44,8 @@ public function __construct(private readonly QueryBuilderInterface $queryBuilder
4444 */
4545 public function build (ExpressionInterface $ expression , array &$ params = []): string
4646 {
47- $ sql = $ expression ->__toString () ;
48- $ expressionParams = $ expression ->getParams () ;
47+ $ sql = $ expression ->expression ;
48+ $ expressionParams = $ expression ->params ;
4949
5050 if (empty ($ expressionParams )) {
5151 return $ sql ;
You can’t perform that action at this time.
0 commit comments