classFunctionRule
final class FunctionRule
Lowers the function calls with a keyword name and a plain argument list, CHAR, TRIM and the calls written as name(...).
Rule: MYSQL-CALL-FUNCTION-001. Scope: function_call_keyword, function_call_nonkeyword, function_call_conflict and geometry_function except the special syntaxes of TemporalRule, WeightRule and JsonRule; function_call_generic, opt_udf_expr_list, udf_expr_list, udf_expr. Each keyword production names its function and the positions of its arguments (an expression, or an expression list that continues the arguments). SUBSTRING with FROM and FOR is SUBSTRING with commas (the synonyms of CallNoise). Constructs: KeywordCall, CharCall, Trim, Position, FunctionCall, CallArgument. Terminates: the argument list is flattened in a loop; every other child is a strict subtree. Source: https://dev.mysql.com/doc/refman/8.4/en/function-resolution.html, https://dev.mysql.com/doc/refman/8.4/en/built-in-function-reference.html. Status: Implemented.
Methods§
public function __construct(private Lowering $lowering)Parameters
$lowering | Lowering | The lowering this rule belongs to |
public function claims(string $signature): boolTells whether a production is one of this rule.
Parameters
$signature | string |
Returns
boolTest cases 1
Called from 1
Calls 3
- class-const FunctionRule::KEYWORDS() line 140
- class-const FunctionRule::TRIMS() line 140
- function-call
in_arrayline 140
Lowers a production this rule claims.
Parameters
$form | Form |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 2
Called from 1
Calls 15
- class-const FunctionRule::KEYWORDS() line 154
- method-call FunctionRule::keyword() line 155
- class-const FunctionRule::TRIMS() line 157
- new Trim line 160
- method-call FunctionRule::expression() line 160
- new CharCall line 165
- method-call Form::node() line 165
- method-call FunctionRule::niladic() line 167
- class-const KeywordFunction::CurrentUser() line 167
- new Position line 168
- new FunctionCall line 169
- method-call FunctionRule::arguments() line 169
- function-call
array_mapline 172 - new CallArgument line 172
- static-call ImplementationGap::production() line 175
public function keyword(
Form $form,
KeywordFunction $function,
list<int> $positions,
int|null $list,
): KeywordCallLowers a keyword production from its table row.
Parameters
$form | Form | |
$function | KeywordFunction | |
$positions | list<int> | The positions of the expressions |
$list | int|null | The position of an expression list that follows them |
Returns
Test cases 1
Called from 1
Calls 4
- method-call FunctionRule::expression() line 189
- function-call
array_pushline 192 - method-call Form::node() line 192
- new KeywordCall line 195
public function niladic(Form $form, KeywordFunction $function): KeywordCallLowers a niladic function written with optional empty parentheses.
Parameters
$form | Form | |
$function | KeywordFunction |
Returns
Test cases 1
Called from 1
Calls 4
- new KeywordCall line 203
- method-call Form::node() line 203
- class-const OptionalWords::Written() line 203
- class-const OptionalWords::Omitted() line 203
Lowers the expression at a position.
Parameters
$form | Form | |
$position | int |
Returns
Test cases 1
Called from 5
- method-call SqlSemantics\Platform\MySql\Lowering\Call\FunctionRule::call() packages/sql-semantics-mysql/src/Lowering/Call/FunctionRule.php:160
- method-call SqlSemantics\Platform\MySql\Lowering\Call\FunctionRule::call() packages/sql-semantics-mysql/src/Lowering/Call/FunctionRule.php:168
- method-call SqlSemantics\Platform\MySql\Lowering\Call\FunctionRule::keyword() packages/sql-semantics-mysql/src/Lowering/Call/FunctionRule.php:189
- method-call SqlSemantics\Platform\MySql\Lowering\Call\FunctionRule::argument() packages/sql-semantics-mysql/src/Lowering/Call/FunctionRule.php:251
- method-call SqlSemantics\Platform\MySql\Lowering\Call\FunctionRule::argument() packages/sql-semantics-mysql/src/Lowering/Call/FunctionRule.php:257
Calls 1
- method-call Form::node() line 211
public function arguments(Node $list): list<CallArgument>Lowers the arguments of an unqualified call: a node of opt_udf_expr_list.
Parameters
$list | Node |
Returns
list<CallArgument>Throws
ImplementationGap When a production has no ruleTest cases 1
Called from 1
Calls 5
- method-call Lowering::form() line 222
- static-call ImplementationGap::production() line 227
- method-call Lists::items() line 231
- new Lists line 231
- method-call FunctionRule::argument() line 232
public function argument(Node $argument): CallArgumentLowers one argument of an unqualified call: a node of udf_expr.
Parameters
$argument | Node |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 1
Calls 4
- method-call Lowering::form() line 246
- new CallArgument line 251
- method-call FunctionRule::expression() line 251
- static-call ImplementationGap::production() line 254
Private surface 3§
Implementation details, listed for orientation only.
private const KEYWORDS = ['function_call_keyword: DATE_SYM ( expr )' => [\SqlSemantics\Platform\MySql\St…private const TRIMS = ['function_call_keyword: TRIM ( expr )' => [null, null, 2], 'function_call_keyw…private Lowering $loweringTest cases 8§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 8
FunctionRuleTest::testArgumentLowersTheAliasOfMySql57callsFunctionRuleTest::testArgumentsLowersAnEmptyListcallsFunctionRuleTest::testCallLowersKeywordAndGenericCallscallsFunctionRuleTest::testCallReportsAProductionOutsideTheRulecallsFunctionRuleTest::testClaimsTellsTheProductionsOfTheRulecallsFunctionRuleTest::testExpressionLowersTheExpressionAtAPositioncallsFunctionRuleTest::testKeywordLowersTheArgumentsAtTheirPositionscallsFunctionRuleTest::testNiladicAcceptsOptionalParenthesescalls