classBlock
final class Block
implements ProgramStatement
uses Snapshot
Public API: explicitly declared with
@visibility public.A BEGIN ... END compound statement with its declarations, statements and optional label.
The facts follow MYSQL-PROGRAM-BLOCK-001. Source: https://dev.mysql.com/doc/refman/8.4/en/begin-end.html.
$create = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('CREATE PROCEDURE p() work: BEGIN DECLARE a INT; SELECT a; END work');
$block = $create->statement->body;
[$block->label->value, count($block->declarations), count($block->statements)] // => ['work', 1, 1]Properties§
public list<Declaration> $declarationspublic list<ProgramStatement|Statement> $statementspublic Name|null $label = nullpublic Name|null $endLabel = nullMethods§
public function __construct(
list<Declaration> $declarations = [],
list<ProgramStatement|Statement> $statements = [],
public Name|null $label = null,
public Name|null $endLabel = null,
)Parameters
$declarations | list<Declaration> | The declarations in written order |
$statements | list<ProgramStatement|Statement> | The statements in written order |
$label | Name|null | The label written before BEGIN |
$endLabel | Name|null | The label written after END; only a labeled block has one |
Throws
InvalidConstruction When a member is of another class, or an end label is given without a labelCalls 5
- static-call Check::listOf() line 54
- class-const Declaration::class() line 54
- method-call StatementSequence::members() line 55
- new StatementSequence line 55
- static-call Check::input() line 56
public function deriveProgram(Derivation $derivation, ProgramScope $scope): voidDerives the declarations and the statements in the scope of the block.
Parameters
$derivation | Derivation | |
$scope | ProgramScope |
Calls 2
- method-call BlockFacts::derive() line 64
- new BlockFacts line 64
public function render(Output $out): voidWrites the block.
Parameters
$out | Output |
Calls 6
- method-call ProgramNames::label() line 72
- new ProgramNames line 72
- method-call Output::keyword() line 73
- method-call StatementSequence::write() line 74
- new StatementSequence line 74
- method-call ProgramNames::end() line 77
Test cases 63§
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 60
ConditionRuleTest::testHandledLowersASingleConditioncallsConditionRuleTest::testHandledLowersEveryKindOfConditioncallsConditionRuleTest::testValueLowersAnErrorCodeAndAnSqlstatecallsDiagnosticsRuleTest::testItemsLowersLocalVariableTargetscallsSignalRuleTest::testConditionLowersAConditionNamecallsEventRuleTest::testCreateLeavesTheOptionalClausesAbsentcallsParameterRuleTest::testDeclaredLowersATypeWithItsCollationcallsBlockRuleTest::testBlockLowersALabeledBlockcallsBlockRuleTest::testBlockLowersAnUnlabeledBlockcallsBlockRuleTest::testCursorLowersOpenFetchAndClosecallsBlockRuleTest::testDeclarationLowersAConditionAndAHandlercallsBlockRuleTest::testDeclarationLowersACursorcallsBlockRuleTest::testDeclarationLowersAVariableWithItsCollationAndDefaultcallsBlockRuleTest::testInitialLowersTheDefaultClausecallsBlockRuleTest::testNamesLowersTheDeclaredAndTheFetchedNamescallsFlowRuleTest::testConditionalLowersAnIfWithoutElsecallsFlowRuleTest::testJumpLowersReturnLeaveAndIteratecallsFlowRuleTest::testLoopLowersLoopWhileAndRepeatcallsStatementRuleTest::providerEventLowersTheStatementOfAnEventcallsStatementRuleTest::testBodyLowersAProgramStatementcallsStatementRuleTest::testStatementRoutesEveryKindOfProgramStatementcallsStatementRuleTest::testStatementsLowersTheListInOrdercallsSequenceTest::testItemsAnswersTheMembersInSourceOrdercallsTriggerRuleTest::testCreateReadsIfNotExistscallsBlockFactsTest::testDeriveDerivesTheCursorQueryInTheScopeOfTheBlockcallsBlockFactsTest::testDeriveResolvesTheVariableOfTheInnermostBlockcallsBlockFactsTest::testVariablesHidesAParameterOfTheSameNamecallsBlockFactsTest::testVariablesReportsADuplicateNameAndKeepsTheFirstMeaningcallsBodyFactsTest::testStatementResolvesAVariableInANestedQuerycallsBodyFactsTest::testStatementResolvesAVariableInAnInspectedStatementcallsFlowFactsTest::testBranchesResolvesAVariableInTheConditioncallsFlowFactsTest::testLoopResolvesAVariableInTheConditioncallsFlowFactsTest::testReturnedResolvesTheValueToALocalVariablecallsReturnSearchTest::providerFoundFindsANestedReturncallsReturnSearchTest::providerFoundIsFalseWithoutReturncallsReturnSearchTest::testNestedAnswersTheStatementsAndHandlerStatementsOfABlockcallsStatementSequenceTest::testMemberAcceptsAProgramStatementAndAnSqlStatementcallsConditionNameTest::testRenderWritesTheNameASignalRaisescallsConditionTest::testImplementationsAreTheValuesAHandlerNamescallsGetDiagnosticsTest::testDeriveProgramResolvesParametersAndLocalVariablescallsErrorCodeTest::testRenderWritesTheCodesOfADeclarationAndAHandlercallsGeneralConditionTest::testRenderWritesTheClassesAHandlerNamescallsResignalTest::testDeriveProgramResolvesADeclaredConditionInAHandlercallsSignalTest::testDeriveProgramResolvesADeclaredConditionAndTheVariablesOfTheItemscallsCreateEventTest::testAHexadecimalCommentIsRejectedcallsCreateEventTest::testANameWithACatalogIsRejectedcallsCreateEventTest::testDeriveStatementResolvesTheLocalVariablesInEveryBodyStatementcallsCreateFunctionTest::testANameWithACatalogIsRejectedcallsCreateFunctionTest::testAParameterWithADirectionIsRejectedcallsCreateProcedureTest::testANameWithACatalogIsRejectedcallsCreateProcedureTest::testDeriveStatementResolvesParametersAndLocalVariablesInEveryBodyStatementcallsCreateTriggerTest::testANameWithACatalogIsRejectedcallsCreateTriggerTest::testDeriveStatementResolvesTheNewRowAndLocalVariablesInEveryBodyStatementcallsConditionDeclarationTest::testRenderWritesTheNameAndTheErrorCodecallsCursorDeclarationTest::testRenderWritesTheNameAndTheQuerycallsFetchCursorTest::testDeriveProgramResolvesTheCursorAndTheTargetscallsDeclarationTest::providerImplementationsAreTheFourDeclarationscallsHandlerDeclarationTest::testRenderWritesTheActionTheConditionsAndTheStatementcallsProgramStatementTest::testDeriveProgramIsNotImplementedByAQueryOfABodycallsVariableDeclarationTest::testDeriveRelationAnswersANullablePositionPerNamecalls