final class ConditionalBranch
    implements Node
    uses Snapshot
Public API: explicitly declared with @visibility public.

One branch of IF or CASE: an expression, THEN, and the statements that run when the branch is chosen.

In IF and in a searched CASE the expression is a search condition; in a simple CASE it is the value compared with the operand of the CASE. Source: https://dev.mysql.com/doc/refman/8.4/en/if.html, https://dev.mysql.com/doc/refman/8.4/en/case.html.

Reading the branches of IFdoctest
$create = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('CREATE PROCEDURE p(a INT) IF a = 1 THEN SELECT 1; ELSEIF a = 2 THEN SELECT 2; SELECT 3; END IF');
    [count($create->statement->body->branches), count($create->statement->body->branches[1]->statements)] // => [2, 2]

Properties§

public non-empty-list<ProgramStatement|Statement> $statements
public Scalar $condition

Methods§

public function __construct(
    public Scalar $condition,
    list<ProgramStatement|Statement> $statements,
)

Parameters

$conditionScalarThe search condition, or the compared value of a simple CASE
$statementslist<ProgramStatement|Statement>The statements after THEN; at least one

Throws

InvalidConstruction When there is no statement or a member is of another class
Calls 2
public function render(Output $out): void

Writes the expression, THEN and the statements.

Parameters

$outOutput
Calls 3

Test cases 9§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 1
Other tests reaching this symbol 8

Relations§

Instantiated in 2
Constant reads 3