From 949d1dfc2a96aff3fa23c2c25b60d968bae5812f Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 15 Oct 2024 18:01:44 +0100 Subject: [PATCH 1/8] Optimize isString Signed-off-by: Kamil Tekiela --- psalm-baseline.xml | 1 - src/Context.php | 22 +++++++--------------- src/Lexer.php | 2 +- tests/Lexer/IsMethodsTest.php | 5 +---- 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index aeef4c62..38a97da5 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -232,7 +232,6 @@ - diff --git a/src/Context.php b/src/Context.php index e5c67ccb..1c9cc307 100644 --- a/src/Context.php +++ b/src/Context.php @@ -469,25 +469,17 @@ public static function isSymbol(string $string): int|null /** * Checks if the given character is the beginning of a string. * - * @param string $string string to be checked + * @param string $character a character to be checked * * @return int|null the appropriate flag for the string type */ - public static function isString(string $string): int|null + public static function isString(string $character): int|null { - if ($string === '') { - return null; - } - - if (str_starts_with($string, '\'')) { - return Token::FLAG_STRING_SINGLE_QUOTES; - } - - if (str_starts_with($string, '"')) { - return Token::FLAG_STRING_DOUBLE_QUOTES; - } - - return null; + return match ($character) { + '\'' => Token::FLAG_STRING_SINGLE_QUOTES, + '"' => Token::FLAG_STRING_DOUBLE_QUOTES, + default => null, + }; } /** diff --git a/src/Lexer.php b/src/Lexer.php index eb3879a5..60d7f88d 100644 --- a/src/Lexer.php +++ b/src/Lexer.php @@ -868,7 +868,7 @@ public function parseString(string $quote = ''): Token|null $token = $this->str[$this->last]; $flags = Context::isString($token); - if (! $flags && $token !== $quote) { + if ($flags === null && $token !== $quote) { return null; } diff --git a/tests/Lexer/IsMethodsTest.php b/tests/Lexer/IsMethodsTest.php index 27dee015..2d723f41 100644 --- a/tests/Lexer/IsMethodsTest.php +++ b/tests/Lexer/IsMethodsTest.php @@ -107,11 +107,8 @@ public function testIsString(): void $this->assertEquals(Token::FLAG_STRING_SINGLE_QUOTES, Context::isString("'")); $this->assertEquals(Token::FLAG_STRING_DOUBLE_QUOTES, Context::isString('"')); - $this->assertEquals(Token::FLAG_STRING_SINGLE_QUOTES, Context::isString("'foo bar'")); - $this->assertEquals(Token::FLAG_STRING_DOUBLE_QUOTES, Context::isString('"foo bar"')); - $this->assertNull(Context::isString('')); - $this->assertNull(Context::isString('foo bar')); + $this->assertNull(Context::isString('f')); } public function testIsSymbol(): void From 0e979c89d876193a96ca1d2dd2ece448ac5d04e7 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 15 Oct 2024 18:10:27 +0100 Subject: [PATCH 2/8] Optimize isSymbol Signed-off-by: Kamil Tekiela --- psalm-baseline.xml | 1 - src/Context.php | 25 +++++++------------------ src/Lexer.php | 2 +- tests/Lexer/IsMethodsTest.php | 7 +++---- 4 files changed, 11 insertions(+), 24 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 38a97da5..8760aa30 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -229,7 +229,6 @@ value]]> - diff --git a/src/Context.php b/src/Context.php index 1c9cc307..2d257ce5 100644 --- a/src/Context.php +++ b/src/Context.php @@ -445,25 +445,14 @@ public static function isNumber(string $string): bool * * @return int|null the appropriate flag for the symbol type */ - public static function isSymbol(string $string): int|null + public static function isSymbol(string $character): int|null { - if ($string === '') { - return null; - } - - if (str_starts_with($string, '@')) { - return Token::FLAG_SYMBOL_VARIABLE; - } - - if (str_starts_with($string, '`')) { - return Token::FLAG_SYMBOL_BACKTICK; - } - - if (str_starts_with($string, ':') || str_starts_with($string, '?')) { - return Token::FLAG_SYMBOL_PARAMETER; - } - - return null; + return match ($character) { + '@' => Token::FLAG_SYMBOL_VARIABLE, + '`' => Token::FLAG_SYMBOL_BACKTICK, + ':', '?' => Token::FLAG_SYMBOL_PARAMETER, + default => null, + }; } /** diff --git a/src/Lexer.php b/src/Lexer.php index 60d7f88d..7da935c0 100644 --- a/src/Lexer.php +++ b/src/Lexer.php @@ -918,7 +918,7 @@ public function parseSymbol(): Token|null $token = $this->str[$this->last]; $flags = Context::isSymbol($token); - if (! $flags) { + if ($flags === null) { return null; } diff --git a/tests/Lexer/IsMethodsTest.php b/tests/Lexer/IsMethodsTest.php index 2d723f41..9feb77ed 100644 --- a/tests/Lexer/IsMethodsTest.php +++ b/tests/Lexer/IsMethodsTest.php @@ -115,12 +115,11 @@ public function testIsSymbol(): void { $this->assertEquals(Token::FLAG_SYMBOL_VARIABLE, Context::isSymbol('@')); $this->assertEquals(Token::FLAG_SYMBOL_BACKTICK, Context::isSymbol('`')); - - $this->assertEquals(Token::FLAG_SYMBOL_VARIABLE, Context::isSymbol('@id')); - $this->assertEquals(Token::FLAG_SYMBOL_BACKTICK, Context::isSymbol('`id`')); + $this->assertEquals(Token::FLAG_SYMBOL_PARAMETER, Context::isSymbol(':')); + $this->assertEquals(Token::FLAG_SYMBOL_PARAMETER, Context::isSymbol('?')); $this->assertNull(Context::isSymbol('')); - $this->assertNull(Context::isSymbol('id')); + $this->assertNull(Context::isSymbol('i')); } public function testisSeparator(): void From 0b21c5c443596ed05c4e04ea1c7086daf90f2a34 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 15 Oct 2024 18:18:23 +0100 Subject: [PATCH 3/8] Optimize isWhitespace Signed-off-by: Kamil Tekiela --- src/Context.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Context.php b/src/Context.php index 2d257ce5..799cae49 100644 --- a/src/Context.php +++ b/src/Context.php @@ -372,9 +372,12 @@ public static function isOperator(string $string): int|null /** * Checks if the given character is a whitespace. */ - public static function isWhitespace(string $string): bool + public static function isWhitespace(string $character): bool { - return $string === ' ' || $string === "\r" || $string === "\n" || $string === "\t"; + return match ($character) { + ' ', "\r", "\n", "\t" => true, + default => false, + }; } /** From bb60ad1684fd2b02cf704421841a7895106a6548 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 15 Oct 2024 18:55:30 +0100 Subject: [PATCH 4/8] Refactor escapeAll() Signed-off-by: Kamil Tekiela --- src/Context.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Context.php b/src/Context.php index 799cae49..cff05b76 100644 --- a/src/Context.php +++ b/src/Context.php @@ -6,6 +6,7 @@ use PhpMyAdmin\SqlParser\Contexts\ContextMySql50700; +use function array_map; use function class_exists; use function explode; use function in_array; @@ -672,11 +673,7 @@ public static function escape(string $str, string $quote = '`'): string */ public static function escapeAll(array $strings): array { - foreach ($strings as $key => $value) { - $strings[$key] = static::escape($value); - } - - return $strings; + return array_map(static::escape(...), $strings); } /** From b541c5a5700850ecc956eb89f4f228fbf88b379a Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 15 Oct 2024 19:11:06 +0100 Subject: [PATCH 5/8] Refactor isComment Signed-off-by: Kamil Tekiela --- src/Context.php | 45 +++++++++++++-------------------------------- 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/src/Context.php b/src/Context.php index cff05b76..ad38b4bc 100644 --- a/src/Context.php +++ b/src/Context.php @@ -388,39 +388,20 @@ public static function isWhitespace(string $character): bool */ public static function isComment(string $string, bool $end = false): int|null { - if ($string === '') { - return null; - } - - // If comment is Bash style (#): - if (str_starts_with($string, '#')) { - return Token::FLAG_COMMENT_BASH; - } - - // If comment is a MySQL command - if (str_starts_with($string, '/*!')) { - return Token::FLAG_COMMENT_MYSQL_CMD; - } - - // If comment is opening C style (/*) or is closing C style (*/), warning, it could conflict - // with wildcard and a real opening C style. - // It would look like the following valid SQL statement: "SELECT */* comment */ FROM...". - if (str_starts_with($string, '/*') || str_starts_with($string, '*/')) { - return Token::FLAG_COMMENT_C; - } - - // If comment is SQL style (--\s?): - if ( + return match (true) { + str_starts_with($string, '#') => Token::FLAG_COMMENT_BASH, + str_starts_with($string, '/*!') => Token::FLAG_COMMENT_MYSQL_CMD, + // If comment is opening C style (/*) or is closing C style (*/), warning, it could conflict + // with wildcard and a real opening C style. + // It would look like the following valid SQL statement: "SELECT */* comment */ FROM...". + str_starts_with($string, '/*') || str_starts_with($string, '*/') => Token::FLAG_COMMENT_C, str_starts_with($string, '-- ') - || str_starts_with($string, "--\r") - || str_starts_with($string, "--\n") - || str_starts_with($string, "--\t") - || ($string === '--' && $end) - ) { - return Token::FLAG_COMMENT_SQL; - } - - return null; + || str_starts_with($string, "--\r") + || str_starts_with($string, "--\n") + || str_starts_with($string, "--\t") + || ($string === '--' && $end) => Token::FLAG_COMMENT_SQL, + default => null, + }; } /** From 8d711e84df4ee0556895e19c1e406a1d67f4136c Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 15 Oct 2024 19:18:55 +0100 Subject: [PATCH 6/8] String offset access should always return a string Signed-off-by: Kamil Tekiela --- psalm-baseline.xml | 46 ------------------------------------ src/Lexer.php | 6 ++--- src/UtfString.php | 4 ++-- tests/Misc/UtfStringTest.php | 4 ++-- 4 files changed, 7 insertions(+), 53 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 8760aa30..7c47a7ac 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -176,49 +176,6 @@ str[$this->last]]]> - - str[$this->last + 1]]]> - str[$this->last]]]> - str[$this->last]]]> - str[$this->last]]]> - str[$this->last]]]> - str[$this->last]]]> - str[$this->last]]]> - str[$this->last]]]> - str[$this->last]]]> - str[$this->last]]]> - - - - - - - - str[$this->last++]]]> - str[$this->last++]]]> - str[$this->last]]]> - str[$this->last]]]> - str[$this->last]]]> - str[$this->last]]]> - str[$this->last]]]> - str[$this->last]]]> - str[$this->last]]]> - str[$this->last]]]> - str[$this->last]]]> - str[$this->last]]]> - str[$this->last]]]> - str[$this->last]]]> - str[$this->last]]]> - str[$this->last]]]> - str[$this->last]]]> - str[$this->last]]]> - str[$this->last]]]> - str[++$this->last]]]> - str[++$this->last]]]> - str[++$this->last]]]> - str[++$this->last]]]> - str[++$this->last]]]> - type]]> value]]> @@ -231,9 +188,6 @@ - - - diff --git a/src/Lexer.php b/src/Lexer.php index 7da935c0..b16608ff 100644 --- a/src/Lexer.php +++ b/src/Lexer.php @@ -546,7 +546,7 @@ public function parseComment(): Token|null $token = $this->str[$this->last]; // Bash style comments. (#comment\n) - if (Context::isComment($token)) { + if (Context::isComment($token) !== null) { while (++$this->last < $this->len && $this->str[$this->last] !== "\n") { $token .= $this->str[$this->last]; } @@ -562,7 +562,7 @@ public function parseComment(): Token|null // C style comments. (/*comment*\/) if (++$this->last < $this->len) { $token .= $this->str[$this->last]; - if (Context::isComment($token)) { + if (Context::isComment($token) !== null) { // There might be a conflict with "*" operator here, when string is "*/*". // This can occurs in the following statements: // - "SELECT */* comment */ FROM ..." @@ -633,7 +633,7 @@ public function parseComment(): Token|null $end = true; } - if (Context::isComment($token, $end)) { + if (Context::isComment($token, $end) !== null) { // Checking if this comment did not end already (```--\n```). if ($this->str[$this->last] !== "\n") { while (++$this->last < $this->len && $this->str[$this->last] !== "\n") { diff --git a/src/UtfString.php b/src/UtfString.php index 43b7e22e..c2a750b0 100644 --- a/src/UtfString.php +++ b/src/UtfString.php @@ -61,9 +61,9 @@ public function offsetExists(mixed $offset): bool * * @param int $offset the offset to be returned */ - public function offsetGet(mixed $offset): string|null + public function offsetGet(mixed $offset): string { - return $this->characters[$offset] ?? null; + return $this->characters[$offset] ?? ''; } /** diff --git a/tests/Misc/UtfStringTest.php b/tests/Misc/UtfStringTest.php index 0c638e39..9a3e7b7f 100644 --- a/tests/Misc/UtfStringTest.php +++ b/tests/Misc/UtfStringTest.php @@ -33,8 +33,8 @@ public function testArrayAccess(): void // offsetGet $this->assertEquals('.', $str[self::TEST_PHRASE_LEN - 1]); - $this->assertNull($str[-1]); - $this->assertNull($str[self::TEST_PHRASE_LEN]); + $this->assertEquals('', $str[-1]); + $this->assertEquals('', $str[self::TEST_PHRASE_LEN]); } public function testSet(): void From 3dcaadb773ff1227857b60b164247b326d29266c Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 15 Oct 2024 19:26:38 +0100 Subject: [PATCH 7/8] Turn $operators into a const Signed-off-by: Kamil Tekiela --- src/Context.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Context.php b/src/Context.php index ad38b4bc..f3dba599 100644 --- a/src/Context.php +++ b/src/Context.php @@ -79,10 +79,8 @@ abstract class Context /** * List of operators and their flags. - * - * @var array */ - public static array $operators = [ + private const OPERATORS = [ // Some operators (*, =) may have ambiguous flags, because they depend on // the context they are being used in. // For example: 1. SELECT * FROM table; # SQL specific (wildcard) @@ -367,7 +365,7 @@ public static function isKeyword(string $string, bool $isReserved = false): int| */ public static function isOperator(string $string): int|null { - return static::$operators[$string] ?? null; + return self::OPERATORS[$string] ?? null; } /** From dbee88aebabd74e1d063a3481f78e6e77440b9d5 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 15 Oct 2024 20:00:03 +0100 Subject: [PATCH 8/8] Context should not be directly loadable Signed-off-by: Kamil Tekiela --- psalm-baseline.xml | 3 --- src/Context.php | 27 ++++++++++++--------------- src/Contexts/ContextMariaDb100000.php | 6 ++---- src/Contexts/ContextMariaDb100100.php | 6 ++---- src/Contexts/ContextMariaDb100200.php | 6 ++---- src/Contexts/ContextMariaDb100300.php | 6 ++---- src/Contexts/ContextMariaDb100400.php | 6 ++---- src/Contexts/ContextMariaDb100500.php | 6 ++---- src/Contexts/ContextMariaDb100600.php | 6 ++---- src/Contexts/ContextMariaDb100700.php | 6 ++---- src/Contexts/ContextMariaDb100800.php | 6 ++---- src/Contexts/ContextMariaDb100900.php | 6 ++---- src/Contexts/ContextMariaDb101000.php | 6 ++---- src/Contexts/ContextMariaDb101100.php | 6 ++---- src/Contexts/ContextMariaDb110000.php | 6 ++---- src/Contexts/ContextMariaDb110100.php | 6 ++---- src/Contexts/ContextMariaDb110200.php | 6 ++---- src/Contexts/ContextMariaDb110300.php | 6 ++---- src/Contexts/ContextMariaDb110400.php | 6 ++---- src/Contexts/ContextMariaDb110500.php | 6 ++---- src/Contexts/ContextMySql50000.php | 6 ++---- src/Contexts/ContextMySql50100.php | 6 ++---- src/Contexts/ContextMySql50500.php | 6 ++---- src/Contexts/ContextMySql50600.php | 6 ++---- src/Contexts/ContextMySql50700.php | 6 ++---- src/Contexts/ContextMySql80000.php | 6 ++---- src/Contexts/ContextMySql80100.php | 6 ++---- src/Contexts/ContextMySql80200.php | 6 ++---- src/Contexts/ContextMySql80300.php | 6 ++---- src/Contexts/ContextMySql80400.php | 6 ++---- src/Contexts/ContextMySql90000.php | 6 ++---- src/Tools/ContextGenerator.php | 6 ++---- tests/Tools/templates/TestContext.php | 6 ++---- 33 files changed, 74 insertions(+), 142 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 7c47a7ac..44b5aa4b 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -156,9 +156,6 @@ - - - diff --git a/src/Context.php b/src/Context.php index f3dba599..9f752476 100644 --- a/src/Context.php +++ b/src/Context.php @@ -27,7 +27,7 @@ * * Holds the configuration of the context that is currently used. */ -abstract class Context +final class Context { /** * The maximum length of a keyword. @@ -55,7 +55,7 @@ abstract class Context * The prefix concatenated to the context name when an incomplete class name * is specified. */ - public static string $contextPrefix = 'PhpMyAdmin\\SqlParser\\Contexts\\Context'; + private const CONTEXT_PREFIX = 'PhpMyAdmin\\SqlParser\\Contexts\\Context'; /** * List of keywords. @@ -486,22 +486,19 @@ public static function load(string $context = ''): bool $context = ContextMySql50700::class; } - if (! class_exists($context)) { - if (! class_exists(self::$contextPrefix . $context)) { - return false; - } - - // Could be the fully qualified class name was given, like `ContextDBMS::class`. - if (class_exists('\\' . $context)) { - $context = '\\' . $context; - } else { - // Short context name (must be formatted into class name). - $context = self::$contextPrefix . $context; + $contextClass = $context; + if (! class_exists($contextClass)) { + $contextClass = self::CONTEXT_PREFIX . $context; + if (! class_exists($contextClass)) { + $contextClass = '\\' . $context; + if (! class_exists($contextClass)) { + return false; + } } } - self::$loadedContext = $context; - self::$keywords = $context::$keywords; + self::$loadedContext = $contextClass; + self::$keywords = $contextClass::KEYWORDS; return true; } diff --git a/src/Contexts/ContextMariaDb100000.php b/src/Contexts/ContextMariaDb100000.php index 026ae19b..0c8118c4 100644 --- a/src/Contexts/ContextMariaDb100000.php +++ b/src/Contexts/ContextMariaDb100000.php @@ -4,7 +4,6 @@ namespace PhpMyAdmin\SqlParser\Contexts; -use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; /** @@ -15,7 +14,7 @@ * * @see https://mariadb.com/kb/en/reserved-words/ */ -class ContextMariaDb100000 extends Context +final class ContextMariaDb100000 { /** * List of keywords. @@ -24,11 +23,10 @@ class ContextMariaDb100000 extends Context * * @see Token * - * @var array * @psalm-var non-empty-array * @phpstan-var non-empty-array */ - public static array $keywords = [ + public const KEYWORDS = [ 'ACTION' => Token::FLAG_KEYWORD, 'AFTER' => Token::FLAG_KEYWORD, 'AGGREGATE' => Token::FLAG_KEYWORD, diff --git a/src/Contexts/ContextMariaDb100100.php b/src/Contexts/ContextMariaDb100100.php index 7dd66bb7..266ae81f 100644 --- a/src/Contexts/ContextMariaDb100100.php +++ b/src/Contexts/ContextMariaDb100100.php @@ -4,7 +4,6 @@ namespace PhpMyAdmin\SqlParser\Contexts; -use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; /** @@ -15,7 +14,7 @@ * * @see https://mariadb.com/kb/en/reserved-words/ */ -class ContextMariaDb100100 extends Context +final class ContextMariaDb100100 { /** * List of keywords. @@ -24,11 +23,10 @@ class ContextMariaDb100100 extends Context * * @see Token * - * @var array * @psalm-var non-empty-array * @phpstan-var non-empty-array */ - public static array $keywords = [ + public const KEYWORDS = [ 'ACCOUNT' => Token::FLAG_KEYWORD, 'ACTION' => Token::FLAG_KEYWORD, 'AFTER' => Token::FLAG_KEYWORD, diff --git a/src/Contexts/ContextMariaDb100200.php b/src/Contexts/ContextMariaDb100200.php index 5494ee3e..fab2e37b 100644 --- a/src/Contexts/ContextMariaDb100200.php +++ b/src/Contexts/ContextMariaDb100200.php @@ -4,7 +4,6 @@ namespace PhpMyAdmin\SqlParser\Contexts; -use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; /** @@ -15,7 +14,7 @@ * * @see https://mariadb.com/kb/en/reserved-words/ */ -class ContextMariaDb100200 extends Context +final class ContextMariaDb100200 { /** * List of keywords. @@ -24,11 +23,10 @@ class ContextMariaDb100200 extends Context * * @see Token * - * @var array * @psalm-var non-empty-array * @phpstan-var non-empty-array */ - public static array $keywords = [ + public const KEYWORDS = [ 'ACCOUNT' => Token::FLAG_KEYWORD, 'ACTION' => Token::FLAG_KEYWORD, 'AFTER' => Token::FLAG_KEYWORD, diff --git a/src/Contexts/ContextMariaDb100300.php b/src/Contexts/ContextMariaDb100300.php index b856f95e..9fdc07a5 100644 --- a/src/Contexts/ContextMariaDb100300.php +++ b/src/Contexts/ContextMariaDb100300.php @@ -4,7 +4,6 @@ namespace PhpMyAdmin\SqlParser\Contexts; -use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; /** @@ -15,7 +14,7 @@ * * @see https://mariadb.com/kb/en/reserved-words/ */ -class ContextMariaDb100300 extends Context +final class ContextMariaDb100300 { /** * List of keywords. @@ -24,11 +23,10 @@ class ContextMariaDb100300 extends Context * * @see Token * - * @var array * @psalm-var non-empty-array * @phpstan-var non-empty-array */ - public static array $keywords = [ + public const KEYWORDS = [ 'ACCOUNT' => Token::FLAG_KEYWORD, 'ACTION' => Token::FLAG_KEYWORD, 'AFTER' => Token::FLAG_KEYWORD, diff --git a/src/Contexts/ContextMariaDb100400.php b/src/Contexts/ContextMariaDb100400.php index 4c08903b..f7ad1e40 100644 --- a/src/Contexts/ContextMariaDb100400.php +++ b/src/Contexts/ContextMariaDb100400.php @@ -4,7 +4,6 @@ namespace PhpMyAdmin\SqlParser\Contexts; -use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; /** @@ -15,7 +14,7 @@ * * @see https://mariadb.com/kb/en/reserved-words/ */ -class ContextMariaDb100400 extends Context +final class ContextMariaDb100400 { /** * List of keywords. @@ -24,11 +23,10 @@ class ContextMariaDb100400 extends Context * * @see Token * - * @var array * @psalm-var non-empty-array * @phpstan-var non-empty-array */ - public static array $keywords = [ + public const KEYWORDS = [ 'ACCOUNT' => Token::FLAG_KEYWORD, 'ACTION' => Token::FLAG_KEYWORD, 'AFTER' => Token::FLAG_KEYWORD, diff --git a/src/Contexts/ContextMariaDb100500.php b/src/Contexts/ContextMariaDb100500.php index bbda2ee1..0f0b7395 100644 --- a/src/Contexts/ContextMariaDb100500.php +++ b/src/Contexts/ContextMariaDb100500.php @@ -4,7 +4,6 @@ namespace PhpMyAdmin\SqlParser\Contexts; -use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; /** @@ -15,7 +14,7 @@ * * @see https://mariadb.com/kb/en/reserved-words/ */ -class ContextMariaDb100500 extends Context +final class ContextMariaDb100500 { /** * List of keywords. @@ -24,11 +23,10 @@ class ContextMariaDb100500 extends Context * * @see Token * - * @var array * @psalm-var non-empty-array * @phpstan-var non-empty-array */ - public static array $keywords = [ + public const KEYWORDS = [ 'ACCOUNT' => Token::FLAG_KEYWORD, 'ACTION' => Token::FLAG_KEYWORD, 'AFTER' => Token::FLAG_KEYWORD, diff --git a/src/Contexts/ContextMariaDb100600.php b/src/Contexts/ContextMariaDb100600.php index d433c7dc..9efa5f9b 100644 --- a/src/Contexts/ContextMariaDb100600.php +++ b/src/Contexts/ContextMariaDb100600.php @@ -4,7 +4,6 @@ namespace PhpMyAdmin\SqlParser\Contexts; -use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; /** @@ -15,7 +14,7 @@ * * @see https://mariadb.com/kb/en/reserved-words/ */ -class ContextMariaDb100600 extends Context +final class ContextMariaDb100600 { /** * List of keywords. @@ -24,11 +23,10 @@ class ContextMariaDb100600 extends Context * * @see Token * - * @var array * @psalm-var non-empty-array * @phpstan-var non-empty-array */ - public static array $keywords = [ + public const KEYWORDS = [ 'ACCOUNT' => Token::FLAG_KEYWORD, 'ACTION' => Token::FLAG_KEYWORD, 'AFTER' => Token::FLAG_KEYWORD, diff --git a/src/Contexts/ContextMariaDb100700.php b/src/Contexts/ContextMariaDb100700.php index 0582cb85..d20a179f 100644 --- a/src/Contexts/ContextMariaDb100700.php +++ b/src/Contexts/ContextMariaDb100700.php @@ -4,7 +4,6 @@ namespace PhpMyAdmin\SqlParser\Contexts; -use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; /** @@ -15,7 +14,7 @@ * * @see https://mariadb.com/kb/en/reserved-words/ */ -class ContextMariaDb100700 extends Context +final class ContextMariaDb100700 { /** * List of keywords. @@ -24,11 +23,10 @@ class ContextMariaDb100700 extends Context * * @see Token * - * @var array * @psalm-var non-empty-array * @phpstan-var non-empty-array */ - public static array $keywords = [ + public const KEYWORDS = [ 'ACCOUNT' => Token::FLAG_KEYWORD, 'ACTION' => Token::FLAG_KEYWORD, 'AFTER' => Token::FLAG_KEYWORD, diff --git a/src/Contexts/ContextMariaDb100800.php b/src/Contexts/ContextMariaDb100800.php index df24f6d4..794fd7c5 100644 --- a/src/Contexts/ContextMariaDb100800.php +++ b/src/Contexts/ContextMariaDb100800.php @@ -4,7 +4,6 @@ namespace PhpMyAdmin\SqlParser\Contexts; -use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; /** @@ -15,7 +14,7 @@ * * @see https://mariadb.com/kb/en/reserved-words/ */ -class ContextMariaDb100800 extends Context +final class ContextMariaDb100800 { /** * List of keywords. @@ -24,11 +23,10 @@ class ContextMariaDb100800 extends Context * * @see Token * - * @var array * @psalm-var non-empty-array * @phpstan-var non-empty-array */ - public static array $keywords = [ + public const KEYWORDS = [ 'ACCOUNT' => Token::FLAG_KEYWORD, 'ACTION' => Token::FLAG_KEYWORD, 'AFTER' => Token::FLAG_KEYWORD, diff --git a/src/Contexts/ContextMariaDb100900.php b/src/Contexts/ContextMariaDb100900.php index bbdf85da..93a4d553 100644 --- a/src/Contexts/ContextMariaDb100900.php +++ b/src/Contexts/ContextMariaDb100900.php @@ -4,7 +4,6 @@ namespace PhpMyAdmin\SqlParser\Contexts; -use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; /** @@ -15,7 +14,7 @@ * * @see https://mariadb.com/kb/en/reserved-words/ */ -class ContextMariaDb100900 extends Context +final class ContextMariaDb100900 { /** * List of keywords. @@ -24,11 +23,10 @@ class ContextMariaDb100900 extends Context * * @see Token * - * @var array * @psalm-var non-empty-array * @phpstan-var non-empty-array */ - public static array $keywords = [ + public const KEYWORDS = [ 'ACCOUNT' => Token::FLAG_KEYWORD, 'ACTION' => Token::FLAG_KEYWORD, 'AFTER' => Token::FLAG_KEYWORD, diff --git a/src/Contexts/ContextMariaDb101000.php b/src/Contexts/ContextMariaDb101000.php index fed8c8cf..d7a89e70 100644 --- a/src/Contexts/ContextMariaDb101000.php +++ b/src/Contexts/ContextMariaDb101000.php @@ -4,7 +4,6 @@ namespace PhpMyAdmin\SqlParser\Contexts; -use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; /** @@ -15,7 +14,7 @@ * * @see https://mariadb.com/kb/en/reserved-words/ */ -class ContextMariaDb101000 extends Context +final class ContextMariaDb101000 { /** * List of keywords. @@ -24,11 +23,10 @@ class ContextMariaDb101000 extends Context * * @see Token * - * @var array * @psalm-var non-empty-array * @phpstan-var non-empty-array */ - public static array $keywords = [ + public const KEYWORDS = [ 'ACCOUNT' => Token::FLAG_KEYWORD, 'ACTION' => Token::FLAG_KEYWORD, 'AFTER' => Token::FLAG_KEYWORD, diff --git a/src/Contexts/ContextMariaDb101100.php b/src/Contexts/ContextMariaDb101100.php index 2011ef17..58e70ff9 100644 --- a/src/Contexts/ContextMariaDb101100.php +++ b/src/Contexts/ContextMariaDb101100.php @@ -4,7 +4,6 @@ namespace PhpMyAdmin\SqlParser\Contexts; -use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; /** @@ -15,7 +14,7 @@ * * @see https://mariadb.com/kb/en/reserved-words/ */ -class ContextMariaDb101100 extends Context +final class ContextMariaDb101100 { /** * List of keywords. @@ -24,11 +23,10 @@ class ContextMariaDb101100 extends Context * * @see Token * - * @var array * @psalm-var non-empty-array * @phpstan-var non-empty-array */ - public static array $keywords = [ + public const KEYWORDS = [ 'ACCOUNT' => Token::FLAG_KEYWORD, 'ACTION' => Token::FLAG_KEYWORD, 'AFTER' => Token::FLAG_KEYWORD, diff --git a/src/Contexts/ContextMariaDb110000.php b/src/Contexts/ContextMariaDb110000.php index 84c54c35..77b0a39b 100644 --- a/src/Contexts/ContextMariaDb110000.php +++ b/src/Contexts/ContextMariaDb110000.php @@ -4,7 +4,6 @@ namespace PhpMyAdmin\SqlParser\Contexts; -use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; /** @@ -15,7 +14,7 @@ * * @see https://mariadb.com/kb/en/reserved-words/ */ -class ContextMariaDb110000 extends Context +final class ContextMariaDb110000 { /** * List of keywords. @@ -24,11 +23,10 @@ class ContextMariaDb110000 extends Context * * @see Token * - * @var array * @psalm-var non-empty-array * @phpstan-var non-empty-array */ - public static array $keywords = [ + public const KEYWORDS = [ 'ACCOUNT' => Token::FLAG_KEYWORD, 'ACTION' => Token::FLAG_KEYWORD, 'AFTER' => Token::FLAG_KEYWORD, diff --git a/src/Contexts/ContextMariaDb110100.php b/src/Contexts/ContextMariaDb110100.php index 3cbeda86..21a879b5 100644 --- a/src/Contexts/ContextMariaDb110100.php +++ b/src/Contexts/ContextMariaDb110100.php @@ -4,7 +4,6 @@ namespace PhpMyAdmin\SqlParser\Contexts; -use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; /** @@ -15,7 +14,7 @@ * * @see https://mariadb.com/kb/en/reserved-words/ */ -class ContextMariaDb110100 extends Context +final class ContextMariaDb110100 { /** * List of keywords. @@ -24,11 +23,10 @@ class ContextMariaDb110100 extends Context * * @see Token * - * @var array * @psalm-var non-empty-array * @phpstan-var non-empty-array */ - public static array $keywords = [ + public const KEYWORDS = [ 'ACCOUNT' => Token::FLAG_KEYWORD, 'ACTION' => Token::FLAG_KEYWORD, 'AFTER' => Token::FLAG_KEYWORD, diff --git a/src/Contexts/ContextMariaDb110200.php b/src/Contexts/ContextMariaDb110200.php index 45f10b19..ec1421ae 100644 --- a/src/Contexts/ContextMariaDb110200.php +++ b/src/Contexts/ContextMariaDb110200.php @@ -4,7 +4,6 @@ namespace PhpMyAdmin\SqlParser\Contexts; -use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; /** @@ -15,7 +14,7 @@ * * @see https://mariadb.com/kb/en/reserved-words/ */ -class ContextMariaDb110200 extends Context +final class ContextMariaDb110200 { /** * List of keywords. @@ -24,11 +23,10 @@ class ContextMariaDb110200 extends Context * * @see Token * - * @var array * @psalm-var non-empty-array * @phpstan-var non-empty-array */ - public static array $keywords = [ + public const KEYWORDS = [ 'ACCOUNT' => Token::FLAG_KEYWORD, 'ACTION' => Token::FLAG_KEYWORD, 'AFTER' => Token::FLAG_KEYWORD, diff --git a/src/Contexts/ContextMariaDb110300.php b/src/Contexts/ContextMariaDb110300.php index cbc403c6..7895baa5 100644 --- a/src/Contexts/ContextMariaDb110300.php +++ b/src/Contexts/ContextMariaDb110300.php @@ -4,7 +4,6 @@ namespace PhpMyAdmin\SqlParser\Contexts; -use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; /** @@ -15,7 +14,7 @@ * * @see https://mariadb.com/kb/en/reserved-words/ */ -class ContextMariaDb110300 extends Context +final class ContextMariaDb110300 { /** * List of keywords. @@ -24,11 +23,10 @@ class ContextMariaDb110300 extends Context * * @see Token * - * @var array * @psalm-var non-empty-array * @phpstan-var non-empty-array */ - public static array $keywords = [ + public const KEYWORDS = [ 'ACCOUNT' => Token::FLAG_KEYWORD, 'ACTION' => Token::FLAG_KEYWORD, 'AFTER' => Token::FLAG_KEYWORD, diff --git a/src/Contexts/ContextMariaDb110400.php b/src/Contexts/ContextMariaDb110400.php index b01cb63f..2fc65a01 100644 --- a/src/Contexts/ContextMariaDb110400.php +++ b/src/Contexts/ContextMariaDb110400.php @@ -4,7 +4,6 @@ namespace PhpMyAdmin\SqlParser\Contexts; -use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; /** @@ -15,7 +14,7 @@ * * @see https://mariadb.com/kb/en/reserved-words/ */ -class ContextMariaDb110400 extends Context +final class ContextMariaDb110400 { /** * List of keywords. @@ -24,11 +23,10 @@ class ContextMariaDb110400 extends Context * * @see Token * - * @var array * @psalm-var non-empty-array * @phpstan-var non-empty-array */ - public static array $keywords = [ + public const KEYWORDS = [ 'ACCOUNT' => Token::FLAG_KEYWORD, 'ACTION' => Token::FLAG_KEYWORD, 'AFTER' => Token::FLAG_KEYWORD, diff --git a/src/Contexts/ContextMariaDb110500.php b/src/Contexts/ContextMariaDb110500.php index bc9c3f00..54b4ff50 100644 --- a/src/Contexts/ContextMariaDb110500.php +++ b/src/Contexts/ContextMariaDb110500.php @@ -4,7 +4,6 @@ namespace PhpMyAdmin\SqlParser\Contexts; -use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; /** @@ -15,7 +14,7 @@ * * @see https://mariadb.com/kb/en/reserved-words/ */ -class ContextMariaDb110500 extends Context +final class ContextMariaDb110500 { /** * List of keywords. @@ -24,11 +23,10 @@ class ContextMariaDb110500 extends Context * * @see Token * - * @var array * @psalm-var non-empty-array * @phpstan-var non-empty-array */ - public static array $keywords = [ + public const KEYWORDS = [ 'ACCOUNT' => Token::FLAG_KEYWORD, 'ACTION' => Token::FLAG_KEYWORD, 'AFTER' => Token::FLAG_KEYWORD, diff --git a/src/Contexts/ContextMySql50000.php b/src/Contexts/ContextMySql50000.php index 1e95872e..b147ea85 100644 --- a/src/Contexts/ContextMySql50000.php +++ b/src/Contexts/ContextMySql50000.php @@ -4,7 +4,6 @@ namespace PhpMyAdmin\SqlParser\Contexts; -use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; /** @@ -15,7 +14,7 @@ * * @see https://dev.mysql.com/doc/refman/5.0/en/keywords.html */ -class ContextMySql50000 extends Context +final class ContextMySql50000 { /** * List of keywords. @@ -24,11 +23,10 @@ class ContextMySql50000 extends Context * * @see Token * - * @var array * @psalm-var non-empty-array * @phpstan-var non-empty-array */ - public static array $keywords = [ + public const KEYWORDS = [ 'ACTION' => Token::FLAG_KEYWORD, 'AFTER' => Token::FLAG_KEYWORD, 'AGGREGATE' => Token::FLAG_KEYWORD, diff --git a/src/Contexts/ContextMySql50100.php b/src/Contexts/ContextMySql50100.php index be68b4c1..289a25a0 100644 --- a/src/Contexts/ContextMySql50100.php +++ b/src/Contexts/ContextMySql50100.php @@ -4,7 +4,6 @@ namespace PhpMyAdmin\SqlParser\Contexts; -use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; /** @@ -15,7 +14,7 @@ * * @see https://dev.mysql.com/doc/refman/5.1/en/keywords.html */ -class ContextMySql50100 extends Context +final class ContextMySql50100 { /** * List of keywords. @@ -24,11 +23,10 @@ class ContextMySql50100 extends Context * * @see Token * - * @var array * @psalm-var non-empty-array * @phpstan-var non-empty-array */ - public static array $keywords = [ + public const KEYWORDS = [ 'ACTION' => Token::FLAG_KEYWORD, 'AFTER' => Token::FLAG_KEYWORD, 'AGGREGATE' => Token::FLAG_KEYWORD, diff --git a/src/Contexts/ContextMySql50500.php b/src/Contexts/ContextMySql50500.php index 363ff5a8..d724cca5 100644 --- a/src/Contexts/ContextMySql50500.php +++ b/src/Contexts/ContextMySql50500.php @@ -4,7 +4,6 @@ namespace PhpMyAdmin\SqlParser\Contexts; -use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; /** @@ -15,7 +14,7 @@ * * @see https://dev.mysql.com/doc/refman/5.5/en/keywords.html */ -class ContextMySql50500 extends Context +final class ContextMySql50500 { /** * List of keywords. @@ -24,11 +23,10 @@ class ContextMySql50500 extends Context * * @see Token * - * @var array * @psalm-var non-empty-array * @phpstan-var non-empty-array */ - public static array $keywords = [ + public const KEYWORDS = [ 'ACTION' => Token::FLAG_KEYWORD, 'AFTER' => Token::FLAG_KEYWORD, 'AGGREGATE' => Token::FLAG_KEYWORD, diff --git a/src/Contexts/ContextMySql50600.php b/src/Contexts/ContextMySql50600.php index d51a229e..c99c7b9e 100644 --- a/src/Contexts/ContextMySql50600.php +++ b/src/Contexts/ContextMySql50600.php @@ -4,7 +4,6 @@ namespace PhpMyAdmin\SqlParser\Contexts; -use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; /** @@ -15,7 +14,7 @@ * * @see https://dev.mysql.com/doc/refman/5.6/en/keywords.html */ -class ContextMySql50600 extends Context +final class ContextMySql50600 { /** * List of keywords. @@ -24,11 +23,10 @@ class ContextMySql50600 extends Context * * @see Token * - * @var array * @psalm-var non-empty-array * @phpstan-var non-empty-array */ - public static array $keywords = [ + public const KEYWORDS = [ 'ACTION' => Token::FLAG_KEYWORD, 'AFTER' => Token::FLAG_KEYWORD, 'AGGREGATE' => Token::FLAG_KEYWORD, diff --git a/src/Contexts/ContextMySql50700.php b/src/Contexts/ContextMySql50700.php index 8b856323..0bb8cd30 100644 --- a/src/Contexts/ContextMySql50700.php +++ b/src/Contexts/ContextMySql50700.php @@ -4,7 +4,6 @@ namespace PhpMyAdmin\SqlParser\Contexts; -use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; /** @@ -15,7 +14,7 @@ * * @see https://dev.mysql.com/doc/refman/5.7/en/keywords.html */ -class ContextMySql50700 extends Context +final class ContextMySql50700 { /** * List of keywords. @@ -24,11 +23,10 @@ class ContextMySql50700 extends Context * * @see Token * - * @var array * @psalm-var non-empty-array * @phpstan-var non-empty-array */ - public static array $keywords = [ + public const KEYWORDS = [ 'ACCOUNT' => Token::FLAG_KEYWORD, 'ACTION' => Token::FLAG_KEYWORD, 'AFTER' => Token::FLAG_KEYWORD, diff --git a/src/Contexts/ContextMySql80000.php b/src/Contexts/ContextMySql80000.php index 320f43dd..78d840b4 100644 --- a/src/Contexts/ContextMySql80000.php +++ b/src/Contexts/ContextMySql80000.php @@ -4,7 +4,6 @@ namespace PhpMyAdmin\SqlParser\Contexts; -use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; /** @@ -15,7 +14,7 @@ * * @see https://dev.mysql.com/doc/refman/8.0/en/keywords.html */ -class ContextMySql80000 extends Context +final class ContextMySql80000 { /** * List of keywords. @@ -24,11 +23,10 @@ class ContextMySql80000 extends Context * * @see Token * - * @var array * @psalm-var non-empty-array * @phpstan-var non-empty-array */ - public static array $keywords = [ + public const KEYWORDS = [ 'ACCOUNT' => Token::FLAG_KEYWORD, 'ACTION' => Token::FLAG_KEYWORD, 'AFTER' => Token::FLAG_KEYWORD, diff --git a/src/Contexts/ContextMySql80100.php b/src/Contexts/ContextMySql80100.php index bb4941dc..81a24964 100644 --- a/src/Contexts/ContextMySql80100.php +++ b/src/Contexts/ContextMySql80100.php @@ -4,7 +4,6 @@ namespace PhpMyAdmin\SqlParser\Contexts; -use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; /** @@ -15,7 +14,7 @@ * * @see https://dev.mysql.com/doc/refman/8.1/en/keywords.html */ -class ContextMySql80100 extends Context +final class ContextMySql80100 { /** * List of keywords. @@ -24,11 +23,10 @@ class ContextMySql80100 extends Context * * @see Token * - * @var array * @psalm-var non-empty-array * @phpstan-var non-empty-array */ - public static array $keywords = [ + public const KEYWORDS = [ 'ACCOUNT' => Token::FLAG_KEYWORD, 'ACTION' => Token::FLAG_KEYWORD, 'AFTER' => Token::FLAG_KEYWORD, diff --git a/src/Contexts/ContextMySql80200.php b/src/Contexts/ContextMySql80200.php index ec95e30a..d60709c1 100644 --- a/src/Contexts/ContextMySql80200.php +++ b/src/Contexts/ContextMySql80200.php @@ -4,7 +4,6 @@ namespace PhpMyAdmin\SqlParser\Contexts; -use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; /** @@ -15,7 +14,7 @@ * * @see https://dev.mysql.com/doc/refman/8.2/en/keywords.html */ -class ContextMySql80200 extends Context +final class ContextMySql80200 { /** * List of keywords. @@ -24,11 +23,10 @@ class ContextMySql80200 extends Context * * @see Token * - * @var array * @psalm-var non-empty-array * @phpstan-var non-empty-array */ - public static array $keywords = [ + public const KEYWORDS = [ 'ACCOUNT' => Token::FLAG_KEYWORD, 'ACTION' => Token::FLAG_KEYWORD, 'AFTER' => Token::FLAG_KEYWORD, diff --git a/src/Contexts/ContextMySql80300.php b/src/Contexts/ContextMySql80300.php index 2c781eab..1b8eb3f0 100644 --- a/src/Contexts/ContextMySql80300.php +++ b/src/Contexts/ContextMySql80300.php @@ -4,7 +4,6 @@ namespace PhpMyAdmin\SqlParser\Contexts; -use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; /** @@ -15,7 +14,7 @@ * * @see https://dev.mysql.com/doc/refman/8.3/en/keywords.html */ -class ContextMySql80300 extends Context +final class ContextMySql80300 { /** * List of keywords. @@ -24,11 +23,10 @@ class ContextMySql80300 extends Context * * @see Token * - * @var array * @psalm-var non-empty-array * @phpstan-var non-empty-array */ - public static array $keywords = [ + public const KEYWORDS = [ 'ACCOUNT' => Token::FLAG_KEYWORD, 'ACTION' => Token::FLAG_KEYWORD, 'AFTER' => Token::FLAG_KEYWORD, diff --git a/src/Contexts/ContextMySql80400.php b/src/Contexts/ContextMySql80400.php index b50d06ff..40b0ad4f 100644 --- a/src/Contexts/ContextMySql80400.php +++ b/src/Contexts/ContextMySql80400.php @@ -4,7 +4,6 @@ namespace PhpMyAdmin\SqlParser\Contexts; -use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; /** @@ -15,7 +14,7 @@ * * @see https://dev.mysql.com/doc/refman/8.4/en/keywords.html */ -class ContextMySql80400 extends Context +final class ContextMySql80400 { /** * List of keywords. @@ -24,11 +23,10 @@ class ContextMySql80400 extends Context * * @see Token * - * @var array * @psalm-var non-empty-array * @phpstan-var non-empty-array */ - public static array $keywords = [ + public const KEYWORDS = [ 'ACCOUNT' => Token::FLAG_KEYWORD, 'ACTION' => Token::FLAG_KEYWORD, 'AFTER' => Token::FLAG_KEYWORD, diff --git a/src/Contexts/ContextMySql90000.php b/src/Contexts/ContextMySql90000.php index 0c99c7d2..88939ac1 100644 --- a/src/Contexts/ContextMySql90000.php +++ b/src/Contexts/ContextMySql90000.php @@ -4,7 +4,6 @@ namespace PhpMyAdmin\SqlParser\Contexts; -use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; /** @@ -15,7 +14,7 @@ * * @see https://dev.mysql.com/doc/refman/9.0/en/keywords.html */ -class ContextMySql90000 extends Context +final class ContextMySql90000 { /** * List of keywords. @@ -24,11 +23,10 @@ class ContextMySql90000 extends Context * * @see Token * - * @var array * @psalm-var non-empty-array * @phpstan-var non-empty-array */ - public static array $keywords = [ + public const KEYWORDS = [ 'ACCOUNT' => Token::FLAG_KEYWORD, 'ACTION' => Token::FLAG_KEYWORD, 'AFTER' => Token::FLAG_KEYWORD, diff --git a/src/Tools/ContextGenerator.php b/src/Tools/ContextGenerator.php index f6b4952c..6632f8b8 100644 --- a/src/Tools/ContextGenerator.php +++ b/src/Tools/ContextGenerator.php @@ -116,7 +116,6 @@ class ContextGenerator namespace PhpMyAdmin\SqlParser\Contexts; -use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; /** @@ -127,7 +126,7 @@ class ContextGenerator * * @see %3$s */ -class %2$s extends Context +final class %2$s { /** * List of keywords. @@ -136,11 +135,10 @@ class %2$s extends Context * * @see Token * - * @var array * @psalm-var non-empty-array * @phpstan-var non-empty-array */ - public static array $keywords = [ + public const KEYWORDS = [ %4$s ]; } diff --git a/tests/Tools/templates/TestContext.php b/tests/Tools/templates/TestContext.php index ba582055..d89522c1 100644 --- a/tests/Tools/templates/TestContext.php +++ b/tests/Tools/templates/TestContext.php @@ -4,7 +4,6 @@ namespace PhpMyAdmin\SqlParser\Contexts; -use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Token; /** @@ -15,7 +14,7 @@ * * @see https://www.phpmyadmin.net/contribute */ -class TestContext extends Context +final class TestContext { /** * List of keywords. @@ -24,11 +23,10 @@ class TestContext extends Context * * @see Token * - * @var array * @psalm-var non-empty-array * @phpstan-var non-empty-array */ - public static array $keywords = [ + public const KEYWORDS = [ 'NO_FLAG' => Token::FLAG_KEYWORD, 'RESERVED' => Token::FLAG_KEYWORD | Token::FLAG_KEYWORD_RESERVED, 'RESERVED2' => Token::FLAG_KEYWORD | Token::FLAG_KEYWORD_RESERVED,