classSignedNumber
final class SignedNumber
implements OptionArgument
uses Snapshot
@visibility public.A number with an optional minus sign, written where the grammar reads NumericOnly instead of an expression.
Sequence options, storage parameters and configuration values take such numbers. A written plus sign changes nothing and is not kept. The grammar makes an integer node of a negated integer constant, and a float node of a negated numeric constant whose text is the constant's text after a minus sign (doNegateFloat); commands that read the value as text receive that. Source: https://www.postgresql.org/docs/17/sql-createsequence.html, NumericOnly and SignedIconst in src/backend/parser/gram.y of PostgreSQL 17.
$number = new \SqlSemantics\Platform\PostgreSql\Statement\Literal\SignedNumber(true, new \SqlSemantics\Platform\PostgreSql\Statement\Literal\IntegerConstant('5'));
[$number->negative, $number->magnitude->digits] // => [true, '5']$operation = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('SET application_name = -.5');
[$operation->statement->values[0]->text(), $operation->toString()] // => ['-.5', 'SET application_name TO - .5']Properties§
public bool $negativepublic IntegerConstant|NumericConstant $magnitudeMethods§
public function __construct(
public bool $negative,
public IntegerConstant|NumericConstant $magnitude,
)Parameters
$negative | bool | Whether a minus sign is written |
$magnitude | IntegerConstant|NumericConstant | The number after the sign |
public function text(): stringAnswers the text the server stores for the number: the integer it denotes, or the written text of a numeric constant after the sign.
Returns
stringTest cases 1
Called from 3
- method-call SqlSemantics\Platform\PostgreSql\Rules\Access\ObjectIdentifiers::problem() packages/sql-semantics-postgres/src/Rules/Access/ObjectIdentifiers.php:73
- method-call SqlSemantics\Platform\PostgreSql\Rules\Access\ObjectIdentifiers::problem() packages/sql-semantics-postgres/src/Rules/Access/ObjectIdentifiers.php:76
- method-call SqlSemantics\Platform\PostgreSql\Rules\Routine\ArgumentText::number() packages/sql-semantics-postgres/src/Rules/Routine/ArgumentText.php:85
public function deriveClause(Derivation $derivation, Environment $environment): voidDerives nothing: a number holds no expression.
Parameters
$derivation | Derivation | |
$environment | Environment |
Test cases 1
public function render(Output $out): voidWrites the minus sign and the number.
Parameters
$out | Output |
Test cases 1
Calls 2
- method-call Output::symbol() line 69
- method-call Output::node() line 71
Test cases 49§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 3
Other tests reaching this symbol 46
OptionsTest::testArgumentLowersEveryValueKindcallsOptionsTest::testDefinitionLowersOneElementcallsOptionsTest::testValueLowersKeywordsWordsStringsAndNumberscallsOptionRuleTest::testArgumentLowersEachValuecallsSettingRuleTest::testZoneLowersEachFormcallsObjectIdentifiersTest::testProblemAcceptsEveryIntegerConstantcallsObjectIdentifiersTest::testProblemRejectsANegativeValueBeyondTheSignExtensioncallsObjectIdentifiersTest::testProblemRejectsAValueOfMoreThanTenDigitscallsArgumentTextTest::testIntegerAnswersOnlyThirtyTwoBitIntegerscallsArgumentTextTest::testNumberWritesTheTextOfAFloatAsWrittencallsArgumentTextTest::testTextReadsEachValueKindcallsAttributeChecksTest::testRejectedAnswersTheMessageOfEachReadingcallsAttributeReaderTest::testBooleanReadsTheServerSpellingscallsAttributeReaderTest::testLengthReadsANumberOrVariablecallsAttributeReaderTest::testNameUnwrapsAPlainTypeNameAndRejectsNumberscallsAttributeReaderTest::testReadKeepsARejectedValueAsWrittencallsAttributeReaderTest::testReadYieldsTheArgumentOfEachReadingcallsObjectFormsTest::testFormNamesEachReferencecallsOptionArgumentsTest::testBooleanReadsTheValuesTheServerAcceptscallsOptionArgumentsTest::testBooleanRefusesOtherValuescallsOptionArgumentsTest::testIntegerReadsIntegersThatFitIn32BitscallsRoleConnectionLimitTest::testAcceptableFromMinusOnecallsRoleConnectionLimitTest::testOptioncallsRoleConnectionLimitTest::testRejectsAFractioncallsLargeObjectsTargetTest::testObjectcallsAttributeTest::testAcceptsAWrittenValueTheCommandRejectscallsBooleanArgumentTest::testRejectsAnotherIntegercallsBooleanArgumentTest::testValueReadsEachSpellingcallsIntegerArgumentTest::testDeriveClauseRecordsNothingcallsIntegerArgumentTest::testFitsOnlyAnIntegerReadingcallsIntegerArgumentTest::testRejectsANumberWithAPointcallsIntegerArgumentTest::testRenderWritesTheNumbercallsIntegerArgumentTest::testValueKeepsTheSigncallsLengthArgumentTest::testBytesAnswersTheIntegerOrNullcallsLengthArgumentTest::testDeriveClauseRecordsNothingForANumbercallsLengthArgumentTest::testVariableTellsTheWordVariablecallsTextArgumentTest::testRenderWritesTheValueAsWrittencallsLargeObjectNumberTest::testDeriveClauseRecordsNothingcallsLargeObjectNumberTest::testRenderWritesTheIdentifiercallsDefinitionTest::testRenderWritesNamespaceNameAndValuecallsOptionArgumentTest::testTheValueKindsOfTheOptionSyntaxAreArgumentscallsRoutineEstimateTest::testAlterableIsTruecallsRoutineEstimateTest::testDeriveClauseRecordsNothingcallsRoutineEstimateTest::testRenderWritesKeywordAndNumbercallsRoutineEstimateTest::testSettingNamesTheEstimatecallsUtilityOptionTest::testTextAnswersTheValueAsTheServerReceivesItcalls
Relations§
Instantiated in 6
- new SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Literals::signed() packages/sql-semantics-postgres/src/Lowering/Leaf/Literals.php:131
- new SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Literals::signed() packages/sql-semantics-postgres/src/Lowering/Leaf/Literals.php:132
- new SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Literals::signed() packages/sql-semantics-postgres/src/Lowering/Leaf/Literals.php:133
- new SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Literals::signed() packages/sql-semantics-postgres/src/Lowering/Leaf/Literals.php:134
- new SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Literals::signed() packages/sql-semantics-postgres/src/Lowering/Leaf/Literals.php:135
- new SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Literals::signed() packages/sql-semantics-postgres/src/Lowering/Leaf/Literals.php:136
Method calls 3
- method-call SqlSemantics\Platform\PostgreSql\Rules\Access\ObjectIdentifiers::problem() packages/sql-semantics-postgres/src/Rules/Access/ObjectIdentifiers.php:73
- method-call SqlSemantics\Platform\PostgreSql\Rules\Access\ObjectIdentifiers::problem() packages/sql-semantics-postgres/src/Rules/Access/ObjectIdentifiers.php:76
- method-call SqlSemantics\Platform\PostgreSql\Rules\Routine\ArgumentText::number() packages/sql-semantics-postgres/src/Rules/Routine/ArgumentText.php:85
Constant reads 1
Type checks 15
- instanceof SqlSemantics\Platform\PostgreSql\Lowering\Utility\OptionRule::argument() packages/sql-semantics-postgres/src/Lowering/Utility/OptionRule.php:102
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Routine\ArgumentText::text() packages/sql-semantics-postgres/src/Rules/Routine/ArgumentText.php:47
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Routine\AttributeChecks::rejected() packages/sql-semantics-postgres/src/Rules/Routine/AttributeChecks.php:144
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Routine\AttributeReader::read() packages/sql-semantics-postgres/src/Rules/Routine/AttributeReader.php:115
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Routine\AttributeReader::name() packages/sql-semantics-postgres/src/Rules/Routine/AttributeReader.php:127
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Routine\AttributeReader::length() packages/sql-semantics-postgres/src/Rules/Routine/AttributeReader.php:154
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Routine\AttributeReader::length() packages/sql-semantics-postgres/src/Rules/Routine/AttributeReader.php:159
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Routine\AttributeReader::boolean() packages/sql-semantics-postgres/src/Rules/Routine/AttributeReader.php:171
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Utility\OptionArguments::boolean() packages/sql-semantics-postgres/src/Rules/Utility/OptionArguments.php:43
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Utility\OptionArguments::integer() packages/sql-semantics-postgres/src/Rules/Utility/OptionArguments.php:71
- instanceof SqlSemantics\Platform\PostgreSql\Statement\Manipulation\Copy\CopyOption::__construct() packages/sql-semantics-postgres/src/Statement/Manipulation/Copy/CopyOption.php:46
- instanceof SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\LengthArgument::__construct() packages/sql-semantics-postgres/src/Statement/Object/Attribute/LengthArgument.php:41
- instanceof SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\LengthArgument::bytes() packages/sql-semantics-postgres/src/Statement/Object/Attribute/LengthArgument.php:49
- instanceof SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\LengthArgument::variable() packages/sql-semantics-postgres/src/Statement/Object/Attribute/LengthArgument.php:57
- instanceof SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\UtilityOption::text() packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/UtilityOption.php:93
Type declarations 33
- type SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Literals packages/sql-semantics-postgres/src/Lowering/Leaf/Literals.php:125
- type SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Options packages/sql-semantics-postgres/src/Lowering/Leaf/Options.php:140
- type SqlSemantics\Platform\PostgreSql\Lowering\Routine\OperatorClassRule packages/sql-semantics-postgres/src/Lowering/Routine/OperatorClassRule.php:218
- type SqlSemantics\Platform\PostgreSql\Lowering\Table\AlterCommandRule packages/sql-semantics-postgres/src/Lowering/Table/AlterCommandRule.php:267
- type SqlSemantics\Platform\PostgreSql\Lowering\Utility\OptionRule packages/sql-semantics-postgres/src/Lowering/Utility/OptionRule.php:93
- type SqlSemantics\Platform\PostgreSql\Lowering\Utility\SettingRule packages/sql-semantics-postgres/src/Lowering/Utility/SettingRule.php:205
- type SqlSemantics\Platform\PostgreSql\Rules\Access\ObjectIdentifiers packages/sql-semantics-postgres/src/Rules/Access/ObjectIdentifiers.php:65
- type SqlSemantics\Platform\PostgreSql\Rules\Routine\ArgumentText packages/sql-semantics-postgres/src/Rules/Routine/ArgumentText.php:41
- type SqlSemantics\Platform\PostgreSql\Rules\Routine\ArgumentText packages/sql-semantics-postgres/src/Rules/Routine/ArgumentText.php:70
- type SqlSemantics\Platform\PostgreSql\Rules\Routine\ArgumentText packages/sql-semantics-postgres/src/Rules/Routine/ArgumentText.php:83
- type SqlSemantics\Platform\PostgreSql\Rules\Routine\AttributeChecks packages/sql-semantics-postgres/src/Rules/Routine/AttributeChecks.php:128
- type SqlSemantics\Platform\PostgreSql\Rules\Routine\AttributeReader packages/sql-semantics-postgres/src/Rules/Routine/AttributeReader.php:91
- type SqlSemantics\Platform\PostgreSql\Rules\Routine\AttributeReader packages/sql-semantics-postgres/src/Rules/Routine/AttributeReader.php:101
- type SqlSemantics\Platform\PostgreSql\Rules\Routine\AttributeReader packages/sql-semantics-postgres/src/Rules/Routine/AttributeReader.php:125
- type SqlSemantics\Platform\PostgreSql\Rules\Routine\AttributeReader packages/sql-semantics-postgres/src/Rules/Routine/AttributeReader.php:140
- type SqlSemantics\Platform\PostgreSql\Rules\Routine\AttributeReader packages/sql-semantics-postgres/src/Rules/Routine/AttributeReader.php:150
- type SqlSemantics\Platform\PostgreSql\Rules\Routine\AttributeReader packages/sql-semantics-postgres/src/Rules/Routine/AttributeReader.php:165
- type SqlSemantics\Platform\PostgreSql\Statement\Catalog\Access\Role\RoleConnectionLimit packages/sql-semantics-postgres/src/Statement/Catalog/Access/Role/RoleConnectionLimit.php:37
- type SqlSemantics\Platform\PostgreSql\Statement\Manipulation\Cursor\Fetch packages/sql-semantics-postgres/src/Statement/Manipulation/Cursor/Fetch.php:49
- type SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\Attribute packages/sql-semantics-postgres/src/Statement/Object/Attribute/Attribute.php:55
- type SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\BooleanArgument packages/sql-semantics-postgres/src/Statement/Object/Attribute/BooleanArgument.php:41
- type SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\ChoiceArgument packages/sql-semantics-postgres/src/Statement/Object/Attribute/ChoiceArgument.php:42
- type SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\IntegerArgument packages/sql-semantics-postgres/src/Statement/Object/Attribute/IntegerArgument.php:37
- type SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\LengthArgument packages/sql-semantics-postgres/src/Statement/Object/Attribute/LengthArgument.php:38
- type SqlSemantics\Platform\PostgreSql\Statement\Object\Attribute\TextArgument packages/sql-semantics-postgres/src/Statement/Object/Attribute/TextArgument.php:39
- type SqlSemantics\Platform\PostgreSql\Statement\Object\Reference\LargeObjectNumber packages/sql-semantics-postgres/src/Statement/Object/Reference/LargeObjectNumber.php:31
- type SqlSemantics\Platform\PostgreSql\Statement\Routine\Option\RoutineEstimate packages/sql-semantics-postgres/src/Statement/Routine/Option/RoutineEstimate.php:31
- type SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\ColumnStatistics packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/ColumnStatistics.php:37
- type SqlSemantics\Platform\PostgreSql\Statement\Table\Alter\Column\IdentityRestart packages/sql-semantics-postgres/src/Statement/Table/Alter/Column/IdentityRestart.php:30
- type SqlSemantics\Platform\PostgreSql\Statement\Table\Index\AlterStatistics packages/sql-semantics-postgres/src/Statement/Table/Index/AlterStatistics.php:37
- type SqlSemantics\Platform\PostgreSql\Statement\Table\Sequence\SequenceNumber packages/sql-semantics-postgres/src/Statement/Table/Sequence/SequenceNumber.php:34
- type SqlSemantics\Platform\PostgreSql\Statement\Utility\Maintenance\UtilityOption packages/sql-semantics-postgres/src/Statement/Utility/Maintenance/UtilityOption.php:45
- type SqlSemantics\Platform\PostgreSql\Statement\Utility\Session\SetTimeZone packages/sql-semantics-postgres/src/Statement/Utility/Session/SetTimeZone.php:51