classItemRule
final class ItemRule
Lowers the select options, the select list and select list aliases of every grammar generation.
Rule: MYSQL-SELECT-ITEMS-001. Scope: select_options, select_option_list, select_option, query_spec_option, opt_query_spec_options, query_spec_option_list, query_expression_option, opt_query_expression_options, query_expression_option_list, select_item_list, select_item, select_alias. Options and items keep their written order; a select alias written as a string names the item like an identifier. An item without alias that the server names after its text keeps the layout of its expression (MYSQL-ITEM-LAYOUT-001) unless the expression is written exactly as its canonical rendering, which an item without layout stands for; an item that names itself, such as a column reference or a string (MYSQL-SELECT-ITEM-NAME-001), keeps none. Constructs: SelectOption, SelectExpression, Star, and the TableWildcard of the leaf rules. Terminates: lists are flattened iteratively. Source: https://dev.mysql.com/doc/refman/8.4/en/select.html. Status: Implemented.
Methods§
public function __construct(private Lowering $lowering)Parameters
$lowering | Lowering | The lowering this rule belongs to |
public function options(Node $options): list<SelectOption>Lowers the select options in written order.
Parameters
$options | Node |
Returns
list<SelectOption>Throws
ImplementationGap When a production has no ruleCalled from 9
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::part() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:58
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::head() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:120
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::create() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:240
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::create() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:241
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::derived() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:260
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::derived() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:261
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::derived() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:262
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\FactorRule::content() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/FactorRule.php:153
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\PrimaryRule::specification() packages/sql-semantics-mysql/src/Lowering/Query/Modern/PrimaryRule.php:91
Calls 7
- method-call Lowering::form() line 98
- class-const ItemRule::LISTS() line 99
- static-call ImplementationGap::production() line 99
- class-const ItemRule::SPINES() line 104
- method-call Lists::items() line 108
- new Lists line 108
- class-const ItemRule::OPTIONS() line 113
public function items(Node $list): list<SelectExpression|Star|TableWildcard>Lowers the select list in written order.
Parameters
$list | Node |
Returns
Throws
ImplementationGap When a production has no ruleCalled from 10
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::part() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:58
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::head() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:120
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::create() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:240
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::create() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:241
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::derived() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:260
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::derived() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:261
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::derived() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:262
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\FactorRule::content() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/FactorRule.php:153
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\PrimaryRule::specification() packages/sql-semantics-mysql/src/Lowering/Query/Modern/PrimaryRule.php:92
- method-call SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::selectItems() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:262
Calls 7
- method-call Lowering::form() line 127
- function-call
in_arrayline 128 - static-call ImplementationGap::production() line 129
- method-call Lists::elements() line 132
- new Lists line 132
- new Star line 135
- method-call ItemRule::item() line 139
public function item(Node $item): SelectExpression|TableWildcardLowers one select list item.
Parameters
$item | Node |
Returns
Throws
ImplementationGap When a production has no ruleCalled from 1
Calls 3
- method-call Lowering::form() line 152
- method-call ItemRule::expression() line 161
- static-call ImplementationGap::production() line 163
public function expression(Node $expression, Node $alias): SelectExpressionLowers a projected expression with its alias, keeping the layout of an expression without alias that the server names after its text and that is not written as the canonical rendering (MYSQL-ITEM-LAYOUT-001).
Returns
Throws
ImplementationGap When a production has no ruleCalled from 2
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\ItemRule::item() packages/sql-semantics-mysql/src/Lowering/Query/Shared/ItemRule.php:161
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\ItemRule::item() packages/sql-semantics-mysql/src/Lowering/Query/Shared/ItemRule.php:162
Calls 8
- method-call ItemRule::alias() line 174
- new ItemNaming line 176
- method-call ItemNaming::own() line 177
- method-call ItemLayout::of() line 177
- new ItemLayout line 177
- method-call ItemNaming::canonical() line 178
- new SelectExpression line 182
- method-call ItemRule::mark() line 182
Answers whether a select alias is written after AS; no alias answers AS, the mark of an item without alias.
Parameters
$alias | Node |
Returns
Throws
ImplementationGap When the production has no ruleCalled from 2
Calls 6
- method-call Lowering::form() line 192
- function-call
array_key_existsline 193 - class-const ItemRule::ALIASES() line 193
- static-call ImplementationGap::production() line 194
- class-const AliasMark::Bare() line 197
- class-const AliasMark::As() line 197
Lowers a select alias; no alias is null.
Parameters
$alias | Node |
Returns
?NameThrows
ImplementationGap When the production has no ruleCalled from 2
Calls 4
- method-call Lowering::form() line 207
- function-call
array_key_existsline 208 - class-const ItemRule::ALIASES() line 208
- static-call ImplementationGap::production() line 209
Private surface 5§
Implementation details, listed for orientation only.
private const OPTIONS = ['select_option: SQL_NO_CACHE_SYM' => \SqlSemantics\Platform\MySql\Statement\Qu…private const LISTS = ['select_options:' => false, 'opt_query_spec_options:' => false, 'opt_query_exp…private const SPINES = ['select_option_list: select_option_list select_option' => true, 'select_option…private const ALIASES = ['select_alias:' => null, 'select_alias: AS ident' => 1, 'select_alias: AS TEXT…private Lowering $loweringTest cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
ItemRuleTestcalls
Relations§
Instantiated in 9
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::part() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:55
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::head() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:118
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::create() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:237
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::derived() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:255
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\FactorRule::content() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/FactorRule.php:151
- new SqlSemantics\Platform\MySql\Lowering\Query\Modern\PrimaryRule::specification() packages/sql-semantics-mysql/src/Lowering/Query/Modern/PrimaryRule.php:88
- new SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::alias() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:219
- new SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::mark() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:229
- new SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::selectItems() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:262
Method calls 21
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::part() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:58
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::part() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:58
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::head() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:120
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::head() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:120
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::create() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:240
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::create() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:240
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::create() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:241
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::create() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:241
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::derived() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:260
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::derived() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:260
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::derived() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:261
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::derived() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:261
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::derived() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:262
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::derived() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:262
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\FactorRule::content() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/FactorRule.php:153
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\FactorRule::content() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/FactorRule.php:153
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\PrimaryRule::specification() packages/sql-semantics-mysql/src/Lowering/Query/Modern/PrimaryRule.php:91
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\PrimaryRule::specification() packages/sql-semantics-mysql/src/Lowering/Query/Modern/PrimaryRule.php:92
- method-call SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::alias() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:219
- method-call SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::mark() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:229
- method-call SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::selectItems() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:262