classRepeatLoop
final class RepeatLoop
implements ProgramStatement
uses Snapshot
Public API: explicitly declared with
@visibility public.REPEAT ... UNTIL ... END REPEAT: repeats its statements until the search condition is true.
The facts follow MYSQL-PROGRAM-FLOW-001. Source: https://dev.mysql.com/doc/refman/8.4/en/repeat.html.
$create = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('CREATE PROCEDURE p(a INT) again: REPEAT SELECT 1; UNTIL a > 0 END REPEAT again');
[$create->statement->body->label->value, count($create->statement->body->statements)] // => ['again', 1]Properties§
public non-empty-list<ProgramStatement|Statement> $statementspublic Scalar $conditionpublic Name|null $label = nullpublic Name|null $endLabel = nullMethods§
public function __construct(
public Scalar $condition,
list<ProgramStatement|Statement> $statements,
public Name|null $label = null,
public Name|null $endLabel = null,
)Parameters
$condition | Scalar | The search condition checked after every pass |
$statements | list<ProgramStatement|Statement> | The repeated statements; at least one |
$label | Name|null | The label written before the loop |
$endLabel | Name|null | The 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 labelCalls 3
- method-call StatementSequence::members() line 50
- new StatementSequence line 50
- static-call Check::input() line 51
public function deriveProgram(Derivation $derivation, ProgramScope $scope): voidDerives the labels, the condition when there is one, and the statements.
Parameters
$derivation | Derivation | |
$scope | ProgramScope |
Calls 2
- method-call FlowFacts::loop() line 59
- new FlowFacts line 59
public function render(Output $out): voidWrites the statement.
Parameters
$out | Output |
Calls 6
- method-call ProgramNames::label() line 67
- new ProgramNames line 67
- method-call Output::keyword() line 68
- method-call StatementSequence::write() line 69
- new StatementSequence line 69
- method-call ProgramNames::end() line 71
Test cases 8§
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 6
FlowRuleTest::providerLabeledLowersALabeledLoopcallsFlowRuleTest::testEndLabelLowersTheLabelAfterEndcallsFlowRuleTest::testLoopLowersLoopWhileAndRepeatcallsReturnSearchTest::providerFoundFindsANestedReturncallsReturnSearchTest::testNestedAnswersTheStatementsOfALoopcallsProgramStatementTest::providerDeriveProgramIsImplementedByTheProgramStatementClassescalls