classHandlerDeclaration
final class HandlerDeclaration
implements Declaration
uses Snapshot
Public API: explicitly declared with
@visibility public.DECLARE ... HANDLER: the statement that runs when one of the listed conditions occurs in the block.
Source: https://dev.mysql.com/doc/refman/8.4/en/declare-handler.html.
$create = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('CREATE PROCEDURE p() BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND, 1051 BEGIN END; END');
$handler = $create->statement->body->declarations[0];
[$handler->action, count($handler->conditions)] // => [\SqlSemantics\Platform\MySql\Statement\Routine\Program\HandlerAction::Continue, 2]Properties§
public non-empty-list<Condition> $conditionspublic ProgramStatement|Statement $statementpublic HandlerAction $actionMethods§
public function __construct(
public HandlerAction $action,
list<Condition> $conditions,
Node $statement,
)Parameters
$action | HandlerAction | What happens after the handler ran |
$conditions | list<Condition> | The conditions handled; at least one |
$statement | Node | The statement the handler runs: a program statement or an SQL statement |
Throws
InvalidConstruction When there is no condition or the statement is of another classCalls 4
- static-call Check::listOf() line 49
- class-const Condition::class() line 49
- method-call StatementSequence::member() line 50
- new StatementSequence line 50
public function render(Output $out): voidTest cases 15§
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 12
ConditionRuleTest::testHandledLowersASingleConditioncallsConditionRuleTest::testHandledLowersEveryKindOfConditioncallsBlockRuleTest::testDeclarationLowersAConditionAndAHandlercallsReturnSearchTest::providerFoundFindsANestedReturncallsReturnSearchTest::providerFoundIsFalseWithoutReturncallsReturnSearchTest::testNestedAnswersTheStatementsAndHandlerStatementsOfABlockcallsConditionTest::testImplementationsAreTheValuesAHandlerNamescallsGetDiagnosticsTest::testDeriveProgramResolvesParametersAndLocalVariablescallsErrorCodeTest::testRenderWritesTheCodesOfADeclarationAndAHandlercallsGeneralConditionTest::testRenderWritesTheClassesAHandlerNamescallsResignalTest::testDeriveProgramResolvesADeclaredConditionInAHandlercallsDeclarationTest::providerImplementationsAreTheFourDeclarationscalls