classPrecedence
final class Precedence
Decides whether an operand keeps its place when an operator expression is written without parentheses.
Rule: SQLITE-PRECEDENCE-001. The binding levels are those of the SQLite grammar, weakest first: OR; AND; NOT; the equality group (=, ==, <>, !=, IS, LIKE, GLOB, REGEXP, MATCH, BETWEEN, IN, ISNULL, NOTNULL, NOT NULL); the ordering comparisons; ESCAPE; the bitwise group; + and -; *, / and %; || and the JSON extraction operators; COLLATE; the prefix operators ~, + and -. Binary operators group to the left. An operand written on the left of an operator keeps its place when no expression on its right edge binds weaker than the operator; an operand written on the right keeps its place when every expression on its left edge binds tighter. A prefix operator on the right edge takes every tighter operator that follows it. Terminates: each walk follows one edge of a finite tree. Source: https://sqlite.org/lang_expr.html#operators_and_parse_affecting_attributes. Status: Implemented.
Constants§
public const DISJUNCTION = 1The level of OR.
public const CONJUNCTION = 2The level of AND.
public const NEGATION = 3The level of the prefix NOT.
public const EQUALITY = 4The level of the equality group.
public const COMPARISON = 5The level of the ordering comparisons.
public const ESCAPE = 6The level of ESCAPE.
public const BITWISE = 7The level of the bitwise operators.
public const ADDITIVE = 8The level of binary plus and minus.
public const MULTIPLICATIVE = 9The level of multiplication, division and remainder.
public const CONCATENATION = 10The level of concatenation and JSON extraction.
public const COLLATION = 11The level of COLLATE.
public const PREFIX = 12The level of the prefix operators other than NOT.
public const CLOSED = 99The level of an expression that is closed on the asked edge.
Methods§
public function edges(Scalar $expression): array{int, Scalar|null, Scalar|null}|nullAnswers the level of an operator expression with its first and last written operand; null marks an edge that is not an operand.
Parameters
$expression | Scalar |
Returns
array{int, Scalar|null, Scalar|null}|null Null for an expression that is closed on both edgesTest cases 4
Called from 3
- method-call SqlSemantics\Platform\Sqlite\Rules\Expression\Precedence::opening() packages/sql-semantics-sqlite/src/Rules/Expression/Precedence.php:140
- method-call SqlSemantics\Platform\Sqlite\Rules\Expression\Precedence::closing() packages/sql-semantics-sqlite/src/Rules/Expression/Precedence.php:153
- method-call SqlSemantics\Platform\Sqlite\Rules\Expression\Precedence::takesEscape() packages/sql-semantics-sqlite/src/Rules/Expression/Precedence.php:165
Calls 5
- class-const UnaryOperator::Not() line 116
- class-const Precedence::NEGATION() line 116
- class-const Precedence::PREFIX() line 116
- class-const Precedence::COLLATION() line 119
- class-const Precedence::EQUALITY() line 122
public function opening(Scalar $operand): intAnswers the weakest level among the expressions on the left edge of an operand.
Parameters
$operand | Scalar |
Returns
intTest cases 1
Called from 6
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Between::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Between.php:53
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Between::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Between.php:54
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Binary::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Binary.php:52
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\PatternMatch::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/PatternMatch.php:67
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\PatternMatch::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/PatternMatch.php:68
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Unary::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Unary.php:46
Calls 3
- class-const Precedence::CLOSED() line 139
- method-call Precedence::edges() line 140
- function-call
minline 141
public function closing(Scalar $operand): intAnswers the weakest level among the expressions on the right edge of an operand.
Parameters
$operand | Scalar |
Returns
intTest cases 1
Called from 9
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Collate::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Collate.php:49
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Between::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Between.php:52
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Between::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Between.php:53
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Binary::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Binary.php:51
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\NullTest::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/NullTest.php:46
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\PatternMatch::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/PatternMatch.php:66
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Subquery\InList::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Subquery/InList.php:56
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Subquery\InQuery::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Subquery/InQuery.php:49
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Subquery\InTable::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Subquery/InTable.php:68
Calls 3
- class-const Precedence::CLOSED() line 152
- method-call Precedence::edges() line 153
- function-call
minline 154
public function takesEscape(Scalar $operand): boolTells whether a pattern match without ESCAPE lies on the right edge of an operand, where it would take a following ESCAPE.
Parameters
$operand | Scalar |
Returns
boolCalled from 1
Calls 1
- method-call Precedence::edges() line 165
Test cases 8§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 7
PrecedenceTest::testClosingIsTheWeakestLevelOnTheRightEdgeAndClosedAfterAPostfixOperatorcallsPrecedenceTest::testEdgesAnswersTheLevelAndBothOperandsOfABinaryOperationcallsPrecedenceTest::testEdgesOfAMatchEndWithTheEscapeWhenWrittencallsPrecedenceTest::testEdgesOfAPostfixOperatorHaveNoRightOperandcallsPrecedenceTest::testEdgesOfAPrefixOperatorHaveNoLeftOperandcallsPrecedenceTest::testOpeningIsTheWeakestLevelOnTheLeftEdgeAndClosedBeforeAPrefixOperatorcallsPrecedenceTest::testTakesEscapeFindsAPatternMatchWithoutEscapeOnTheRightEdgecalls
Other tests reaching this symbol 1
Relations§
Instantiated in 9
- new SqlSemantics\Platform\Sqlite\Statement\Expression\Collate::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Collate.php:49
- new SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Between::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Between.php:51
- new SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Binary::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Binary.php:50
- new SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\NullTest::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/NullTest.php:46
- new SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\PatternMatch::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/PatternMatch.php:65
- new SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Unary::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Unary.php:46
- new SqlSemantics\Platform\Sqlite\Statement\Expression\Subquery\InList::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Subquery/InList.php:56
- new SqlSemantics\Platform\Sqlite\Statement\Expression\Subquery\InQuery::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Subquery/InQuery.php:49
- new SqlSemantics\Platform\Sqlite\Statement\Expression\Subquery\InTable::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Subquery/InTable.php:68
Method calls 16
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Collate::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Collate.php:49
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Between::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Between.php:52
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Between::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Between.php:53
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Between::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Between.php:53
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Between::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Between.php:54
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Binary::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Binary.php:51
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Binary::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Binary.php:52
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\NullTest::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/NullTest.php:46
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\PatternMatch::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/PatternMatch.php:66
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\PatternMatch::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/PatternMatch.php:67
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\PatternMatch::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/PatternMatch.php:68
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\PatternMatch::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/PatternMatch.php:68
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Unary::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Unary.php:46
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Subquery\InList::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Subquery/InList.php:56
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Subquery\InQuery::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Subquery/InQuery.php:49
- method-call SqlSemantics\Platform\Sqlite\Statement\Expression\Subquery\InTable::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Subquery/InTable.php:68
Constant reads 29
- class-const SqlSemantics\Platform\Sqlite\Rules\Typing\Operators::binary() packages/sql-semantics-sqlite/src/Rules/Typing/Operators.php:59
- class-const SqlSemantics\Platform\Sqlite\Rules\Typing\Operators::binary() packages/sql-semantics-sqlite/src/Rules/Typing/Operators.php:59
- class-const SqlSemantics\Platform\Sqlite\Rules\Typing\Operators::binary() packages/sql-semantics-sqlite/src/Rules/Typing/Operators.php:60
- class-const SqlSemantics\Platform\Sqlite\Rules\Typing\Operators::binary() packages/sql-semantics-sqlite/src/Rules/Typing/Operators.php:60
- class-const SqlSemantics\Platform\Sqlite\Rules\Typing\Operators::binary() packages/sql-semantics-sqlite/src/Rules/Typing/Operators.php:61
- class-const SqlSemantics\Platform\Sqlite\Statement\Expression\Collate::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Collate.php:49
- class-const SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Between::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Between.php:52
- class-const SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Between::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Between.php:53
- class-const SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Between::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Between.php:53
- class-const SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Between::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Between.php:54
- class-const SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Binary::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Binary.php:64
- class-const SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Binary::deriveScalar() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Binary.php:64
- class-const SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\BinaryOperator::level() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/BinaryOperator.php:54
- class-const SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\BinaryOperator::level() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/BinaryOperator.php:55
- class-const SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\BinaryOperator::level() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/BinaryOperator.php:56
- class-const SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\BinaryOperator::level() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/BinaryOperator.php:57
- class-const SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\BinaryOperator::level() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/BinaryOperator.php:58
- class-const SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\BinaryOperator::level() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/BinaryOperator.php:59
- class-const SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\BinaryOperator::level() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/BinaryOperator.php:60
- class-const SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\BinaryOperator::level() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/BinaryOperator.php:61
- class-const SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\NullTest::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/NullTest.php:46
- class-const SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\PatternMatch::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/PatternMatch.php:66
- class-const SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\PatternMatch::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/PatternMatch.php:67
- class-const SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\PatternMatch::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/PatternMatch.php:68
- class-const SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Unary::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Unary.php:46
- class-const SqlSemantics\Platform\Sqlite\Statement\Expression\Operator\Unary::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Operator/Unary.php:46
- class-const SqlSemantics\Platform\Sqlite\Statement\Expression\Subquery\InList::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Subquery/InList.php:56
- class-const SqlSemantics\Platform\Sqlite\Statement\Expression\Subquery\InQuery::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Subquery/InQuery.php:49
- class-const SqlSemantics\Platform\Sqlite\Statement\Expression\Subquery\InTable::__construct() packages/sql-semantics-sqlite/src/Statement/Expression/Subquery/InTable.php:68