Skip to content

Commit

Permalink
Make constants const
Browse files Browse the repository at this point in the history
Signed-off-by: Kamil Tekiela <[email protected]>
  • Loading branch information
kamil-tekiela committed Sep 6, 2023
1 parent b737500 commit e76fcc2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 22 deletions.
19 changes: 6 additions & 13 deletions src/Lexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ class Lexer extends Core
{
/**
* A list of methods that are used in lexing the SQL query.
*
* @var string[]
*/
public static $parserMethods = [
private const PARSER_METHODS = [
// It is best to put the parsers in order of their complexity
// (ascending) and their occurrence rate (descending).
//
Expand Down Expand Up @@ -70,14 +68,11 @@ class Lexer extends Core
'parseUnknown',
];


/**
* A list of keywords that indicate that the function keyword
* is not used as a function
*
* @var string[]
*/
public $keywordNameIndicators = [
private const KEYWORD_NAME_INDICATORS = [
'FROM',
'SET',
'WHERE',
Expand All @@ -86,10 +81,8 @@ class Lexer extends Core
/**
* A list of operators that indicate that the function keyword
* is not used as a function
*
* @var string[]
*/
public $operatorNameIndicators = [
private const OPERATOR_NAME_INDICATORS = [
',',
'.',
];
Expand Down Expand Up @@ -238,7 +231,7 @@ public function lex(): void
*/
$token = null;

foreach (static::$parserMethods as $method) {
foreach (self::PARSER_METHODS as $method) {
$token = $this->$method();

if ($token) {
Expand Down Expand Up @@ -413,10 +406,10 @@ private function solveAmbiguityOnFunctionKeywords(): void
$next = $this->list->getNext();
if (
($next->type !== Token::TYPE_KEYWORD
|| ! in_array($next->value, $this->keywordNameIndicators, true)
|| ! in_array($next->value, self::KEYWORD_NAME_INDICATORS, true)
)
&& ($next->type !== Token::TYPE_OPERATOR
|| ! in_array($next->value, $this->operatorNameIndicators, true)
|| ! in_array($next->value, self::OPERATOR_NAME_INDICATORS, true)
)
&& ($next->value !== null)
) {
Expand Down
7 changes: 2 additions & 5 deletions src/Statements/ExplainStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ class ExplainStatement extends Statement
{
/**
* Options for `EXPLAIN` statements.
*
* @var array<string, int|array<int, int|string>>
* @psalm-var array<string, (positive-int|array{positive-int, ('var'|'var='|'expr'|'expr=')})>
*/
public static $OPTIONS = [
private const OPTIONS = [

'EXTENDED' => 1,
'PARTITIONS' => 1,
Expand Down Expand Up @@ -166,7 +163,7 @@ public function parse(Parser $parser, TokensList $list): void
}
} elseif ($state === 1) {
// Parsing options.
$this->options = OptionsArray::parse($parser, $list, static::$OPTIONS);
$this->options = OptionsArray::parse($parser, $list, self::OPTIONS);
$state = 2;
} elseif ($state === 2) {
$currIdx = $list->idx;
Expand Down
4 changes: 0 additions & 4 deletions src/Tools/CustomJsonSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ class CustomJsonSerializer extends JsonSerializer
'statementEndOptions',
'keywordParsers',
'statementParsers',
'keywordNameIndicators',// Not static
'operatorNameIndicators',// Not static
'defaultDelimiter',
'parserMethods',
'OPTIONS',
'clauses',
'databaseOptions',
'delimiters',
Expand Down

0 comments on commit e76fcc2

Please sign in to comment.