final class RealLiteral
    implements Scalar
    uses Snapshot
Public API: explicitly declared with @visibility public.

A floating point literal, kept as its exact decimal parts and never as a PHP float.

Rule: SQLITE-REAL-LITERAL-001. A numeric literal with a decimal point or an exponent has storage class REAL. Source: https://sqlite.org/lang_expr.html#literal_values_constants_. Status: Implemented.

Reading the parts of a floating point literaldoctest
$query = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('SELECT 1.50E-3 AS r');
    $literal = $query->statement->columns[0]->expression;
    [$literal->whole, $literal->fraction, $literal->exponent, $query->toString()] // => ['1', '50', '-3', 'SELECT 1.50e-3 AS r']
Refusing a literal with neither a decimal point nor an exponentdoctest
new \SqlSemantics\Platform\Sqlite\Statement\Expression\Literal\RealLiteral('1', null, null) // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstruction
Refusing a point without any digitdoctest
new \SqlSemantics\Platform\Sqlite\Statement\Expression\Literal\RealLiteral('', '') // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstruction
Refusing non digit partsdoctest
new \SqlSemantics\Platform\Sqlite\Statement\Expression\Literal\RealLiteral('1a', '5') // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstruction
Refusing an exponent with a letterdoctest
new \SqlSemantics\Platform\Sqlite\Statement\Expression\Literal\RealLiteral('1', null, 'e5') // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstruction

Properties§

public string $whole
public string|null $fraction
public string|null $exponent = null

Methods§

public function __construct(
    public string $whole,
    public string|null $fraction,
    public string|null $exponent = null,
)

Parameters

$wholestringThe digits before the decimal point; empty when the literal starts with the point
$fractionstring|nullThe digits after the decimal point; null when the literal has no point
$exponentstring|nullThe exponent digits with their optional sign; null when the literal has no exponent
Calls 2
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives REAL.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

Calls 4
public function render(Output $out): void

Writes the parts in order.

Parameters

$outOutput
Calls 1

Test cases 12§

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 9

Relations§

Instantiated in 1
Type declarations 2