final class SignedNumber
    implements OptionArgument
    uses Snapshot
Public API: explicitly declared with @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.

Reading a negative option valuedoctest
$number = new \SqlSemantics\Platform\PostgreSql\Statement\Literal\SignedNumber(true, new \SqlSemantics\Platform\PostgreSql\Statement\Literal\IntegerConstant('5'));
    [$number->negative, $number->magnitude->digits] // => [true, '5']
Reading the text a command receives from a negative numeric constantdoctest
$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 $negative

Methods§

public function __construct(
    public bool $negative,
    public IntegerConstant|NumericConstant $magnitude,
)

Parameters

$negativeboolWhether a minus sign is written
$magnitudeIntegerConstant|NumericConstantThe number after the sign
public function deriveClause(Derivation $derivation, Environment $environment): void

Derives nothing: a number holds no expression.

Parameters

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

Writes the minus sign and the number.

Parameters

$outOutput
Test cases 1
Calls 2

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

Relations§

Instantiated in 6
Method calls 3
Constant reads 1
Type checks 15
Type declarations 33