classArrayConstructor
final class ArrayConstructor
implements Scalar, OutputNaming
uses Snapshot
@visibility public.An array built from values: ARRAY[a, b], ARRAY[[a, b], [c, d]].
Mirrors PostgreSQL's A_ArrayExpr node.
Rule: PG-ARRAY-CONSTRUCTOR-001. Facts: an array of the common type of the values (PG-UNIFICATION-001; unknown-typed values give text); values that are arrays, and sub-arrays, make a multidimensional array of the same type; an empty array has no element type of its own, which a cast supplies; the array is never NULL. An unaliased result column is named array. Source: https://www.postgresql.org/docs/17/sql-expressions.html#SQL-SYNTAX-ARRAY-CONSTRUCTORS. Status: Implemented.
(new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('SELECT ARRAY[1, 2.5]')->field(0)->type->descriptor->name() // => 'numeric[]'Properties§
public ArrayItems $itemsMethods§
public function __construct(public ArrayItems $items)Parameters
$items | ArrayItems | The bracketed items |
public function outputName(): NameNames an unaliased result column array.
Returns
Test cases 1
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives every value and the array type.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 4
- new ScalarFact line 58
- method-call ArrayTyping::items() line 58
- new ArrayTyping line 58
- class-const Nullability::NotNull() line 58
public function render(Output $out): voidWrites ARRAY and the items.
Parameters
$out | Output |
Test cases 1
Calls 1
- method-call Output::keyword() line 66
Test cases 5§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.