classLengthArgument
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.
$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]new \SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\LengthArgument(new \SqlSemantics\Platform\PostgreSql\Statement\Literal\StringConstant('fixed')) // throws \SqlSemantics\Platform\PostgreSql\Model\Diagnostic\InvalidConstructionProperties§
public SignedNumber|StringConstant|TypeName $lengthMethods§
public function __construct(public SignedNumber|StringConstant|TypeName $length)Parameters
$length | SignedNumber|StringConstant|TypeName | The length as written |
Calls 5
- new ArgumentText line 40
- static-call Check::input() line 41
- method-call ArgumentText::integer() line 41
- function-call
strtolowerline 41 - method-call ArgumentText::text() line 41
public function bytes(): ?intAnswers the length in bytes, or null for a variable length.
Returns
?intTest cases 1
Calls 2
- method-call ArgumentText::integer() line 49
- new ArgumentText line 49
public function variable(): boolTells whether the length is written as variable.
Returns
boolTest cases 1
public function fits(Reading $reading): boolTells whether the reading reads a type length.
Parameters
$reading | Reading |
Returns
boolTest cases 1
Calls 1
- class-const Reading::Length() line 65
public function deriveClause(Derivation $derivation, Environment $environment): voidDerives the modifier expressions of a value written as a type name.
Parameters
$derivation | Derivation | |
$environment | Environment |
Test cases 1
public function render(Output $out): voidWrites the length as written.
Parameters
$out | Output |
Test cases 1
Calls 1
- method-call Output::node() line 81
Test cases 8§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 6
LengthArgumentTest::testBytesAnswersTheIntegerOrNullcallsLengthArgumentTest::testDeriveClauseRecordsNothingForANumbercallsLengthArgumentTest::testFitsOnlyALengthReadingcallsLengthArgumentTest::testRejectsAnotherWordcallsLengthArgumentTest::testRenderWritesTheLengthAsWrittencallsLengthArgumentTest::testVariableTellsTheWordVariablecalls