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

An assignment to a user-defined variable inside an expression: @name := value.

The value is a complete expression: everything to the right of := belongs to it. An operator that takes an assignment as its left operand must therefore hold it in a grouping.

Rule: MYSQL-VARIABLE-ASSIGNMENT-001. Facts: the assignment yields the assigned value, so its type and NULL fact are those of the value. Diagnostics: none. Terminates: the value is a strict part. Source: https://dev.mysql.com/doc/refman/8.4/en/assignment-operators.html#operator_assign-value. Status: Implemented.

Reading an assignmentdoctest
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SELECT a FROM t WHERE a = @n := 5');
    [$query->statement->where->right->target->name->value, $query->statement->where->right->value->text] // => ['n', '5']

Properties§

public UserVariable $target
public Scalar $value

Methods§

public function __construct(public UserVariable $target, public Scalar $value)

Parameters

$targetUserVariableThe variable assigned to
$valueScalarThe assigned expression
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the target and the value; the assignment has the facts of the value.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes the target, the assignment operator and the value.

Parameters

$outOutput
Calls 1

Test cases 8§

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 5

Relations§

Instantiated in 1
Type checks 1
Type declarations 1