classStatementSequence
final class StatementSequence
Restricted visibility: declared "@visibility SqlSemantics\Platform\MySql". Code outside that scope must not name this declaration.
Checks and writes the statement lists of stored programs.
Rule: MYSQL-PROGRAM-SEQUENCE-001. A member of a statement list is a statement of the stored program language or any SQL statement; every member is written followed by a semicolon, as the grammar requires inside compound statements. Terminates: one pass over the list. Source: https://dev.mysql.com/doc/refman/8.4/en/begin-end.html. Status: Implemented.
Methods§
public function members(
array<array-key, object|array<array-key, object|scalar|null>|scalar|null> $statements,
int $minimum = 0,
): ($minimum is positive-int ? non-empty-list<ProgramStatement|Statement> : list<ProgramStatement|Statement>)Narrows a constructor argument to a list of program statements and SQL statements.
Parameters
$statements | array<array-key, object|array<array-key, object|scalar|null>|scalar|null> | |
$minimum | int |
Returns
($minimum is positive-int ? non-empty-list<ProgramStatement|Statement> : list<ProgramStatement|Statement>)Throws
InvalidConstruction When a member is no statement, or the list is shorter than the minimumTest cases 4
Called from 8
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Block::__construct() packages/sql-semantics-mysql/src/Statement/Routine/Program/Block.php:55
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\ConditionalBranch::__construct() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/ConditionalBranch.php:45
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\IfStatement::__construct() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/IfStatement.php:52
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\Loop::__construct() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/Loop.php:48
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\RepeatLoop::__construct() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/RepeatLoop.php:50
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\SearchedCase::__construct() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/SearchedCase.php:51
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\SimpleCase::__construct() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/SimpleCase.php:55
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\WhileLoop::__construct() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/WhileLoop.php:50
Calls 4
- function-call
array_mapline 37 - method-call StatementSequence::member() line 37
- static-call Check::listOf() line 37
- class-const Node::class() line 37
public function member(Node $statement): ProgramStatement|StatementNarrows a node to a program statement or an SQL statement.
Parameters
$statement | Node |
Returns
Throws
InvalidConstruction When the node is neitherTest cases 2
Called from 6
- method-call SqlSemantics\Platform\MySql\Rules\Routine\ProgramFacts::body() packages/sql-semantics-mysql/src/Rules/Routine/ProgramFacts.php:59
- method-call SqlSemantics\Platform\MySql\Rules\Routine\StatementSequence::members() packages/sql-semantics-mysql/src/Rules/Routine/StatementSequence.php:37
- method-call SqlSemantics\Platform\MySql\Statement\Routine\AlterEvent::__construct() packages/sql-semantics-mysql/src/Statement/Routine/AlterEvent.php:71
- method-call SqlSemantics\Platform\MySql\Statement\Routine\CreateEvent::__construct() packages/sql-semantics-mysql/src/Statement/Routine/CreateEvent.php:70
- method-call SqlSemantics\Platform\MySql\Statement\Routine\CreateTrigger::__construct() packages/sql-semantics-mysql/src/Statement/Routine/CreateTrigger.php:68
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\HandlerDeclaration::__construct() packages/sql-semantics-mysql/src/Statement/Routine/Program/HandlerDeclaration.php:50
Calls 1
Writes the statements, each followed by a semicolon.
Test cases 1
Called from 9
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Block::render() packages/sql-semantics-mysql/src/Statement/Routine/Program/Block.php:74
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Block::render() packages/sql-semantics-mysql/src/Statement/Routine/Program/Block.php:75
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\ConditionalBranch::render() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/ConditionalBranch.php:54
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\IfStatement::render() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/IfStatement.php:73
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\Loop::render() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/Loop.php:67
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\RepeatLoop::render() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/RepeatLoop.php:69
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\SearchedCase::render() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/SearchedCase.php:73
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\SimpleCase::render() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/SimpleCase.php:78
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\WhileLoop::render() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/WhileLoop.php:69
Calls 1
- method-call Output::node() line 62
Test cases 7§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 7
StatementSequenceTest::testMemberAcceptsAProgramStatementAndAnSqlStatementcallsStatementSequenceTest::testMemberRefusesANodeThatIsNoStatementcallsStatementSequenceTest::testMembersKeepsProgramStatementsAndSqlStatementsInOrdercallsStatementSequenceTest::testMembersRefusesAListShorterThanTheMinimumcallsStatementSequenceTest::testMembersRefusesAListWithKeyscallsStatementSequenceTest::testMembersRefusesAMemberThatIsNoNodecallsStatementSequenceTest::testWriteEndsEveryStatementWithASemicoloncalls
Relations§
Instantiated in 22
- new SqlSemantics\Platform\MySql\Rules\Routine\ProgramFacts::body() packages/sql-semantics-mysql/src/Rules/Routine/ProgramFacts.php:59
- new SqlSemantics\Platform\MySql\Statement\Routine\AlterEvent::__construct() packages/sql-semantics-mysql/src/Statement/Routine/AlterEvent.php:71
- new SqlSemantics\Platform\MySql\Statement\Routine\CreateEvent::__construct() packages/sql-semantics-mysql/src/Statement/Routine/CreateEvent.php:70
- new SqlSemantics\Platform\MySql\Statement\Routine\CreateTrigger::__construct() packages/sql-semantics-mysql/src/Statement/Routine/CreateTrigger.php:68
- new SqlSemantics\Platform\MySql\Statement\Routine\Program\Block::__construct() packages/sql-semantics-mysql/src/Statement/Routine/Program/Block.php:55
- new SqlSemantics\Platform\MySql\Statement\Routine\Program\Block::render() packages/sql-semantics-mysql/src/Statement/Routine/Program/Block.php:74
- new SqlSemantics\Platform\MySql\Statement\Routine\Program\Block::render() packages/sql-semantics-mysql/src/Statement/Routine/Program/Block.php:75
- new SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\ConditionalBranch::__construct() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/ConditionalBranch.php:45
- new SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\ConditionalBranch::render() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/ConditionalBranch.php:54
- new SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\IfStatement::__construct() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/IfStatement.php:52
- new SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\IfStatement::render() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/IfStatement.php:73
- new SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\Loop::__construct() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/Loop.php:48
- new SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\Loop::render() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/Loop.php:67
- new SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\RepeatLoop::__construct() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/RepeatLoop.php:50
- new SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\RepeatLoop::render() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/RepeatLoop.php:69
- new SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\SearchedCase::__construct() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/SearchedCase.php:51
- new SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\SearchedCase::render() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/SearchedCase.php:73
- new SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\SimpleCase::__construct() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/SimpleCase.php:55
- new SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\SimpleCase::render() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/SimpleCase.php:78
- new SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\WhileLoop::__construct() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/WhileLoop.php:50
- new SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\WhileLoop::render() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/WhileLoop.php:69
- new SqlSemantics\Platform\MySql\Statement\Routine\Program\HandlerDeclaration::__construct() packages/sql-semantics-mysql/src/Statement/Routine/Program/HandlerDeclaration.php:50
Method calls 22
- method-call SqlSemantics\Platform\MySql\Rules\Routine\ProgramFacts::body() packages/sql-semantics-mysql/src/Rules/Routine/ProgramFacts.php:59
- method-call SqlSemantics\Platform\MySql\Statement\Routine\AlterEvent::__construct() packages/sql-semantics-mysql/src/Statement/Routine/AlterEvent.php:71
- method-call SqlSemantics\Platform\MySql\Statement\Routine\CreateEvent::__construct() packages/sql-semantics-mysql/src/Statement/Routine/CreateEvent.php:70
- method-call SqlSemantics\Platform\MySql\Statement\Routine\CreateTrigger::__construct() packages/sql-semantics-mysql/src/Statement/Routine/CreateTrigger.php:68
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Block::__construct() packages/sql-semantics-mysql/src/Statement/Routine/Program/Block.php:55
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Block::render() packages/sql-semantics-mysql/src/Statement/Routine/Program/Block.php:74
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Block::render() packages/sql-semantics-mysql/src/Statement/Routine/Program/Block.php:75
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\ConditionalBranch::__construct() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/ConditionalBranch.php:45
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\ConditionalBranch::render() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/ConditionalBranch.php:54
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\IfStatement::__construct() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/IfStatement.php:52
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\IfStatement::render() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/IfStatement.php:73
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\Loop::__construct() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/Loop.php:48
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\Loop::render() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/Loop.php:67
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\RepeatLoop::__construct() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/RepeatLoop.php:50
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\RepeatLoop::render() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/RepeatLoop.php:69
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\SearchedCase::__construct() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/SearchedCase.php:51
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\SearchedCase::render() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/SearchedCase.php:73
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\SimpleCase::__construct() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/SimpleCase.php:55
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\SimpleCase::render() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/SimpleCase.php:78
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\WhileLoop::__construct() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/WhileLoop.php:50
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\WhileLoop::render() packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/WhileLoop.php:69
- method-call SqlSemantics\Platform\MySql\Statement\Routine\Program\HandlerDeclaration::__construct() packages/sql-semantics-mysql/src/Statement/Routine/Program/HandlerDeclaration.php:50