final class LengthArgument
    implements AttributeArgument
    uses Snapshot
Public API: explicitly declared with @visibility public.

The internallength of a base type: a number of bytes, or variable.

defGetTypeLength accepts a 32-bit integer, or variable without regard to case written as a string or a word. Source: https://www.postgresql.org/docs/17/sql-createtype.html, defGetTypeLength in src/backend/commands/define.c of PostgreSQL 17.

Reading a variable lengthdoctest
$operation = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('CREATE TYPE box3 (input = box3_in, output = box3_out, internallength = VARIABLE)');
    [$operation->statement->definition[2]->value->bytes(), $operation->statement->definition[2]->value->variable()] // => [null, true]
Rejecting another worddoctest
new \SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\LengthArgument(new \SqlSemantics\Platform\PostgreSql\Statement\Literal\StringConstant('fixed')) // throws \SqlSemantics\Platform\PostgreSql\Model\Diagnostic\InvalidConstruction

Properties§

Methods§

public function __construct(public SignedNumber|StringConstant|TypeName $length)

Parameters

$lengthSignedNumber|StringConstant|TypeNameThe length as written
Calls 5
public function bytes(): ?int

Answers the length in bytes, or null for a variable length.

Returns

?int
Test cases 1
Calls 2
public function variable(): bool

Tells whether the length is written as variable.

Returns

bool
Test cases 1
public function fits(Reading $reading): bool

Tells whether the reading reads a type length.

Parameters

$readingReading

Returns

bool
Test cases 1
Calls 1
public function deriveClause(Derivation $derivation, Environment $environment): void

Derives the modifier expressions of a value written as a type name.

Parameters

$derivationDerivation
$environmentEnvironment
Test cases 1
public function render(Output $out): void

Writes the length as written.

Parameters

$outOutput
Test cases 1
Calls 1

Test cases 8§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 6
Other tests reaching this symbol 2

Relations§

Instantiated in 1
Type declarations 1