classKeywords
final class Keywords
The words the MySQL lexer of one release can read as something other than an identifier.
Rule: MYSQL-KEYWORDS-001. A word is unusable for a bare name when the release lists it as a keyword or as a function name (a function name is a keyword when a parenthesis follows, and under IGNORE_SPACE even after spaces), or when it starts with an underscore, because _charset words are character set introducers. The table is the keyword artifact the language profile pins. Treating every such word as reserved, including those a grammar position would accept bare, makes a bare spelling independent of the position it is written at. Source: https://dev.mysql.com/doc/refman/8.4/en/keywords.html. Status: Implemented.
Methods§
public function __construct(private GrammarRelease $release)Parameters
$release | GrammarRelease | The grammar release whose keyword artifact is read |
public function reserved(string $word): boolTells whether a word cannot be written as a bare name, compared without regard to ASCII case.
Parameters
$word | string |
Returns
boolTest cases 5
KeywordsTest::testReservedFollowsTheKeywordArtifactOfEachReleasecallsKeywordsTest::testReservedIsFalseForOrdinaryWordscallsKeywordsTest::testReservedIsTrueForFunctionNamesOfTheReleasecallsKeywordsTest::testReservedIsTrueForKeywordsOfTheReleaseWhateverTheCasecallsKeywordsTest::testReservedIsTrueForWordsStartingWithAnUnderscorecalls
Called from 1
Calls 5
- method-call VersionRegistry::resolve() line 47
- new VersionRegistry line 47
- function-call
is_arrayline 48 - function-call
array_keysline 49 - function-call
strtrline 56
Private surface 2§
Implementation details, listed for orientation only.
private static array<string, array<string, true>> $words = []private GrammarRelease $releaseTest cases 5§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 5
KeywordsTest::testReservedFollowsTheKeywordArtifactOfEachReleasecallsKeywordsTest::testReservedIsFalseForOrdinaryWordscallsKeywordsTest::testReservedIsTrueForFunctionNamesOfTheReleasecallsKeywordsTest::testReservedIsTrueForKeywordsOfTheReleaseWhateverTheCasecallsKeywordsTest::testReservedIsTrueForWordsStartingWithAnUnderscorecalls