classAttributeReader
final class AttributeReader
Reads the value of a definition attribute the way its command does.
Rule: PG-DEFINE-READ-001. The attribute name is looked up, respecting case, in the set of the defining command. A recognized attribute's value is read as its reading prescribes when the defGet* function of that reading accepts it: a name from anything but a number or no value, a type from a type name, string or keyword, a Boolean from no value, 0, 1 or the texts true, false, on and off, an integer from a 32-bit integer, text from any value, a type length from a 32-bit integer or variable, and a choice from a text that names a member. Any other value is kept as written, and the defining command's checks report it. A plain name written as a type name is kept as a dotted name. Lowering and the attribute constructor use the same reading, so the reading of a written value is unique. Terminates: no recursion. Source: src/backend/commands/define.c of PostgreSQL 17, https://www.postgresql.org/docs/17/sql-createoperator.html. Status: Implemented.
Methods§
public function command(ObjectKind $kind): class-string<KnownAttribute>Answers the attribute set of the command that defines objects of a kind.
Parameters
$kind | ObjectKind |
Returns
class-string<KnownAttribute>Test cases 2
Called from 3
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Routine\DefineRule::attributes() packages/sql-semantics-postgres/src/Lowering/Routine/DefineRule.php:116
- method-call SqlSemantics\Platform\PostgreSql\Rules\Routine\DefineChecks::derive() packages/sql-semantics-postgres/src/Rules/Routine/DefineChecks.php:64
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\Define::__construct() packages/sql-semantics-postgres/src/Statement/Object/Define.php:72
Calls 2
- class-const AttributeReader::COMMANDS() line 80
- static-call Check::input() line 81
public function attribute(
class-string<KnownAttribute> $command,
Name $name,
TypeName|KeywordWord|OperatorName|SignedNumber|StringConstant|null $value,
): AttributeBuilds an attribute of the command whose attribute set is given.
Parameters
$command | class-string<KnownAttribute> | The attribute set of the command |
$name | Name | |
$value | TypeName|KeywordWord|OperatorName|SignedNumber|StringConstant|null |
Returns
Called from 4
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Routine\DefineRule::read() packages/sql-semantics-postgres/src/Lowering/Routine/DefineRule.php:132
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Routine\OperatorClassRule::changes() packages/sql-semantics-postgres/src/Lowering/Routine/OperatorClassRule.php:203
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Routine\OperatorClassRule::changes() packages/sql-semantics-postgres/src/Lowering/Routine/OperatorClassRule.php:204
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Routine\OperatorClassRule::changes() packages/sql-semantics-postgres/src/Lowering/Routine/OperatorClassRule.php:205
Calls 2
- new Attribute line 95
- method-call AttributeReader::read() line 95
public function read(
Reading $reading,
TypeName|KeywordWord|OperatorName|SignedNumber|StringConstant|null $value,
): AttributeArgument|TypeName|KeywordWord|OperatorName|SignedNumber|StringConstant|nullReads a written value; a value the reading rejects is answered as written.
Parameters
$reading | Reading | |
$value | TypeName|KeywordWord|OperatorName|SignedNumber|StringConstant|null |
Test cases 2
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Rules\Routine\AttributeReader::attribute() packages/sql-semantics-postgres/src/Rules/Routine/AttributeReader.php:95
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\Attribute::__construct() packages/sql-semantics-postgres/src/Statement/Object/Attribute/Attribute.php:61
Calls 17
- method-call Reading::kind() line 103
- method-call Reading::choices() line 104
- method-call AttributeReader::name() line 106
- method-call AttributeReader::choice() line 109
- class-const Reading::Type() line 113
- new TypeArgument line 113
- class-const Reading::Boolean() line 114
- method-call AttributeReader::boolean() line 114
- new BooleanArgument line 114
- class-const Reading::Integer() line 115
- method-call ArgumentText::integer() line 115
- new ArgumentText line 115
- new IntegerArgument line 115
- class-const Reading::Text() line 116
- new TextArgument line 116
- class-const Reading::Length() line 117
- method-call AttributeReader::length() line 117
public function name(
ObjectKind $kind,
TypeName|KeywordWord|OperatorName|SignedNumber|StringConstant|null $value,
): NameArgument|SignedNumber|nullReads a value as the name of an object of a kind; no value and a number are not names.
Parameters
$kind | ObjectKind | |
$value | TypeName|KeywordWord|OperatorName|SignedNumber|StringConstant|null |
Returns
NameArgument|SignedNumber|nullTest cases 1
Called from 1
Calls 2
- new NameArgument line 132
- method-call AttributeReader::plain() line 132
public function choice(
class-string<Choice> $choices,
TypeName|KeywordWord|OperatorName|SignedNumber|StringConstant|null $value,
): ChoiceArgument|TypeName|KeywordWord|OperatorName|SignedNumber|StringConstant|nullReads a value as one of a set of words.
Parameters
$choices | class-string<Choice> | |
$value | TypeName|KeywordWord|OperatorName|SignedNumber|StringConstant|null |
Test cases 1
Called from 1
Calls 3
- method-call ArgumentText::text() line 142
- new ArgumentText line 142
- new ChoiceArgument line 144
public function length(TypeName|KeywordWord|OperatorName|SignedNumber|StringConstant|null $value): LengthArgument|TypeName|KeywordWord|OperatorName|SignedNumber|StringConstant|nullReads a value as a type length.
Parameters
$value | TypeName|KeywordWord|OperatorName|SignedNumber|StringConstant|null |
Test cases 1
Called from 1
Calls 5
- new ArgumentText line 152
- method-call ArgumentText::integer() line 154
- function-call
strtolowerline 155 - method-call ArgumentText::text() line 155
- new LengthArgument line 159
public function boolean(TypeName|KeywordWord|OperatorName|SignedNumber|StringConstant|null $value): ?boolAnswers the Boolean a value reads as, or null when it is not a Boolean; no value is true.
Parameters
$value | TypeName|KeywordWord|OperatorName|SignedNumber|StringConstant|null |
Returns
?boolTest cases 1
Called from 3
- method-call SqlSemantics\Platform\PostgreSql\Rules\Routine\AttributeReader::read() packages/sql-semantics-postgres/src/Rules/Routine/AttributeReader.php:114
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\BooleanArgument::__construct() packages/sql-semantics-postgres/src/Statement/Object/Attribute/BooleanArgument.php:43
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\BooleanArgument::value() packages/sql-semantics-postgres/src/Statement/Object/Attribute/BooleanArgument.php:51
Calls 4
- new ArgumentText line 170
- method-call ArgumentText::integer() line 171
- function-call
strtolowerline 176 - method-call ArgumentText::text() line 176
public function plain(TypeName $type): boolTells whether a type name is a plain, possibly qualified, name without modifiers, array bounds or SETOF.
Parameters
$type | TypeName |
Returns
boolTest cases 1
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Rules\Routine\AttributeReader::name() packages/sql-semantics-postgres/src/Rules/Routine/AttributeReader.php:132
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\NameArgument::__construct() packages/sql-semantics-postgres/src/Statement/Object/Attribute/NameArgument.php:56
Private surface 1§
Implementation details, listed for orientation only.
private const COMMANDS = ['AGGREGATE' => \SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\Kn…Test cases 10§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 10
AttributeReaderTest::testAttributeReadsARecognizedNameAndKeepsAnotherAsWrittencallsAttributeReaderTest::testBooleanReadsTheServerSpellingscallsAttributeReaderTest::testChoiceReadsOnlyAMemberTextcallsAttributeReaderTest::testCommandAnswersTheAttributeSetOfAKindcallsAttributeReaderTest::testCommandRejectsAKindWithoutAttributescallsAttributeReaderTest::testLengthReadsANumberOrVariablecallsAttributeReaderTest::testNameUnwrapsAPlainTypeNameAndRejectsNumberscallsAttributeReaderTest::testPlainRejectsModifiersArraysAndSetofcallsAttributeReaderTest::testReadKeepsARejectedValueAsWrittencallsAttributeReaderTest::testReadYieldsTheArgumentOfEachReadingcalls
Relations§
Instantiated in 9
- new SqlSemantics\Platform\PostgreSql\Lowering\Routine\DefineRule::attributes() packages/sql-semantics-postgres/src/Lowering/Routine/DefineRule.php:116
- new SqlSemantics\Platform\PostgreSql\Lowering\Routine\DefineRule::read() packages/sql-semantics-postgres/src/Lowering/Routine/DefineRule.php:129
- new SqlSemantics\Platform\PostgreSql\Lowering\Routine\OperatorClassRule::changes() packages/sql-semantics-postgres/src/Lowering/Routine/OperatorClassRule.php:197
- new SqlSemantics\Platform\PostgreSql\Rules\Routine\DefineChecks::derive() packages/sql-semantics-postgres/src/Rules/Routine/DefineChecks.php:64
- new SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\Attribute::__construct() packages/sql-semantics-postgres/src/Statement/Object/Attribute/Attribute.php:61
- new SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\BooleanArgument::__construct() packages/sql-semantics-postgres/src/Statement/Object/Attribute/BooleanArgument.php:43
- new SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\BooleanArgument::value() packages/sql-semantics-postgres/src/Statement/Object/Attribute/BooleanArgument.php:51
- new SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\NameArgument::__construct() packages/sql-semantics-postgres/src/Statement/Object/Attribute/NameArgument.php:56
- new SqlSemantics\Platform\PostgreSql\Statement\Object\Define::__construct() packages/sql-semantics-postgres/src/Statement/Object/Define.php:72
Method calls 11
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Routine\DefineRule::attributes() packages/sql-semantics-postgres/src/Lowering/Routine/DefineRule.php:116
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Routine\DefineRule::read() packages/sql-semantics-postgres/src/Lowering/Routine/DefineRule.php:132
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Routine\OperatorClassRule::changes() packages/sql-semantics-postgres/src/Lowering/Routine/OperatorClassRule.php:203
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Routine\OperatorClassRule::changes() packages/sql-semantics-postgres/src/Lowering/Routine/OperatorClassRule.php:204
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Routine\OperatorClassRule::changes() packages/sql-semantics-postgres/src/Lowering/Routine/OperatorClassRule.php:205
- method-call SqlSemantics\Platform\PostgreSql\Rules\Routine\DefineChecks::derive() packages/sql-semantics-postgres/src/Rules/Routine/DefineChecks.php:64
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\Attribute::__construct() packages/sql-semantics-postgres/src/Statement/Object/Attribute/Attribute.php:61
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\BooleanArgument::__construct() packages/sql-semantics-postgres/src/Statement/Object/Attribute/BooleanArgument.php:43
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\BooleanArgument::value() packages/sql-semantics-postgres/src/Statement/Object/Attribute/BooleanArgument.php:51
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\NameArgument::__construct() packages/sql-semantics-postgres/src/Statement/Object/Attribute/NameArgument.php:56
- method-call SqlSemantics\Platform\PostgreSql\Statement\Object\Define::__construct() packages/sql-semantics-postgres/src/Statement/Object/Define.php:72