classConditionRule
final class ConditionRule
Lowers the expr and bool_pri levels: logical operators, NOT, truth tests, NULL tests and comparisons.
Rule: MYSQL-CONDITION-001. Scope: expr, bool_pri, or, and, comp_op, all_or_any. The binary operators of each level are left recursive; the left spine is walked in a loop and the operations are built from the innermost outwards, so the structure associates as the grammar does. && is AND and || without PIPES_AS_CONCAT is OR (their nonterminals are synonyms); SOME is the keyword ANY. Constructs: Logical, Not, TruthTest, NullTest, Comparison, QuantifiedComparison. Terminates: the spine loop descends one left child per step; every other child is a strict subtree. Source: https://dev.mysql.com/doc/refman/8.4/en/expressions.html. Status: Implemented.
Methods§
public function __construct(private Lowering $lowering)Parameters
$lowering | Lowering | The lowering this rule belongs to |
Lowers a node of expr.
Parameters
$expression | Node |
Returns
Throws
ImplementationGap When a production has no ruleTest cases 1
Called from 3
- method-call SqlSemantics\Platform\MySql\Lowering\Expression\ConditionRule::expression() packages/sql-semantics-mysql/src/Lowering/Expression/ConditionRule.php:110
- method-call SqlSemantics\Platform\MySql\Lowering\Expression\ConditionRule::unit() packages/sql-semantics-mysql/src/Lowering/Expression/ConditionRule.php:127
- method-call SqlSemantics\Platform\MySql\Lowering\Expression\ExpressionRules::expression() packages/sql-semantics-mysql/src/Lowering/Expression/ExpressionRules.php:44
Calls 7
- method-call Lowering::form() line 100
- class-const ConditionRule::LOGICAL() line 101
- method-call ConditionRule::synonym() line 103
- method-call ConditionRule::unit() line 108
- function-call
array_reverseline 109 - new Logical line 110
- method-call ConditionRule::expression() line 110
Lowers an expr production that is not a logical operation.
Parameters
$form | Form |
Returns
Throws
ImplementationGap When a production has no ruleTest cases 1
Called from 1
Calls 7
- method-call ConditionRule::boolean() line 124
- method-call Form::node() line 124
- new Not line 127
- method-call ConditionRule::expression() line 127
- class-const ConditionRule::TRUTH() line 129
- static-call ImplementationGap::production() line 129
- new TruthTest line 134
Lowers a node of bool_pri.
Parameters
$expression | Node |
Returns
Throws
ImplementationGap When a production has no ruleTest cases 1
Called from 2
- method-call SqlSemantics\Platform\MySql\Lowering\Expression\ConditionRule::unit() packages/sql-semantics-mysql/src/Lowering/Expression/ConditionRule.php:124
- method-call SqlSemantics\Platform\MySql\Lowering\Expression\ConditionRule::unit() packages/sql-semantics-mysql/src/Lowering/Expression/ConditionRule.php:134
Calls 7
- method-call Lowering::form() line 145
- class-const ConditionRule::BOOL_PRI() line 146
- static-call ImplementationGap::production() line 151
- method-call PredicateRule::predicate() line 153
- new PredicateRule line 153
- function-call
array_reverseline 154 - method-call ConditionRule::apply() line 155
Applies one left-recursive bool_pri production to its already lowered left operand.
Returns
Throws
ImplementationGap When a production has no ruleTest cases 1
Called from 1
Calls 11
- new PredicateRule line 168
- new NullTest line 171
- method-call ConditionRule::negatedNull() line 172
- new Comparison line 173
- class-const ComparisonOperator::NullSafeEqual() line 173
- method-call PredicateRule::predicate() line 173
- method-call Form::node() line 173
- method-call ConditionRule::operator() line 174
- new QuantifiedComparison line 175
- method-call ConditionRule::quantifier() line 175
- static-call ImplementationGap::production() line 177
Lowers IS NOT NULL, confirming the NOT keyword.
Returns
Test cases 1
Called from 1
Calls 2
- method-call Form::node() line 186
- new NullTest line 188
public function operator(Node $operator): ComparisonOperatorLowers a comparison operator.
Parameters
$operator | Node |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 3
- method-call SqlSemantics\Platform\MySql\Lowering\Expression\ConditionRule::apply() packages/sql-semantics-mysql/src/Lowering/Expression/ConditionRule.php:174
- method-call SqlSemantics\Platform\MySql\Lowering\Expression\ConditionRule::apply() packages/sql-semantics-mysql/src/Lowering/Expression/ConditionRule.php:175
- method-call SqlSemantics\Platform\MySql\Lowering\Expression\ConditionRule::apply() packages/sql-semantics-mysql/src/Lowering/Expression/ConditionRule.php:176
Calls 3
- method-call Lowering::form() line 198
- class-const ConditionRule::OPERATORS() line 200
- static-call ImplementationGap::production() line 200
public function quantifier(Node $quantifier): QuantifierLowers ALL or ANY.
Parameters
$quantifier | Node |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 2
- method-call SqlSemantics\Platform\MySql\Lowering\Expression\ConditionRule::apply() packages/sql-semantics-mysql/src/Lowering/Expression/ConditionRule.php:175
- method-call SqlSemantics\Platform\MySql\Lowering\Expression\ConditionRule::apply() packages/sql-semantics-mysql/src/Lowering/Expression/ConditionRule.php:176
Calls 3
- method-call Lowering::form() line 210
- class-const ConditionRule::QUANTIFIERS() line 212
- static-call ImplementationGap::production() line 212
public function synonym(Node $keyword): voidConfirms that a node is one of the synonym keywords of AND or OR.
Parameters
$keyword | Node |
Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 1
Calls 3
- method-call Lowering::form() line 222
- class-const ConditionRule::SYNONYMS() line 223
- static-call ImplementationGap::production() line 224
Private surface 7§
Implementation details, listed for orientation only.
private const LOGICAL = ['expr: expr or expr' => \SqlSemantics\Platform\MySql\Statement\Expression\Logi…private const TRUTH = ['expr: bool_pri IS TRUE_SYM' => [\SqlSemantics\Platform\MySql\Statement\Expres…private const BOOL_PRI = ['bool_pri: bool_pri IS NULL_SYM' => true, 'bool_pri: bool_pri IS not NULL_SYM'…private const OPERATORS = ['comp_op: EQ' => \SqlSemantics\Platform\MySql\Statement\Expression\ComparisonO…private const QUANTIFIERS = ['all_or_any: ALL' => \SqlSemantics\Platform\MySql\Statement\Expression\Subquer…private const SYNONYMS = ['or: OR_SYM' => true, 'or: OR2_SYM' => true, 'and: AND_SYM' => true, 'and: AND…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
ConditionRuleTest::testApplyLowersAQuantifiedComparisoncallsConditionRuleTest::testBooleanLowersAChainOfNullTestsAndComparisonscallsConditionRuleTest::testExpressionBuildsTheLeftAssociationOfAChaincallsConditionRuleTest::testNegatedNullLowersIsNotNullcallsConditionRuleTest::testOperatorLowersTheComparisonOperatorscallsConditionRuleTest::testQuantifierLowersSomeAsAnycallsConditionRuleTest::testSynonymRejectsANodeThatIsNoLogicalKeywordcallsConditionRuleTest::testUnitLowersNotAndTheTruthTestscalls