classLeafKeys
final class LeafKeys
implements LeafKeys
Keys SQLite tokens for the token correspondence check.
Rule: SQLITE-LEAF-KEYS-001. A token at an identifier position is keyed by its decoded name, so equivalent spellings of one name are equal. An unqualified word used as a value is keyed apart when it is written in double quotes or is the bare word TRUE or FALSE, because those are other requests than a column use. A word before JOIN that is written as a join keyword is keyed as that keyword. A string is keyed by its decoded text, a BLOB by its hexadecimal digits, a number by its spelling without digit separators and without regard to case, a bind parameter by its exact text. Every other token is keyed by its terminal and its text without regard to ASCII case, so = and == stay different. The positions and synonyms of Noise are the only exceptions. The keys of the words before JOIN depend on the production read just before them, so one instance keys one token sequence at a time, in order. Status: Implemented.
Methods§
public function key(Token $token, string $signature, int $position): ?stringAnswers the comparison key of a token, or null for declared noise.
Parameters
$token | Token | |
$signature | string | |
$position | int |
Returns
?stringTest cases 7
LeafKeysTest::testKeyAnswersNullForAnEmptyTokenAndForADeclaredNoisePositioncallsLeafKeysTest::testKeyCountsTheJoinWordsOfTheLatestOperatorOnlycallsLeafKeysTest::testKeyKeysAKeywordByItsTerminalAndUpperCasedTextcallsLeafKeysTest::testKeyKeysANameBeforeJoinByItsNameWhenItIsNoJoinKeywordcallsLeafKeysTest::testKeyKeysAnIdentifierPositionByItsDecodedNamecallsLeafKeysTest::testKeyKeysAnUnqualifiedWordUsedAsAValueByTheRequestItIscallsLeafKeysTest::testKeyKeysAWordBeforeJoinAsTheJoinKeywordItIsWrittenAscalls
Calls 15
- function-call
in_arrayline 47 - static-call Noise::positions() line 47
- static-call DefinitionNoise::positions() line 47
- function-call
str_starts_withline 50 - function-call
substr_countline 51 - function-call
strtoupperline 55 - method-call LeafKeys::word() line 59
- function-call
explodeline 61 - function-call
substrline 61 - function-call
strposline 61 - function-call
str_ends_withline 61 - class-const LeafKeys::IDENTIFIERS() line 63
- method-call Identifiers::decode() line 64
- new Identifiers line 64
- method-call LeafKeys::literal() line 67
public function word(Token $token): stringKeys an unqualified word used as a value by the request it is.
Parameters
$token | Token |
Returns
stringTest cases 2
Called from 1
Calls 5
- method-call Identifiers::decode() line 75
- new Identifiers line 75
- function-call
str_starts_withline 76 - function-call
in_arrayline 80 - function-call
strtolowerline 80
public function literal(Token $token): stringKeys a token that is no identifier: a literal by its value, a keyword or punctuation by its terminal and text.
Parameters
$token | Token |
Returns
stringTest cases 5
LeafKeysTest::testLiteralKeysABindParameterByItsExactTextcallsLeafKeysTest::testLiteralKeysABlobByItsUpperCasedHexadecimalDigitscallsLeafKeysTest::testLiteralKeysANumberWithoutDigitSeparatorsAndWithoutRegardToCasecallsLeafKeysTest::testLiteralKeysAnyOtherTokenByItsTerminalAndUpperCasedTextcallsLeafKeysTest::testLiteralKeysAStringByItsDecodedTextcalls
Called from 1
Calls 7
- method-call Identifiers::decode() line 89
- new Identifiers line 89
- function-call
strtoupperline 90 - function-call
substrline 90 - function-call
str_replaceline 91 - static-call Noise::synonyms() line 93
- function-call
strtrline 93
Private surface 3§
Implementation details, listed for orientation only.
private const IDENTIFIERS = ['idj', 'ids', 'id', 'nm: STRING']private array<string, list<string>> $symbols = []private int $joinWords = 0Test cases 19§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 14
LeafKeysTest::testKeyAnswersNullForAnEmptyTokenAndForADeclaredNoisePositioncallsLeafKeysTest::testKeyCountsTheJoinWordsOfTheLatestOperatorOnlycallsLeafKeysTest::testKeyKeysAKeywordByItsTerminalAndUpperCasedTextcallsLeafKeysTest::testKeyKeysANameBeforeJoinByItsNameWhenItIsNoJoinKeywordcallsLeafKeysTest::testKeyKeysAnIdentifierPositionByItsDecodedNamecallsLeafKeysTest::testKeyKeysAnUnqualifiedWordUsedAsAValueByTheRequestItIscallsLeafKeysTest::testKeyKeysAWordBeforeJoinAsTheJoinKeywordItIsWrittenAscallsLeafKeysTest::testLiteralKeysABindParameterByItsExactTextcallsLeafKeysTest::testLiteralKeysABlobByItsUpperCasedHexadecimalDigitscallsLeafKeysTest::testLiteralKeysANumberWithoutDigitSeparatorsAndWithoutRegardToCasecallsLeafKeysTest::testLiteralKeysAnyOtherTokenByItsTerminalAndUpperCasedTextcallsLeafKeysTest::testLiteralKeysAStringByItsDecodedTextcallsLeafKeysTest::testWordKeysADoubleQuotedWordApartFromABareNamecallsLeafKeysTest::testWordKeysTheBareWordsTrueAndFalseAsTruthValuescalls