classLoop
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.
$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> $statementspublic Name|null $label = nullpublic Name|null $endLabel = nullMethods§
public function __construct(
list<ProgramStatement|Statement> $statements,
public Name|null $label = null,
public Name|null $endLabel = null,
)Parameters
$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 48
- new StatementSequence line 48
- static-call Check::input() line 49
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 57
- new FlowFacts line 57
public function render(Output $out): voidWrites the statement.
Parameters
$out | Output |
Calls 6
- method-call ProgramNames::label() line 65
- new ProgramNames line 65
- method-call Output::keyword() line 66
- method-call StatementSequence::write() line 67
- new StatementSequence line 67
- method-call ProgramNames::end() line 69
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
FlowRuleTest::providerLabeledLowersALabeledLoopcallsFlowRuleTest::testJumpLowersReturnLeaveAndIteratecallsFlowRuleTest::testLoopLowersLoopWhileAndRepeatcallsStatementRuleTest::providerEventLowersTheStatementOfAnEventcallsStatementRuleTest::testStatementRoutesEveryKindOfProgramStatementcallsProgramFactsTest::testBodyKeepsAProgramStatementAndAnSqlStatementcallsReturnSearchTest::providerFoundFindsANestedReturncallsReturnSearchTest::providerFoundIsFalseWithoutReturncallsReturnSearchTest::testNestedAnswersTheStatementsOfALoopcallsProgramStatementTest::providerDeriveProgramIsImplementedByTheProgramStatementClassescalls