1818use Yiisoft \Json \Json ;
1919
2020/**
21- * The class JsonExpressionBuilder builds {@see JsonExpression} for PostgreSQL DBMS .
21+ * Builds expressions for {@see `Yiisoft\Db\Expression\ JsonExpression` } for PostgresSQL Server .
2222 */
2323final class JsonExpressionBuilder implements ExpressionBuilderInterface
2424{
@@ -29,18 +29,23 @@ public function __construct(private QueryBuilderInterface $queryBuilder)
2929 /**
3030 * Method builds the raw SQL from the $expression that will not be additionally escaped or quoted.
3131 *
32- * @param ExpressionInterface $expression the expression to be built.
33- * @param array $params the binding parameters.
32+ * @param ExpressionInterface $expression The expression to be built.
33+ * @param array $params The binding parameters.
3434 *
35- * @throws Exception|InvalidArgumentException|InvalidConfigException|JsonException|NotSupportedException
35+ * @throws Exception
36+ * @throws InvalidArgumentException
37+ * @throws InvalidConfigException
38+ * @throws JsonException
39+ * @throws NotSupportedException
3640 *
37- * @return string the raw SQL that will not be additionally escaped or quoted.
41+ * @return string The raw SQL that will not be additionally escaped or quoted.
42+ *
43+ * @psalm-param JsonExpression $expression
3844 */
3945 public function build (ExpressionInterface $ expression , array &$ params = []): string
4046 {
4147 /**
42- * @var JsonExpression $expression
43- * @var array|mixed|QueryInterface $value
48+ * @psalm-var array|mixed|QueryInterface $value
4449 */
4550 $ value = $ expression ->getValue ();
4651
@@ -59,14 +64,15 @@ public function build(ExpressionInterface $expression, array &$params = []): str
5964 }
6065
6166 /**
62- * @return string the typecast expression based on {@see type }.
67+ * @return string The typecast expression based on {@see JsonExpression::getType() }.
6368 */
6469 protected function getTypecast (JsonExpression $ expression ): string
6570 {
66- if ($ expression ->getType () === null ) {
67- return '' ;
68- }
71+ $ type = $ expression ->getType ();
6972
70- return ':: ' . (string ) $ expression ->getType ();
73+ return match ($ type !== null ) {
74+ true => ':: ' . $ type ,
75+ default => '' ,
76+ };
7177 }
7278}
0 commit comments