final class SearchedCase
    implements ProgramStatement
    uses Snapshot
Public API: explicitly declared with @visibility public.

The searched CASE statement: the statements of the first WHEN whose search condition is true run.

The facts follow MYSQL-PROGRAM-FLOW-001. Source: https://dev.mysql.com/doc/refman/8.4/en/case.html.

Reading a searched CASE statementdoctest
$create = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('CREATE PROCEDURE p(a INT) CASE WHEN a > 1 THEN SELECT 1; WHEN a < 0 THEN SELECT 2; END CASE');
    [count($create->statement->body->branches), $create->statement->body->otherwise] // => [2, []]

Properties§

public non-empty-list<ConditionalBranch> $branches
public list<ProgramStatement|Statement> $otherwise

Methods§

public function __construct(
    list<ConditionalBranch> $branches,
    list<ProgramStatement|Statement> $otherwise = [],
)

Parameters

$brancheslist<ConditionalBranch>The WHEN branches; at least one
$otherwiselist<ProgramStatement|Statement>The statements of ELSE; empty without ELSE

Throws

InvalidConstruction When there is no branch or a member is of another class
Calls 4
public function deriveProgram(Derivation $derivation, ProgramScope $scope): void

Derives the conditions and the statements of every branch.

Parameters

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

Writes the statement.

Parameters

$outOutput
Calls 3

Test cases 7§

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 5

Relations§

Instantiated in 1
Type checks 1
Type declarations 1