diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 9febb185..75375844 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -29,9 +29,6 @@ - - 4 - 4 diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index d87f00d9..b38f1953 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -76,17 +76,17 @@ parameters: path: src/Components/DataType.php - - message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\:\\:\\$alias \\(string\\|null\\) does not accept mixed\\.$#" - count: 3 + message: "#^Comparison operation \"\\<\" between int\\<1, max\\> and 0 is always false\\.$#" + count: 1 path: src/Components/Expression.php - - message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\:\\:\\$subquery \\(string\\|null\\) does not accept mixed\\.$#" - count: 1 + message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\:\\:\\$alias \\(string\\|null\\) does not accept mixed\\.$#" + count: 3 path: src/Components/Expression.php - - message: "#^Strict comparison using \\=\\=\\= between PhpMyAdmin\\\\SqlParser\\\\Token and null will always evaluate to false\\.$#" + message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\:\\:\\$subquery \\(string\\|null\\) does not accept mixed\\.$#" count: 1 path: src/Components/Expression.php @@ -176,7 +176,7 @@ parameters: path: src/Components/JoinKeyword.php - - message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\Key\\:\\:\\$columns \\(array\\\\) does not accept non\\-empty\\-array\\\\>\\.$#" + message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\Key\\:\\:\\$columns \\(array\\\\) does not accept non\\-empty\\-array\\\\>\\.$#" count: 1 path: src/Components/Key.php @@ -405,13 +405,18 @@ parameters: count: 4 path: src/Parser.php + - + message: "#^Instantiated class not found\\.$#" + count: 1 + path: src/Parser.php + - message: "#^Parameter \\#2 \\$list of method PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:validateClauseOrder\\(\\) expects PhpMyAdmin\\\\SqlParser\\\\TokensList, PhpMyAdmin\\\\SqlParser\\\\TokensList\\|null given\\.$#" - count: 3 + count: 2 path: src/Parser.php - - message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\SelectStatement\\:\\:\\$union \\(array\\\\) does not accept array\\\\|PhpMyAdmin\\\\SqlParser\\\\Statements\\\\SelectStatement\\>\\.$#" + message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\SelectStatement\\:\\:\\$union \\(array\\\\) does not accept array\\\\|PhpMyAdmin\\\\SqlParser\\\\Statements\\\\SelectStatement\\>\\.$#" count: 1 path: src/Parser.php @@ -421,7 +426,112 @@ parameters: path: src/Parser.php - - message: "#^Call to an undefined static method PhpMyAdmin\\\\SqlParser\\\\Component\\:\\:buildAll\\(\\)\\.$#" + message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$call\\.$#" + count: 1 + path: src/Statement.php + + - + message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$endOptions\\.$#" + count: 1 + path: src/Statement.php + + - + message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$expr\\.$#" + count: 1 + path: src/Statement.php + + - + message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$fields\\.$#" + count: 1 + path: src/Statement.php + + - + message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$from\\.$#" + count: 1 + path: src/Statement.php + + - + message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$group\\.$#" + count: 1 + path: src/Statement.php + + - + message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$groupOptions\\.$#" + count: 1 + path: src/Statement.php + + - + message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$having\\.$#" + count: 1 + path: src/Statement.php + + - + message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$index_hints\\.$#" + count: 1 + path: src/Statement.php + + - + message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$into\\.$#" + count: 1 + path: src/Statement.php + + - + message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$join\\.$#" + count: 1 + path: src/Statement.php + + - + message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$limit\\.$#" + count: 1 + path: src/Statement.php + + - + message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$order\\.$#" + count: 1 + path: src/Statement.php + + - + message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$partition\\.$#" + count: 1 + path: src/Statement.php + + - + message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$procedure\\.$#" + count: 1 + path: src/Statement.php + + - + message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$renames\\.$#" + count: 1 + path: src/Statement.php + + - + message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$set\\.$#" + count: 1 + path: src/Statement.php + + - + message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$table\\.$#" + count: 1 + path: src/Statement.php + + - + message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$tables\\.$#" + count: 1 + path: src/Statement.php + + - + message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$union\\.$#" + count: 1 + path: src/Statement.php + + - + message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$values\\.$#" + count: 1 + path: src/Statement.php + + - + message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$where\\.$#" count: 1 path: src/Statement.php @@ -435,6 +545,11 @@ parameters: count: 1 path: src/Statement.php + - + message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$options \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\|null\\) does not accept mixed\\.$#" + count: 1 + path: src/Statement.php + - message: "#^Argument of an invalid type array\\\\|null supplied for foreach, only iterables are supported\\.$#" count: 1 @@ -570,6 +685,11 @@ parameters: count: 1 path: src/Statements/LoadStatement.php + - + message: "#^Comparison operation \"\\>\\=\" between int\\<3, max\\> and 3 is always true\\.$#" + count: 1 + path: src/Statements/LoadStatement.php + - message: "#^Parameter \\#3 \\$keyword of method PhpMyAdmin\\\\SqlParser\\\\Statements\\\\LoadStatement\\:\\:parseFileOptions\\(\\) expects string, mixed given\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 1443d46f..18d31720 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -11,6 +11,15 @@ ['type' => PartitionDefinition::class], )]]> + + $partitionState === 2 + $state === 3 + + + + + $state === 1 + @@ -78,6 +87,9 @@ options]]> + + $state === 5 + @@ -88,11 +100,11 @@ $name $options + + $state === 1 + - - $prev[0] === null - keyword]]]> keyword]]]> @@ -113,10 +125,9 @@ expr]]> expr]]> - - $prev[1] !== null - function) && ($prev[1] !== null)]]> - + + + @@ -130,9 +141,9 @@ $expr $expr - - buildAll - + + $state === 1 + @@ -145,6 +156,9 @@ name]]> parameters]]> + + $state === 1 + @@ -154,6 +168,9 @@ $type + + $state === 1 + @@ -163,9 +180,6 @@ indexOrKey]]> type]]> - - buildAll - @@ -203,11 +217,9 @@ $using 'table'])]]> - - $state - $state - $state - + + $state === 4 + @@ -216,6 +228,9 @@ name]]> type]]> + + columns]]> + expr]]> options]]> @@ -226,9 +241,9 @@ $name $type - - columns]]> - + + $state === 5 + @@ -332,6 +347,9 @@ $expr Expression::parse($parser, $list) + + $state === 1 + @@ -343,6 +361,9 @@ $type DataType::parse($parser, $list) + + $state === 3 + name)]]> @@ -380,6 +401,9 @@ ['type' => self::class], )]]> + + $state === 6 + $idx @@ -400,6 +424,9 @@ ], )]]> + + $state === 2 + @@ -422,20 +449,19 @@ ], )]]> + + $state === 3 + expr]]> + $state === 1 value === ',']]> - - - buildAll - - [] @@ -624,17 +650,53 @@ keyword]]]> keyword]]]> + + validateClauseOrder + + + $list + $list + token]]> + + + tokens[$list->idx]]]> + tokens]]> + self::STATEMENT_PARSERS idx]]> idx]]> $prevLastIdx + + $list + $list + $lastIdx + + count]]> + idx]]> + tokens]]> + keyword]]> + token]]> + type]]> + value]]> + + + getNextOfType + getNextOfType + getNextOfType + + + statements]]> + statements]]> + statements]]> + statements]]> + list]]> @@ -644,6 +706,19 @@ $built[$field] value]]]> + + $field]]> + $field]]> + $field]]> + $field]]> + $field]]> + $field]]> + $field]]> + $field]]> + $field]]> + $field]]> + $field]]> + value]]]> value]]]> @@ -674,6 +749,10 @@ $field)]]> + $field)]]> + $field)]]> + $field)]]> + $field)]]> $index @@ -697,6 +776,9 @@ build build + + $state === 1 + @@ -723,10 +805,10 @@ $field]]> - + $brackets $brackets - + parameters]]> @@ -806,6 +888,9 @@ $statementAlias + + $state === 3 + @@ -820,6 +905,9 @@ value]]> + + $state + ArrayObj::parse($parser, $list) @@ -835,6 +923,17 @@ token]]> type]]> + + $state === 1 + + + $state === 2 + + + + + $state === 2 + @@ -930,6 +1029,9 @@ withers]]> withers]]> + + $state === 5 + @@ -976,6 +1078,101 @@ + + $i + $i + delimiterLen]]> + $i - $iBak + $iBak + query[$i + 2]]]> + query[$i + 9]]]> + query[$i]]]> + query[$i]]]> + query[$i]]]> + + + query[$i + 1]]]> + query[$i + 1]]]> + query[$i + 1]]]> + query[$i + 1]]]> + query[$i + 2]]]> + query[$i + 2]]]> + query[$i + 2]]]> + query[$i + 2]]]> + query[$i + 3]]]> + query[$i + 3]]]> + query[$i + 4]]]> + query[$i + 4]]]> + query[$i + 5]]]> + query[$i + 5]]]> + query[$i + 6]]]> + query[$i + 6]]]> + query[$i + 7]]]> + query[$i + 7]]]> + query[$i + 8]]]> + query[$i + 8]]]> + query[$i + 9]]]> + query[$i - 1]]]> + query[$i++]]]> + query[$i]]]> + query[$i]]]> + query[$i]]]> + query[$i]]]> + query[$i]]]> + query[$i]]]> + query[$i]]]> + query[$i]]]> + query[$i]]]> + query[$i]]]> + query[$i]]]> + query[++$i]]]> + + + $i + $i + $i + $i + $i + $i + $iBak + + + $i + $i + $i + $i + $i + $i + $i + $i + $i + $i + $i + $i + $i + $i + $i + $i + $i + $i + $i + $i + $i + $i + $i + $i + $i + $i + $i + $i + $i + $i + $i + $i + query[++$i] : '']]> + query[$i++]]]> + query[$i]]]> + status]]> @@ -1084,10 +1281,15 @@ int + $clauses[$clauseType] keyword]]]> keyword]]]> + + $clauses[$clauseType] + + $clauseType $expr $expressions[] $rename diff --git a/src/Components/AlterOperation.php b/src/Components/AlterOperation.php index 95575d73..b540550e 100644 --- a/src/Components/AlterOperation.php +++ b/src/Components/AlterOperation.php @@ -286,8 +286,6 @@ public static function parse(Parser $parser, TokensList $list, array $options = /** * Counts brackets. - * - * @var int */ $brackets = 0; @@ -303,15 +301,11 @@ public static function parse(Parser $parser, TokensList $list, array $options = * 1 -------------[ PARTITION / PARTITION BY ]------------> 3 * * 2 -------------------------[ , ]-----------------------> 0 - * - * @var int */ $state = 0; /** * partition state. - * - * @var int */ $partitionState = 0; diff --git a/src/Components/Array2d.php b/src/Components/Array2d.php index 90a402d2..f73e267e 100644 --- a/src/Components/Array2d.php +++ b/src/Components/Array2d.php @@ -33,8 +33,6 @@ public static function parse(Parser $parser, TokensList $list, array $options = /** * The number of values in each set. - * - * @var int */ $count = -1; @@ -47,8 +45,6 @@ public static function parse(Parser $parser, TokensList $list, array $options = * * 1 ------------------------[ , ]------------------------> 0 * 1 -----------------------[ else ]----------------------> (END) - * - * @var int */ $state = 0; diff --git a/src/Components/ArrayObj.php b/src/Components/ArrayObj.php index a4263258..8ed4decb 100644 --- a/src/Components/ArrayObj.php +++ b/src/Components/ArrayObj.php @@ -55,29 +55,21 @@ public static function parse(Parser $parser, TokensList $list, array $options = /** * The last raw expression. - * - * @var string */ $lastRaw = ''; /** * The last value. - * - * @var string */ $lastValue = ''; /** * Counts brackets. - * - * @var int */ $brackets = 0; /** * Last separator (bracket or comma). - * - * @var bool */ $isCommaLast = false; diff --git a/src/Components/CaseExpression.php b/src/Components/CaseExpression.php index d29d5b9f..68a01a9c 100644 --- a/src/Components/CaseExpression.php +++ b/src/Components/CaseExpression.php @@ -78,15 +78,11 @@ public static function parse(Parser $parser, TokensList $list, array $options = /** * State of parser. - * - * @var int */ $state = 0; /** * Syntax type (type 0 or type 1). - * - * @var int */ $type = 0; diff --git a/src/Components/Condition.php b/src/Components/Condition.php index 0bc14aaf..cdb45598 100644 --- a/src/Components/Condition.php +++ b/src/Components/Condition.php @@ -98,8 +98,6 @@ public static function parse(Parser $parser, TokensList $list, array $options = /** * Counts brackets. - * - * @var int */ $brackets = 0; @@ -109,8 +107,6 @@ public static function parse(Parser $parser, TokensList $list, array $options = * It is required to keep track of them because their structure contains * the keyword `AND`, which is also an operator that delimits * expressions. - * - * @var bool */ $betweenBefore = false; diff --git a/src/Components/CreateDefinition.php b/src/Components/CreateDefinition.php index edaee1e7..7dfcdfe3 100644 --- a/src/Components/CreateDefinition.php +++ b/src/Components/CreateDefinition.php @@ -199,8 +199,6 @@ public static function parse(Parser $parser, TokensList $list, array $options = * * 5 ------------------------[ , ]-----------------------> 1 * 5 ------------------------[ ) ]-----------------------> 6 (-1) - * - * @var int */ $state = 0; diff --git a/src/Components/DataType.php b/src/Components/DataType.php index 9968643d..4aecb8ac 100644 --- a/src/Components/DataType.php +++ b/src/Components/DataType.php @@ -104,8 +104,6 @@ public static function parse(Parser $parser, TokensList $list, array $options = * 0 -------------------[ data type ]--------------------> 1 * * 1 ----------------[ size and options ]----------------> 2 - * - * @var int */ $state = 0; diff --git a/src/Components/Expression.php b/src/Components/Expression.php index 8d62a1fc..aafd18db 100644 --- a/src/Components/Expression.php +++ b/src/Components/Expression.php @@ -166,36 +166,26 @@ public static function parse(Parser $parser, TokensList $list, array $options = /** * Whether current tokens make an expression or a table reference. - * - * @var bool */ $isExpr = false; /** * Whether a period was previously found. - * - * @var bool */ $dot = false; /** * Whether an alias is expected. Is 2 if `AS` keyword was found. - * - * @var bool */ $alias = false; /** * Counts brackets. - * - * @var int */ $brackets = 0; /** * Keeps track of the last two previous tokens. - * - * @var Token[] */ $prev = [ null, diff --git a/src/Components/ExpressionArray.php b/src/Components/ExpressionArray.php index 2c24a501..dd95a508 100644 --- a/src/Components/ExpressionArray.php +++ b/src/Components/ExpressionArray.php @@ -46,8 +46,6 @@ public static function parse(Parser $parser, TokensList $list, array $options = * * 1 ------------------------[ , ]------------------------> 0 * 1 -----------------------[ else ]----------------------> (END) - * - * @var int */ $state = 0; diff --git a/src/Components/FunctionCall.php b/src/Components/FunctionCall.php index eed47e93..0f307b2a 100644 --- a/src/Components/FunctionCall.php +++ b/src/Components/FunctionCall.php @@ -61,8 +61,6 @@ public static function parse(Parser $parser, TokensList $list, array $options = * 0 ----------------------[ name ]-----------------------> 1 * * 1 --------------------[ parameters ]-------------------> (END) - * - * @var int */ $state = 0; diff --git a/src/Components/GroupKeyword.php b/src/Components/GroupKeyword.php index 38855df8..403e8d05 100644 --- a/src/Components/GroupKeyword.php +++ b/src/Components/GroupKeyword.php @@ -55,8 +55,6 @@ public static function parse(Parser $parser, TokensList $list, array $options = * * 1 ------------------------[ , ]------------------------> 0 * 1 -------------------[ ASC / DESC ]--------------------> 1 - * - * @var int */ $state = 0; diff --git a/src/Components/IndexHint.php b/src/Components/IndexHint.php index ce44248c..ec32ede3 100644 --- a/src/Components/IndexHint.php +++ b/src/Components/IndexHint.php @@ -78,8 +78,6 @@ public static function parse(Parser $parser, TokensList $list, array $options = * 2 -------------------- [ expr_list ] --------------------> 0 * 3 -------------- [ JOIN/GROUP BY/ORDER BY ] -------------> 4 * 4 -------------------- [ expr_list ] --------------------> 0 - * - * @var int */ $state = 0; diff --git a/src/Components/IntoKeyword.php b/src/Components/IntoKeyword.php index 5ecd30b4..67a467c3 100644 --- a/src/Components/IntoKeyword.php +++ b/src/Components/IntoKeyword.php @@ -148,8 +148,6 @@ public static function parse(Parser $parser, TokensList $list, array $options = * 1 ------------------------[ ( ]------------------------> (END) * * 2 ---------------------[ filename ]--------------------> 1 - * - * @var int */ $state = 0; diff --git a/src/Components/JoinKeyword.php b/src/Components/JoinKeyword.php index b975c90a..cf87998c 100644 --- a/src/Components/JoinKeyword.php +++ b/src/Components/JoinKeyword.php @@ -118,8 +118,6 @@ public static function parse(Parser $parser, TokensList $list, array $options = * 3 --------------------[ conditions ]-------------------> 0 * * 4 ----------------------[ columns ]--------------------> 0 - * - * @var int */ $state = 0; diff --git a/src/Components/Key.php b/src/Components/Key.php index d041bd6e..d6785b36 100644 --- a/src/Components/Key.php +++ b/src/Components/Key.php @@ -127,8 +127,6 @@ public static function parse(Parser $parser, TokensList $list, array $options = /** * Last parsed column. - * - * @var array */ $lastColumn = []; @@ -147,8 +145,6 @@ public static function parse(Parser $parser, TokensList $list, array $options = * 3 ---------------------[ column length ]------------------> 2 * 2 ---------------------[ options ]------------------------> 4 * 5 ---------------------[ expression ]---------------------> 4 - * - * @var int */ $state = 0; diff --git a/src/Components/LockExpression.php b/src/Components/LockExpression.php index 3ef6f7c8..bc293d01 100644 --- a/src/Components/LockExpression.php +++ b/src/Components/LockExpression.php @@ -47,8 +47,6 @@ public static function parse(Parser $parser, TokensList $list, array $options = * 0 ---------------- [ tbl_name ] -----------------> 1 * 1 ---------------- [ lock_type ] ----------------> 2 * 2 -------------------- [ , ] --------------------> break - * - * @var int */ $state = 0; @@ -116,8 +114,6 @@ private static function parseLockType(Parser $parser, TokensList $list): string * 0 ---------------- [ WRITE ] ----------------> 3 * 1 ---------------- [ LOCAL ] ----------------> 3 * 2 ---------------- [ WRITE ] ----------------> 3 - * - * @var int */ $state = 0; diff --git a/src/Components/OptionsArray.php b/src/Components/OptionsArray.php index 2350b596..bd7fab74 100644 --- a/src/Components/OptionsArray.php +++ b/src/Components/OptionsArray.php @@ -44,8 +44,6 @@ public static function parse(Parser $parser, TokensList $list, array $options = /** * The ID that will be assigned to duplicate options. - * - * @var int */ $lastAssignedId = count($options) + 1; @@ -56,15 +54,11 @@ public static function parse(Parser $parser, TokensList $list, array $options = /** * The index of the option that was processed last time. - * - * @var int */ $lastOptionId = 0; /** * Counts brackets. - * - * @var int */ $brackets = 0; @@ -78,8 +72,6 @@ public static function parse(Parser $parser, TokensList $list, array $options = * 1 -------------------[ = (optional) ]------------------> 2 * * 2 ----------------------[ value ]----------------------> 0 - * - * @var int */ $state = 0; diff --git a/src/Components/OrderKeyword.php b/src/Components/OrderKeyword.php index 05ad2d41..7ec76356 100644 --- a/src/Components/OrderKeyword.php +++ b/src/Components/OrderKeyword.php @@ -62,8 +62,6 @@ public static function parse(Parser $parser, TokensList $list, array $options = * * 1 ------------------------[ , ]------------------------> 0 * 1 -------------------[ ASC / DESC ]--------------------> 1 - * - * @var int */ $state = 0; diff --git a/src/Components/ParameterDefinition.php b/src/Components/ParameterDefinition.php index d1696a52..a9069dd2 100644 --- a/src/Components/ParameterDefinition.php +++ b/src/Components/ParameterDefinition.php @@ -78,8 +78,6 @@ public static function parse(Parser $parser, TokensList $list, array $options = * * 3 ------------------------[ , ]-----------------------> 1 * 3 ------------------------[ ) ]-----------------------> (END) - * - * @var int */ $state = 0; diff --git a/src/Components/PartitionDefinition.php b/src/Components/PartitionDefinition.php index be373f25..de4e926f 100644 --- a/src/Components/PartitionDefinition.php +++ b/src/Components/PartitionDefinition.php @@ -134,8 +134,6 @@ public static function parse(Parser $parser, TokensList $list, array $options = * 5 ----------------------[ options ]--------------------> 6 * * 6 ------------------[ subpartitions ]------------------> (END) - * - * @var int */ $state = 0; diff --git a/src/Components/Reference.php b/src/Components/Reference.php index f13573bc..cc94c9e6 100644 --- a/src/Components/Reference.php +++ b/src/Components/Reference.php @@ -88,8 +88,6 @@ public static function parse(Parser $parser, TokensList $list, array $options = * 1 ---------------------[ columns ]--------------------> 2 * * 2 ---------------------[ options ]--------------------> (END) - * - * @var int */ $state = 0; diff --git a/src/Components/RenameOperation.php b/src/Components/RenameOperation.php index c1dace45..49e6ced9 100644 --- a/src/Components/RenameOperation.php +++ b/src/Components/RenameOperation.php @@ -66,8 +66,6 @@ public static function parse(Parser $parser, TokensList $list, array $options = * * 3 ------------------------[ , ]------------------------> 0 * 3 -----------------------[ else ]----------------------> (END) - * - * @var int */ $state = 0; diff --git a/src/Components/SetOperation.php b/src/Components/SetOperation.php index 2d695d93..2379e116 100644 --- a/src/Components/SetOperation.php +++ b/src/Components/SetOperation.php @@ -65,15 +65,11 @@ public static function parse(Parser $parser, TokensList $list, array $options = * 0 ---------------------[ = or := ]---------------------> 1 * 1 -----------------------[ value ]---------------------> 1 * 1 ------------------------[ , ]------------------------> 0 - * - * @var int */ $state = 0; /** * Token when the parser has seen the latest comma - * - * @var Token */ $commaLastSeenAt = null; diff --git a/src/Lexer.php b/src/Lexer.php index ab033a57..9c9695ac 100644 --- a/src/Lexer.php +++ b/src/Lexer.php @@ -394,8 +394,6 @@ public function parseKeyword(): Token|null /** * Value to be returned. - * - * @var Token */ $ret = null; @@ -406,8 +404,6 @@ public function parseKeyword(): Token|null /** * Whether last parsed character is a whitespace. - * - * @var bool */ $lastSpace = false; @@ -454,8 +450,6 @@ public function parseLabel(): Token|null /** * Value to be returned. - * - * @var Token */ $ret = null; @@ -498,8 +492,6 @@ public function parseOperator(): Token|null /** * Value to be returned. - * - * @var Token */ $ret = null; diff --git a/src/Parser.php b/src/Parser.php index 7709214f..7212a581 100644 --- a/src/Parser.php +++ b/src/Parser.php @@ -404,29 +404,21 @@ public function parse(): void { /** * Last transaction. - * - * @var TransactionStatement */ $lastTransaction = null; /** * Last parsed statement. - * - * @var Statement */ $lastStatement = null; /** * Union's type or false for no union. - * - * @var bool|string */ $unionType = false; /** * The index of the last token from the last statement. - * - * @var int */ $prevLastIdx = -1; @@ -518,15 +510,11 @@ public function parse(): void /** * The name of the class that is used for parsing. - * - * @var string */ $class = self::STATEMENT_PARSERS[$statementName ?? $token->keyword]; /** * Processed statement. - * - * @var Statement */ $statement = new $class($this, $this->list); diff --git a/src/Statement.php b/src/Statement.php index 7b95130d..6db9d155 100644 --- a/src/Statement.php +++ b/src/Statement.php @@ -99,8 +99,6 @@ public function build(): string { /** * Query to be returned. - * - * @var string */ $query = ''; @@ -124,8 +122,6 @@ public function build(): string foreach ($clauses as $clause) { /** * The name of the clause. - * - * @var string */ $name = $clause[0]; @@ -133,23 +129,17 @@ public function build(): string * The type of the clause. * * @see Statement::$clauses - * - * @var int */ $type = $clause[1]; /** * The builder (parser) of this clause. - * - * @var Component */ $class = Parser::KEYWORD_PARSERS[$name]['class']; /** * The name of the field that is used as source for the builder. * Same field is used to store the result of parsing. - * - * @var string */ $field = Parser::KEYWORD_PARSERS[$name]['field']; @@ -281,15 +271,11 @@ public function parse(Parser $parser, TokensList $list): void /** * The name of the class that is used for parsing. - * - * @var Component|null */ $class = null; /** * The name of the field where the result of the parsing is stored. - * - * @var string */ $field = null; @@ -474,8 +460,6 @@ public function validateClauseOrder(Parser $parser, TokensList $list): bool * For tracking JOIN clauses in a query * = 0 - JOIN not found till now * > 0 - Index of first JOIN clause in the statement. - * - * @var int */ $minJoin = 0; @@ -485,8 +469,6 @@ public function validateClauseOrder(Parser $parser, TokensList $list): bool * > 0 - Index of last JOIN clause * (which appears together with other JOINs) * in the statement. - * - * @var int */ $maxJoin = 0; diff --git a/src/Statements/AlterStatement.php b/src/Statements/AlterStatement.php index e925158b..9ec043f1 100644 --- a/src/Statements/AlterStatement.php +++ b/src/Statements/AlterStatement.php @@ -94,8 +94,6 @@ public function parse(Parser $parser, TokensList $list): void * 0 -----------------[ alter operation ]-----------------> 1 * * 1 -------------------------[ , ]-----------------------> 0 - * - * @var int */ $state = 0; diff --git a/src/Statements/CreateStatement.php b/src/Statements/CreateStatement.php index 33662bb3..3ecc5524 100644 --- a/src/Statements/CreateStatement.php +++ b/src/Statements/CreateStatement.php @@ -580,8 +580,6 @@ public function parse(Parser $parser, TokensList $list): void /** * The field that is being filled (`partitionBy` or * `subpartitionBy`). - * - * @var string */ $field = null; @@ -589,8 +587,6 @@ public function parse(Parser $parser, TokensList $list): void * The number of brackets. `false` means no bracket was found * previously. At least one bracket is required to validate the * expression. - * - * @var int|bool */ $brackets = false; diff --git a/src/Statements/DeleteStatement.php b/src/Statements/DeleteStatement.php index e06cbcfb..9cc99555 100644 --- a/src/Statements/DeleteStatement.php +++ b/src/Statements/DeleteStatement.php @@ -212,15 +212,11 @@ public function parse(Parser $parser, TokensList $list): void * 2 --------------------------------[ WHERE ]----------------------------------> 4 * 2 --------------------------------[ ORDER ]----------------------------------> 5 * 2 --------------------------------[ LIMIT ]----------------------------------> 6 - * - * @var int */ $state = 0; /** * If the query is multi-table or not. - * - * @var bool */ $multiTable = false; diff --git a/src/Statements/ExplainStatement.php b/src/Statements/ExplainStatement.php index 82308419..6e8c69d9 100644 --- a/src/Statements/ExplainStatement.php +++ b/src/Statements/ExplainStatement.php @@ -84,8 +84,6 @@ public function parse(Parser $parser, TokensList $list): void * 2 --------------[ tablename / STATEMENT / FOR CONNECTION ]---------------------> 2 * * 3 -----------------------------[ tablename ]-----------------------------------> 3 - * - * @var int */ $state = 0; diff --git a/src/Statements/InsertStatement.php b/src/Statements/InsertStatement.php index 2b5988a2..99818bc5 100644 --- a/src/Statements/InsertStatement.php +++ b/src/Statements/InsertStatement.php @@ -147,8 +147,6 @@ public function parse(Parser $parser, TokensList $list): void * 1 -------------------------[ VALUES/VALUE/SET/SELECT ]-----------------------> 2 * * 2 -------------------------[ ON DUPLICATE KEY UPDATE ]-----------------------> 3 - * - * @var int */ $state = 0; diff --git a/src/Statements/LoadStatement.php b/src/Statements/LoadStatement.php index ecf15601..3c3554f3 100644 --- a/src/Statements/LoadStatement.php +++ b/src/Statements/LoadStatement.php @@ -209,8 +209,6 @@ public function parse(Parser $parser, TokensList $list): void /** * The state of the parser. - * - * @var int */ $state = 0; diff --git a/src/Statements/LockStatement.php b/src/Statements/LockStatement.php index eb55b5c1..85272368 100644 --- a/src/Statements/LockStatement.php +++ b/src/Statements/LockStatement.php @@ -51,8 +51,6 @@ public function parse(Parser $parser, TokensList $list): void * 0 ---------------- [ TABLES ] -----------------> 1 * 1 -------------- [ lock_expr ] ----------------> 2 * 2 ------------------ [ , ] --------------------> 1 - * - * @var int */ $state = 0; diff --git a/src/Statements/PurgeStatement.php b/src/Statements/PurgeStatement.php index 67800b5e..4e52c616 100644 --- a/src/Statements/PurgeStatement.php +++ b/src/Statements/PurgeStatement.php @@ -55,8 +55,6 @@ public function parse(Parser $parser, TokensList $list): void /** * The state of the parser. - * - * @var int */ $state = 0; diff --git a/src/Statements/ReplaceStatement.php b/src/Statements/ReplaceStatement.php index e0d1dbcf..c3a74b1e 100644 --- a/src/Statements/ReplaceStatement.php +++ b/src/Statements/ReplaceStatement.php @@ -114,8 +114,6 @@ public function parse(Parser $parser, TokensList $list): void * 0 ---------------------------------[ INTO ]----------------------------------> 1 * * 1 -------------------------[ VALUES/VALUE/SET/SELECT ]-----------------------> 2 - * - * @var int */ $state = 0; diff --git a/src/Statements/WithStatement.php b/src/Statements/WithStatement.php index f5210f7f..6aee3de3 100644 --- a/src/Statements/WithStatement.php +++ b/src/Statements/WithStatement.php @@ -86,8 +86,6 @@ public function parse(Parser $parser, TokensList $list): void * 4 ------------------ [ , ] ------------------> 1 * * 4 ----- [ SELECT/UPDATE/DELETE/INSERT ] -----> 5 - * - * @var int */ $state = 0; $wither = null; diff --git a/src/Tools/TestGenerator.php b/src/Tools/TestGenerator.php index ef0c5abb..a6484f92 100644 --- a/src/Tools/TestGenerator.php +++ b/src/Tools/TestGenerator.php @@ -58,22 +58,16 @@ public static function generate(string $query, string $type = 'parser'): array /** * Parsed used for analyzing the query. * A new instance of parser is generated only if the test requires. - * - * @var Parser */ $parser = $type === 'parser' ? new Parser($lexer->list) : null; /** * Lexer's errors. - * - * @var array> */ $lexerErrors = []; /** * Parser's errors. - * - * @var array> */ $parserErrors = []; @@ -147,8 +141,6 @@ public static function build( /** * The query that is used to generate the test. - * - * @var string */ $query = file_get_contents($input); diff --git a/src/Utils/BufferedQuery.php b/src/Utils/BufferedQuery.php index f8265103..7d91677b 100644 --- a/src/Utils/BufferedQuery.php +++ b/src/Utils/BufferedQuery.php @@ -117,8 +117,6 @@ public function extract(bool $end = false): string|false * This is statically defined because it is not used outside anywhere * outside this method and there is probably a (minor) performance * improvement to it. - * - * @var int */ static $i = 0; @@ -128,8 +126,6 @@ public function extract(bool $end = false): string|false /** * The length of the buffer. - * - * @var int */ $len = strlen($this->query); diff --git a/src/Utils/Formatter.php b/src/Utils/Formatter.php index a0609f15..fc8837b2 100644 --- a/src/Utils/Formatter.php +++ b/src/Utils/Formatter.php @@ -328,36 +328,26 @@ public function formatList(TokensList $list): string { /** * The query to be returned. - * - * @var string */ $ret = ''; /** * The indentation level. - * - * @var int */ $indent = 0; /** * Whether the line ended. - * - * @var bool */ $lineEnded = false; /** * Whether current group is short (no linebreaks). - * - * @var bool */ $shortGroup = false; /** * The name of the last clause. - * - * @var string */ $lastClause = ''; @@ -375,15 +365,11 @@ public function formatList(TokensList $list): string /** * Whether clause's options were formatted. - * - * @var bool */ $formattedOptions = false; /** * Previously parsed token. - * - * @var Token|null */ $prev = null; @@ -717,15 +703,11 @@ public static function getGroupLength(TokensList $list): int * This counter starts at one because by the time this function called, * the list already advanced one position and the opening bracket was * already parsed. - * - * @var int */ $count = 1; /** * The length of this group. - * - * @var int */ $length = 0; diff --git a/src/Utils/Query.php b/src/Utils/Query.php index f12ca039..0edbe002 100644 --- a/src/Utils/Query.php +++ b/src/Utils/Query.php @@ -620,23 +620,17 @@ public static function getClause( ): string { /** * The index of the current clause. - * - * @var int */ $currIdx = 0; /** * The count of brackets. * We keep track of them so we won't insert the clause in a subquery. - * - * @var int */ $brackets = 0; /** * The string to be returned. - * - * @var string */ $ret = ''; @@ -652,8 +646,6 @@ public static function getClause( /** * The type of this clause. - * - * @var string */ $clauseType = $lexer->list->getNextOfType(TokenType::Keyword)->keyword; @@ -787,8 +779,6 @@ public static function replaceClauses(Statement $statement, TokensList $list, ar /** * Value to be returned. - * - * @var string */ $ret = ''; @@ -833,15 +823,11 @@ public static function getFirstStatement(string $query, string|null $delimiter = /** * Whether a full statement was found. - * - * @var bool */ $fullStatement = false; /** * The first full statement. - * - * @var string */ $statement = ''; @@ -897,8 +883,6 @@ public static function getClauseStartOffset(Statement $statement, TokensList $li /** * The count of brackets. * We keep track of them so we won't insert the clause in a subquery. - * - * @var int */ $brackets = 0;