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.

Reading a labeled blockdoctest
$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> $declarations
public list<ProgramStatement|Statement> $statements
public Name|null $label = null
public Name|null $endLabel = null

Methods§

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

Parameters

$declarationslist<Declaration>The declarations in written order
$statementslist<ProgramStatement|Statement>The statements in written order
$labelName|nullThe label written before BEGIN
$endLabelName|nullThe 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 label
Calls 5
public function deriveProgram(Derivation $derivation, ProgramScope $scope): void

Derives the declarations and the statements in the scope of the block.

Parameters

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

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

Relations§

Instantiated in 1
Type checks 1
Type declarations 2