classRealLiteral
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.
$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']new \SqlSemantics\Platform\Sqlite\Statement\Expression\Literal\RealLiteral('1', null, null) // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstructionnew \SqlSemantics\Platform\Sqlite\Statement\Expression\Literal\RealLiteral('', '') // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstructionnew \SqlSemantics\Platform\Sqlite\Statement\Expression\Literal\RealLiteral('1a', '5') // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstructionnew \SqlSemantics\Platform\Sqlite\Statement\Expression\Literal\RealLiteral('1', null, 'e5') // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstructionProperties§
public string $wholepublic string|null $fractionpublic string|null $exponent = nullMethods§
public function __construct(
public string $whole,
public string|null $fraction,
public string|null $exponent = null,
)Parameters
$whole | string | The digits before the decimal point; empty when the literal starts with the point |
$fraction | string|null | The digits after the decimal point; null when the literal has no point |
$exponent | string|null | The exponent digits with their optional sign; null when the literal has no exponent |
Calls 2
- static-call Check::input() line 51
- function-call
preg_matchline 51
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives REAL.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 4
- new ScalarFact line 62
- new Known line 62
- class-const Storage::Real() line 62
- class-const Nullability::NotNull() line 62
public function render(Output $out): voidTest 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
LiteralRuleTest::testNumberDropsTheDigitSeparatorsOfARealTokencallsLiteralRuleTest::testNumberLowersEverySpellingOfARealNumbercallsLiteralRuleTest::testPlainLowersAFloatingPointTokenByItsPartscallsTypeNameRuleTest::testMinusNumberLowersAMinusSignedNumbercallsTypeNameRuleTest::testPlusNumberLowersAnUnsignedAndAPlusSignedNumbercallsTypeNameRuleTest::testSignedLowersARealAndAHexadecimalArgumentcallsOrdinalsTest::testValueIsNullForAnOrdinaryExpressioncallsSignedNumberTest::testRenderWritesANewlyBuiltNumbercallsSignedNumberTest::testRenderWritesEveryKindOfNumericLiteralcalls