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

A call of a built-in function whose name is a keyword and whose arguments are a plain list of expressions.

Rule: MYSQL-KEYWORD-CALL-001. The function decides the argument counts the grammar accepts and the result (MYSQL-CALL-RESULT-001); ADDDATE and SUBDATE with a number of days are typed as a date plus or minus days. GROUPING() yields 1 or 0 and is never NULL. The keyword is written against its parenthesis, and the niladic functions are written with empty parentheses, which the grammar accepts for every one of them; CURRENT_USER keeps whether its optional parentheses are written. Terminates: the arguments are strict parts. Source: https://dev.mysql.com/doc/refman/8.4/en/built-in-function-reference.html. Status: Implemented.

Typing a keyword functiondoctest
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze("SELECT LEFT('abc', 2)");
    $query->field(0)->type->descriptor->name() // => 'VARCHAR'
Refusing an argument count the grammar does not acceptdoctest
new \SqlSemantics\Platform\MySql\Statement\Call\KeywordCall(\SqlSemantics\Platform\MySql\Statement\Call\KeywordFunction::Left, []) // throws \SqlSemantics\Platform\MySql\Model\Diagnostic\InvalidConstruction

Properties§

public list<Scalar> $arguments
public KeywordFunction $function
public OptionalWords $parentheses = OptionalWords::Written

Methods§

public function __construct(
    public KeywordFunction $function,
    list<Scalar> $arguments,
    public OptionalWords $parentheses = OptionalWords::Written,
)

Parameters

$functionKeywordFunctionThe function
$argumentslist<Scalar>The arguments in order
$parenthesesOptionalWordsWhether the empty parentheses of CURRENT_USER are written; the other functions write their parentheses
Calls 7
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the arguments and the documented result.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes the keyword against its parenthesized arguments.

Parameters

$outOutput
Test cases 1
Calls 3

Test cases 5§

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 2

Relations§

Instantiated in 2
Type declarations 2