classProgramScope
final class ProgramScope
What names mean at one position of a stored program.
Rule: MYSQL-PROGRAM-SCOPE-001. The scope holds the environment in which the parameters and local variables are visible as rows (the innermost block first, so an inner declaration hides an outer one), the action time and event of a trigger, the labels of the enclosing blocks and loops, and the conditions and cursors declared around the position, the innermost last. Names of variables, labels, conditions and cursors are compared without regard to letter case. It is a working value of one derivation. Terminates: every search is over a finite list. Source: https://dev.mysql.com/doc/refman/8.4/en/local-variable-scope.html, https://dev.mysql.com/doc/refman/8.4/en/statement-labels.html. Status: Implemented.
Properties§
public Environment $environmentpublic ProgramKind|null $kind = nullpublic list<Name> $blocks = []public list<Name> $loops = []public list<ConditionDeclaration> $conditions = []public list<Name> $cursors = []public TriggerTime|null $time = nullpublic TriggerEvent|null $event = nullMethods§
public function __construct(
public Environment $environment,
public ProgramKind|null $kind = null,
public list<Name> $blocks = [],
public list<Name> $loops = [],
public list<ConditionDeclaration> $conditions = [],
public list<Name> $cursors = [],
public TriggerTime|null $time = null,
public TriggerEvent|null $event = null,
)Parameters
$environment | Environment | The environment the variables are visible in |
$kind | ProgramKind|null | The kind of program the position belongs to; null outside a program |
$blocks | list<Name> | The labels of the enclosing blocks |
$loops | list<Name> | The labels of the enclosing loops |
$conditions | list<ConditionDeclaration> | The conditions in scope, the innermost last |
$cursors | list<Name> | The cursors in scope |
$time | TriggerTime|null | The action time of the trigger the position belongs to; null outside a trigger |
$event | TriggerEvent|null | The event of the trigger the position belongs to; null outside a trigger |
Tells whether a list of names holds a name, compared without regard to letter case.
Returns
boolTest cases 1
Called from 6
- method-call SqlSemantics\Platform\MySql\Rules\Routine\BlockFacts::distinct() packages/sql-semantics-mysql/src/Rules/Routine/BlockFacts.php:111
- method-call SqlSemantics\Platform\MySql\Rules\Routine\BlockFacts::variables() packages/sql-semantics-mysql/src/Rules/Routine/BlockFacts.php:152
- method-call SqlSemantics\Platform\MySql\Rules\Routine\CursorFacts::cursor() packages/sql-semantics-mysql/src/Rules/Routine/CursorFacts.php:33
- method-call SqlSemantics\Platform\MySql\Rules\Routine\FlowFacts::jump() packages/sql-semantics-mysql/src/Rules/Routine/FlowFacts.php:68
- method-call SqlSemantics\Platform\MySql\Rules\Routine\LabelFacts::enter() packages/sql-semantics-mysql/src/Rules/Routine/LabelFacts.php:32
- method-call SqlSemantics\Platform\MySql\Rules\Routine\ProgramFacts::routine() packages/sql-semantics-mysql/src/Rules/Routine/ProgramFacts.php:72
Calls 1
- function-call
strcasecmpline 66
public function variable(Name $name): boolTells whether a parameter or local variable with the name is in scope.
Parameters
$name | Name |
Returns
boolTest cases 1
Called from 1
Calls 2
- method-call ColumnResolver::find() line 79
- new ColumnResolver line 79
public function condition(Name $name): ?ConditionDeclarationFinds the innermost condition declared with a name.
Parameters
$name | Name |
Returns
Test cases 1
Called from 3
- method-call SqlSemantics\Platform\MySql\Rules\Routine\ConditionFacts::value() packages/sql-semantics-mysql/src/Rules/Routine/ConditionFacts.php:55
- method-call SqlSemantics\Platform\MySql\Rules\Routine\ConditionFacts::meaning() packages/sql-semantics-mysql/src/Rules/Routine/ConditionFacts.php:65
- method-call SqlSemantics\Platform\MySql\Rules\Routine\ConditionFacts::signal() packages/sql-semantics-mysql/src/Rules/Routine/ConditionFacts.php:91
public function labeled(?Name $label, bool $loop): selfpublic function declared(
Environment $environment,
list<ConditionDeclaration> $conditions,
list<Name> $cursors,
): selfAnswers the scope after declarations: another environment, and the conditions and cursors now in scope.
Parameters
$environment | Environment | |
$conditions | list<ConditionDeclaration> | |
$cursors | list<Name> |
Returns
selfCalled from 1
Calls 1
- new
selfline 116
public function handler(): selfAnswers the scope of the statement of a handler, which sees no label outside the handler.
Returns
selfCalls 1
- new
selfline 124
Test cases 8§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 7
ProgramScopeTest::testConditionFindsTheInnermostDeclarationOfTheNamecallsProgramScopeTest::testDeclaredReplacesTheEnvironmentConditionsAndCursorscallsProgramScopeTest::testHandlerSeesNoLabelOutsideTheHandlercallsProgramScopeTest::testHoldsComparesNamesWithoutRegardToLetterCasecallsProgramScopeTest::testLabeledAddsTheLabelOfABlockOrALoopcallsProgramScopeTest::testLabeledKeepsTheScopeWithoutALabelcallsProgramScopeTest::testVariableIsFalseInAnEnvironmentWithoutVariablescalls
Other tests reaching this symbol 1
Relations§
Instantiated in 7
- new SqlSemantics\Platform\MySql\Rules\Routine\ProgramFacts::routine() packages/sql-semantics-mysql/src/Rules/Routine/ProgramFacts.php:68
- new SqlSemantics\Platform\MySql\Rules\Routine\ProgramFacts::routine() packages/sql-semantics-mysql/src/Rules/Routine/ProgramFacts.php:82
- new SqlSemantics\Platform\MySql\Rules\Routine\ProgramFacts::trigger() packages/sql-semantics-mysql/src/Rules/Routine/ProgramFacts.php:96
- new SqlSemantics\Platform\MySql\Rules\Routine\ProgramFacts::event() packages/sql-semantics-mysql/src/Rules/Routine/ProgramFacts.php:106
- new SqlSemantics\Platform\MySql\Statement\Routine\Condition\Diagnostics\GetDiagnostics::deriveStatement() packages/sql-semantics-mysql/src/Statement/Routine/Condition/Diagnostics/GetDiagnostics.php:44
- new SqlSemantics\Platform\MySql\Statement\Routine\Condition\Resignal::deriveStatement() packages/sql-semantics-mysql/src/Statement/Routine/Condition/Resignal.php:52
- new SqlSemantics\Platform\MySql\Statement\Routine\Condition\Signal::deriveStatement() packages/sql-semantics-mysql/src/Statement/Routine/Condition/Signal.php:52
Method calls 12
- method-call SqlSemantics\Platform\MySql\Rules\Routine\BlockFacts::distinct() packages/sql-semantics-mysql/src/Rules/Routine/BlockFacts.php:111
- method-call SqlSemantics\Platform\MySql\Rules\Routine\BlockFacts::variables() packages/sql-semantics-mysql/src/Rules/Routine/BlockFacts.php:152
- method-call SqlSemantics\Platform\MySql\Rules\Routine\BlockFacts::variables() packages/sql-semantics-mysql/src/Rules/Routine/BlockFacts.php:160
- method-call SqlSemantics\Platform\MySql\Rules\Routine\ConditionFacts::value() packages/sql-semantics-mysql/src/Rules/Routine/ConditionFacts.php:55
- method-call SqlSemantics\Platform\MySql\Rules\Routine\ConditionFacts::meaning() packages/sql-semantics-mysql/src/Rules/Routine/ConditionFacts.php:65
- method-call SqlSemantics\Platform\MySql\Rules\Routine\ConditionFacts::signal() packages/sql-semantics-mysql/src/Rules/Routine/ConditionFacts.php:91
- method-call SqlSemantics\Platform\MySql\Rules\Routine\CursorFacts::cursor() packages/sql-semantics-mysql/src/Rules/Routine/CursorFacts.php:33
- method-call SqlSemantics\Platform\MySql\Rules\Routine\CursorFacts::variables() packages/sql-semantics-mysql/src/Rules/Routine/CursorFacts.php:46
- method-call SqlSemantics\Platform\MySql\Rules\Routine\FlowFacts::jump() packages/sql-semantics-mysql/src/Rules/Routine/FlowFacts.php:68
- method-call SqlSemantics\Platform\MySql\Rules\Routine\LabelFacts::enter() packages/sql-semantics-mysql/src/Rules/Routine/LabelFacts.php:32
- method-call SqlSemantics\Platform\MySql\Rules\Routine\LabelFacts::enter() packages/sql-semantics-mysql/src/Rules/Routine/LabelFacts.php:39
- method-call SqlSemantics\Platform\MySql\Rules\Routine\ProgramFacts::routine() packages/sql-semantics-mysql/src/Rules/Routine/ProgramFacts.php:72
Type declarations 35
- type SqlSemantics\Platform\MySql\Rules\Routine\BlockFacts packages/sql-semantics-mysql/src/Rules/Routine/BlockFacts.php:50
- type SqlSemantics\Platform\MySql\Rules\Routine\BlockFacts packages/sql-semantics-mysql/src/Rules/Routine/BlockFacts.php:109
- type SqlSemantics\Platform\MySql\Rules\Routine\BlockFacts packages/sql-semantics-mysql/src/Rules/Routine/BlockFacts.php:123
- type SqlSemantics\Platform\MySql\Rules\Routine\BlockFacts packages/sql-semantics-mysql/src/Rules/Routine/BlockFacts.php:147
- type SqlSemantics\Platform\MySql\Rules\Routine\BodyFacts packages/sql-semantics-mysql/src/Rules/Routine/BodyFacts.php:45
- type SqlSemantics\Platform\MySql\Rules\Routine\BodyFacts packages/sql-semantics-mysql/src/Rules/Routine/BodyFacts.php:55
- type SqlSemantics\Platform\MySql\Rules\Routine\ConditionFacts packages/sql-semantics-mysql/src/Rules/Routine/ConditionFacts.php:47
- type SqlSemantics\Platform\MySql\Rules\Routine\ConditionFacts packages/sql-semantics-mysql/src/Rules/Routine/ConditionFacts.php:63
- type SqlSemantics\Platform\MySql\Rules\Routine\ConditionFacts packages/sql-semantics-mysql/src/Rules/Routine/ConditionFacts.php:86
- type SqlSemantics\Platform\MySql\Rules\Routine\ConditionFacts packages/sql-semantics-mysql/src/Rules/Routine/ConditionFacts.php:109
- type SqlSemantics\Platform\MySql\Rules\Routine\CursorFacts packages/sql-semantics-mysql/src/Rules/Routine/CursorFacts.php:31
- type SqlSemantics\Platform\MySql\Rules\Routine\CursorFacts packages/sql-semantics-mysql/src/Rules/Routine/CursorFacts.php:43
- type SqlSemantics\Platform\MySql\Rules\Routine\FlowFacts packages/sql-semantics-mysql/src/Rules/Routine/FlowFacts.php:40
- type SqlSemantics\Platform\MySql\Rules\Routine\FlowFacts packages/sql-semantics-mysql/src/Rules/Routine/FlowFacts.php:54
- type SqlSemantics\Platform\MySql\Rules\Routine\FlowFacts packages/sql-semantics-mysql/src/Rules/Routine/FlowFacts.php:66
- type SqlSemantics\Platform\MySql\Rules\Routine\FlowFacts packages/sql-semantics-mysql/src/Rules/Routine/FlowFacts.php:77
- type SqlSemantics\Platform\MySql\Rules\Routine\LabelFacts packages/sql-semantics-mysql/src/Rules/Routine/LabelFacts.php:30
- type SqlSemantics\Platform\MySql\Rules\Routine\TriggerAssignments packages/sql-semantics-mysql/src/Rules/Routine/TriggerAssignments.php:43
- type SqlSemantics\Platform\MySql\Statement\Routine\Condition\Diagnostics\GetDiagnostics packages/sql-semantics-mysql/src/Statement/Routine/Condition/Diagnostics/GetDiagnostics.php:50
- type SqlSemantics\Platform\MySql\Statement\Routine\Condition\Resignal packages/sql-semantics-mysql/src/Statement/Routine/Condition/Resignal.php:58
- type SqlSemantics\Platform\MySql\Statement\Routine\Condition\Signal packages/sql-semantics-mysql/src/Statement/Routine/Condition/Signal.php:58
- type SqlSemantics\Platform\MySql\Statement\Routine\Program\Block packages/sql-semantics-mysql/src/Statement/Routine/Program/Block.php:62
- type SqlSemantics\Platform\MySql\Statement\Routine\Program\Cursor\CloseCursor packages/sql-semantics-mysql/src/Statement/Routine/Program/Cursor/CloseCursor.php:41
- type SqlSemantics\Platform\MySql\Statement\Routine\Program\Cursor\FetchCursor packages/sql-semantics-mysql/src/Statement/Routine/Program/Cursor/FetchCursor.php:50
- type SqlSemantics\Platform\MySql\Statement\Routine\Program\Cursor\OpenCursor packages/sql-semantics-mysql/src/Statement/Routine/Program/Cursor/OpenCursor.php:40
- type SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\IfStatement packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/IfStatement.php:58
- type SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\Iterate packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/Iterate.php:41
- type SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\Leave packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/Leave.php:41
- type SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\Loop packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/Loop.php:55
- type SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\RepeatLoop packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/RepeatLoop.php:57
- type SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\ReturnStatement packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/ReturnStatement.php:40
- type SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\SearchedCase packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/SearchedCase.php:57
- type SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\SimpleCase packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/SimpleCase.php:61
- type SqlSemantics\Platform\MySql\Statement\Routine\Program\Flow\WhileLoop packages/sql-semantics-mysql/src/Statement/Routine/Program/Flow/WhileLoop.php:57
- type SqlSemantics\Platform\MySql\Statement\Routine\Program\ProgramStatement packages/sql-semantics-mysql/src/Statement/Routine/Program/ProgramStatement.php:29