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

A user-defined variable read as a value: @name.

Variable names are compared without regard to letter case; the name is kept as written.

Rule: MYSQL-USER-VARIABLE-001. Facts: the type and the NULL fact are those of the value the session last assigned, which no context holds; the fact names the variable as missing session state. Diagnostics: none. Source: https://dev.mysql.com/doc/refman/8.4/en/user-variables.html. Status: Implemented.

Naming the session state a variable depends ondoctest
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SELECT a FROM t WHERE a = @total');
    [$query->statement->where->right->name->value, $query->facts->scalar($query->statement->where->right)->type->missing[0]->describe()] // => ['total', 'the session state: user variable @total']

Properties§

public Name $name

Methods§

public function __construct(public Name $name)

Parameters

$nameNameThe variable name without the at sign
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the dependence on the session.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes the at sign and the name without a space between them.

Parameters

$outOutput
Calls 2

Test cases 34§

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 31

Relations§

Instantiated in 1
Constant reads 1
Type checks 6
Type declarations 9