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

WHILE ... DO ... END WHILE: repeats its statements while the search condition is true.

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

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

Properties§

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

Methods§

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

Parameters

$conditionScalarThe search condition checked before every pass
$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 11§

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 9

Relations§

Instantiated in 1
Type checks 1
Type declarations 2