final class Loop
    implements ProgramStatement
    uses Snapshot
Public API: explicitly declared with @visibility public.

LOOP ... END LOOP: repeats its statements until a LEAVE or RETURN ends it.

The facts follow MYSQL-PROGRAM-FLOW-001. Source: https://dev.mysql.com/doc/refman/8.4/en/loop.html.

Reading a labeled loopdoctest
$create = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('CREATE PROCEDURE p() again: LOOP LEAVE again; END LOOP again');
    [$create->statement->body->label->value, count($create->statement->body->statements)] // => ['again', 1]

Properties§

public non-empty-list<ProgramStatement|Statement> $statements
public Name|null $label = null
public Name|null $endLabel = null

Methods§

public function __construct(
    list<ProgramStatement|Statement> $statements,
    public Name|null $label = null,
    public Name|null $endLabel = null,
)

Parameters

$statementslist<ProgramStatement|Statement>The repeated statements; at least one
$labelName|nullThe label written before the loop
$endLabelName|nullThe label written after the loop; only a labeled loop has one

Throws

InvalidConstruction When there is no statement, a member is of another class, or an end label is given without a label
Calls 3
public function deriveProgram(Derivation $derivation, ProgramScope $scope): void

Derives the labels, the condition when there is one, and the statements.

Parameters

$derivationDerivation
$scopeProgramScope
Calls 2
public function render(Output $out): void

Writes the statement.

Parameters

$outOutput
Calls 6

Test cases 12§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 2
Other tests reaching this symbol 10

Relations§

Instantiated in 1
Type checks 1
Type declarations 2