diff options
Diffstat (limited to 'src/Statements')
27 files changed, 400 insertions, 510 deletions
diff --git a/src/Statements/AlterStatement.php b/src/Statements/AlterStatement.php index ce0c824..a03b2fc 100644 --- a/src/Statements/AlterStatement.php +++ b/src/Statements/AlterStatement.php @@ -1,8 +1,8 @@ <?php - /** * `ALTER` statement. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Statements; @@ -16,10 +16,6 @@ use PhpMyAdmin\SqlParser\TokensList; /** * `ALTER` statement. - * - * @category Statements - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class AlterStatement extends Statement { @@ -35,14 +31,14 @@ class AlterStatement extends Statement * * @var AlterOperation[] */ - public $altered = array(); + public $altered = []; /** * Options of this statement. * * @var array */ - public static $OPTIONS = array( + public static $OPTIONS = [ 'ONLINE' => 1, 'OFFLINE' => 1, 'IGNORE' => 2, @@ -54,8 +50,8 @@ class AlterStatement extends Statement 'SERVER' => 3, 'TABLE' => 3, 'TABLESPACE' => 3, - 'VIEW' => 3 - ); + 'VIEW' => 3, + ]; /** * @param Parser $parser the instance that requests parsing @@ -75,10 +71,10 @@ class AlterStatement extends Statement $this->table = Expression::parse( $parser, $list, - array( + [ 'parseField' => 'table', - 'breakOnAlias' => true - ) + 'breakOnAlias' => true, + ] ); ++$list->idx; // Skipping field. @@ -114,7 +110,7 @@ class AlterStatement extends Statement } if ($state === 0) { - $options = array(); + $options = []; if ($this->options->has('DATABASE')) { $options = AlterOperation::$DB_OPTIONS; } elseif ($this->options->has('TABLE')) { @@ -138,7 +134,7 @@ class AlterStatement extends Statement */ public function build() { - $tmp = array(); + $tmp = []; foreach ($this->altered as $altered) { $tmp[] = $altered::build($altered); } diff --git a/src/Statements/AnalyzeStatement.php b/src/Statements/AnalyzeStatement.php index 4f6ea32..b14b891 100644 --- a/src/Statements/AnalyzeStatement.php +++ b/src/Statements/AnalyzeStatement.php @@ -1,8 +1,8 @@ <?php - /** * `ANALYZE` statement. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Statements; @@ -12,12 +12,8 @@ use PhpMyAdmin\SqlParser\Statement; /** * `ANALYZE` statement. * - * ANALYZE array(NO_WRITE_TO_BINLOG | LOCAL] TABLE - * tbl_name array(, tbl_name] ... - * - * @category Statements - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ + * ANALYZE [NO_WRITE_TO_BINLOG | LOCAL] TABLE + * tbl_name [, tbl_name] ... */ class AnalyzeStatement extends Statement { @@ -26,12 +22,12 @@ class AnalyzeStatement extends Statement * * @var array */ - public static $OPTIONS = array( + public static $OPTIONS = [ 'TABLE' => 1, 'NO_WRITE_TO_BINLOG' => 2, - 'LOCAL' => 3 - ); + 'LOCAL' => 3, + ]; /** * Analyzed tables. diff --git a/src/Statements/BackupStatement.php b/src/Statements/BackupStatement.php index 52f136b..3fab2de 100644 --- a/src/Statements/BackupStatement.php +++ b/src/Statements/BackupStatement.php @@ -1,19 +1,15 @@ <?php - /** * `BACKUP` statement. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Statements; /** * `BACKUP` statement. * - * BACKUP TABLE tbl_name array(, tbl_name] ... TO '/path/to/backup/directory' - * - * @category Statements - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ + * BACKUP TABLE tbl_name [, tbl_name] ... TO '/path/to/backup/directory' */ class BackupStatement extends MaintenanceStatement { @@ -22,15 +18,15 @@ class BackupStatement extends MaintenanceStatement * * @var array */ - public static $OPTIONS = array( + public static $OPTIONS = [ 'TABLE' => 1, 'NO_WRITE_TO_BINLOG' => 2, 'LOCAL' => 3, - 'TO' => array( + 'TO' => [ 4, 'var', - ) - ); + ], + ]; } diff --git a/src/Statements/CallStatement.php b/src/Statements/CallStatement.php index 00cb95c..6a3de69 100644 --- a/src/Statements/CallStatement.php +++ b/src/Statements/CallStatement.php @@ -1,8 +1,8 @@ <?php - /** * `CALL` statement. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Statements; @@ -17,10 +17,6 @@ use PhpMyAdmin\SqlParser\Statement; * or * * CALL sp_name[()] - * - * @category Statements - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class CallStatement extends Statement { @@ -38,6 +34,6 @@ class CallStatement extends Statement */ public function build() { - return "CALL " . $this->call->name . "(" . ($this->call->parameters ? implode(",", $this->call->parameters->raw) : "") . ")"; + return 'CALL ' . $this->call->name . '(' . ($this->call->parameters ? implode(',', $this->call->parameters->raw) : '') . ')'; } } diff --git a/src/Statements/CheckStatement.php b/src/Statements/CheckStatement.php index 57e5cb7..c112f0a 100644 --- a/src/Statements/CheckStatement.php +++ b/src/Statements/CheckStatement.php @@ -1,19 +1,15 @@ <?php - /** * `CHECK` statement. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Statements; /** * `CHECK` statement. * - * CHECK TABLE tbl_name array(, tbl_name] ... array(option] ... - * - * @category Statements - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ + * CHECK TABLE tbl_name [, tbl_name] ... [option] ... */ class CheckStatement extends MaintenanceStatement { @@ -22,7 +18,7 @@ class CheckStatement extends MaintenanceStatement * * @var array */ - public static $OPTIONS = array( + public static $OPTIONS = [ 'TABLE' => 1, 'FOR UPGRADE' => 2, @@ -30,6 +26,6 @@ class CheckStatement extends MaintenanceStatement 'FAST' => 4, 'MEDIUM' => 5, 'EXTENDED' => 6, - 'CHANGED' => 7 - ); + 'CHANGED' => 7, + ]; } diff --git a/src/Statements/ChecksumStatement.php b/src/Statements/ChecksumStatement.php index 1be2588..259f287 100644 --- a/src/Statements/ChecksumStatement.php +++ b/src/Statements/ChecksumStatement.php @@ -1,19 +1,15 @@ <?php - /** * `CHECKSUM` statement. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Statements; /** * `CHECKSUM` statement. * - * CHECKSUM TABLE tbl_name array(, tbl_name] ... array( QUICK | EXTENDED ] - * - * @category Statements - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ + * CHECKSUM TABLE tbl_name [, tbl_name] ... [ QUICK | EXTENDED ] */ class ChecksumStatement extends MaintenanceStatement { @@ -22,10 +18,10 @@ class ChecksumStatement extends MaintenanceStatement * * @var array */ - public static $OPTIONS = array( + public static $OPTIONS = [ 'TABLE' => 1, 'QUICK' => 2, - 'EXTENDED' => 3 - ); + 'EXTENDED' => 3, + ]; } diff --git a/src/Statements/CreateStatement.php b/src/Statements/CreateStatement.php index d3bf3bd..64ea57d 100644 --- a/src/Statements/CreateStatement.php +++ b/src/Statements/CreateStatement.php @@ -1,8 +1,8 @@ <?php - /** * `CREATE` statement. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Statements; @@ -20,10 +20,6 @@ use PhpMyAdmin\SqlParser\TokensList; /** * `CREATE` statement. - * - * @category Statements - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class CreateStatement extends Statement { @@ -32,25 +28,25 @@ class CreateStatement extends Statement * * @var array */ - public static $OPTIONS = array( + public static $OPTIONS = [ // CREATE TABLE 'TEMPORARY' => 1, // CREATE VIEW 'OR REPLACE' => 2, - 'ALGORITHM' => array( + 'ALGORITHM' => [ 3, 'var=', - ), + ], // `DEFINER` is also used for `CREATE FUNCTION / PROCEDURE` - 'DEFINER' => array( + 'DEFINER' => [ 4, 'expr=', - ), - 'SQL SECURITY' => array( + ], + 'SQL SECURITY' => [ 5, 'var', - ), + ], 'DATABASE' => 6, 'EVENT' => 6, @@ -69,159 +65,159 @@ class CreateStatement extends Statement 'SCHEMA' => 6, // CREATE TABLE - 'IF NOT EXISTS' => 7 - ); + 'IF NOT EXISTS' => 7, + ]; /** * All database options. * * @var array */ - public static $DB_OPTIONS = array( - 'CHARACTER SET' => array( + public static $DB_OPTIONS = [ + 'CHARACTER SET' => [ 1, 'var=', - ), - 'CHARSET' => array( + ], + 'CHARSET' => [ 1, 'var=', - ), - 'DEFAULT CHARACTER SET' => array( + ], + 'DEFAULT CHARACTER SET' => [ 1, 'var=', - ), - 'DEFAULT CHARSET' => array( + ], + 'DEFAULT CHARSET' => [ 1, 'var=', - ), - 'DEFAULT COLLATE' => array( + ], + 'DEFAULT COLLATE' => [ 2, 'var=', - ), - 'COLLATE' => array( + ], + 'COLLATE' => [ 2, 'var=', - ) - ); + ], + ]; /** * All table options. * * @var array */ - public static $TABLE_OPTIONS = array( - 'ENGINE' => array( + public static $TABLE_OPTIONS = [ + 'ENGINE' => [ 1, 'var=', - ), - 'AUTO_INCREMENT' => array( + ], + 'AUTO_INCREMENT' => [ 2, 'var=', - ), - 'AVG_ROW_LENGTH' => array( + ], + 'AVG_ROW_LENGTH' => [ 3, 'var', - ), - 'CHARACTER SET' => array( + ], + 'CHARACTER SET' => [ 4, 'var=', - ), - 'CHARSET' => array( + ], + 'CHARSET' => [ 4, 'var=', - ), - 'DEFAULT CHARACTER SET' => array( + ], + 'DEFAULT CHARACTER SET' => [ 4, 'var=', - ), - 'DEFAULT CHARSET' => array( + ], + 'DEFAULT CHARSET' => [ 4, 'var=', - ), - 'CHECKSUM' => array( + ], + 'CHECKSUM' => [ 5, 'var', - ), - 'DEFAULT COLLATE' => array( + ], + 'DEFAULT COLLATE' => [ 6, 'var=', - ), - 'COLLATE' => array( + ], + 'COLLATE' => [ 6, 'var=', - ), - 'COMMENT' => array( + ], + 'COMMENT' => [ 7, 'var=', - ), - 'CONNECTION' => array( + ], + 'CONNECTION' => [ 8, 'var', - ), - 'DATA DIRECTORY' => array( + ], + 'DATA DIRECTORY' => [ 9, 'var', - ), - 'DELAY_KEY_WRITE' => array( + ], + 'DELAY_KEY_WRITE' => [ 10, 'var', - ), - 'INDEX DIRECTORY' => array( + ], + 'INDEX DIRECTORY' => [ 11, 'var', - ), - 'INSERT_METHOD' => array( + ], + 'INSERT_METHOD' => [ 12, 'var', - ), - 'KEY_BLOCK_SIZE' => array( + ], + 'KEY_BLOCK_SIZE' => [ 13, 'var', - ), - 'MAX_ROWS' => array( + ], + 'MAX_ROWS' => [ 14, 'var', - ), - 'MIN_ROWS' => array( + ], + 'MIN_ROWS' => [ 15, 'var', - ), - 'PACK_KEYS' => array( + ], + 'PACK_KEYS' => [ 16, 'var', - ), - 'PASSWORD' => array( + ], + 'PASSWORD' => [ 17, 'var', - ), - 'ROW_FORMAT' => array( + ], + 'ROW_FORMAT' => [ 18, 'var', - ), - 'TABLESPACE' => array( + ], + 'TABLESPACE' => [ 19, 'var', - ), - 'STORAGE' => array( + ], + 'STORAGE' => [ 20, 'var', - ), - 'UNION' => array( + ], + 'UNION' => [ 21, 'var', - ) - ); + ], + ]; /** * All function options. * * @var array */ - public static $FUNC_OPTIONS = array( - 'COMMENT' => array( + public static $FUNC_OPTIONS = [ + 'COMMENT' => [ 1, 'var=', - ), + ], 'LANGUAGE SQL' => 2, 'DETERMINISTIC' => 3, 'NOT DETERMINISTIC' => 3, @@ -229,24 +225,24 @@ class CreateStatement extends Statement 'NO SQL' => 4, 'READS SQL DATA' => 4, 'MODIFIES SQL DATA' => 4, - 'SQL SECURITY DEFINER' => array( + 'SQL SECURITY DEFINER' => [ 5, 'var', - ) - ); + ], + ]; /** * All trigger options. * * @var array */ - public static $TRIGGER_OPTIONS = array( + public static $TRIGGER_OPTIONS = [ 'BEFORE' => 1, 'AFTER' => 1, 'INSERT' => 2, 'UPDATE' => 2, - 'DELETE' => 2 - ); + 'DELETE' => 2, + ]; /** * The name of the entity that is created. @@ -262,11 +258,11 @@ class CreateStatement extends Statement * * Used by `CREATE TABLE`, `CREATE FUNCTION` and `CREATE PROCEDURE`. * - * @var OptionsArray - * * @see static::$TABLE_OPTIONS * @see static::$FUNC_OPTIONS * @see static::$TRIGGER_OPTIONS + * + * @var OptionsArray */ public $entityOptions; @@ -368,7 +364,7 @@ class CreateStatement extends Statement * * @var Token[]|string */ - public $body = array(); + public $body = []; /** * @return string @@ -389,12 +385,12 @@ class CreateStatement extends Statement . Expression::build($this->name) . ' ' . OptionsArray::build($this->entityOptions); } elseif ($this->options->has('TABLE')) { - if (! is_null($this->select)) { + if ($this->select !== null) { return 'CREATE ' . OptionsArray::build($this->options) . ' ' . Expression::build($this->name) . ' ' . $this->select->build(); - } elseif (! is_null($this->like)) { + } elseif ($this->like !== null) { return 'CREATE ' . OptionsArray::build($this->options) . ' ' . Expression::build($this->name) . ' LIKE ' @@ -478,10 +474,10 @@ class CreateStatement extends Statement $this->name = Expression::parse( $parser, $list, - array( + [ 'parseField' => $fieldName, - 'breakOnAlias' => true - ) + 'breakOnAlias' => true, + ] ); if (! isset($this->name) || ($this->name === '')) { @@ -528,13 +524,13 @@ class CreateStatement extends Statement $this->like = Expression::parse( $parser, $list, - array( + [ 'parseField' => 'table', - 'breakOnAlias' => true - ) + 'breakOnAlias' => true, + ] ); // The 'LIKE' keyword was found, but no table_name was found next to it - if (is_null($this->like)) { + if ($this->like === null) { $parser->error( 'A table name was expected.', $list->tokens[$list->idx] @@ -626,7 +622,7 @@ class CreateStatement extends Statement } // Building the expression used for partitioning. - $this->$field .= ($token->type === Token::TYPE_WHITESPACE) ? ' ' : $token->token; + $this->$field .= $token->type === Token::TYPE_WHITESPACE ? ' ' : $token->token; // Last bracket was read, the expression ended. // Comparing with `0` and not `false`, because `false` means @@ -641,9 +637,9 @@ class CreateStatement extends Statement $this->partitions = ArrayObj::parse( $parser, $list, - array( - 'type' => 'PhpMyAdmin\\SqlParser\\Components\\PartitionDefinition' - ) + [ + 'type' => 'PhpMyAdmin\\SqlParser\\Components\\PartitionDefinition', + ] ); } break; @@ -657,10 +653,10 @@ class CreateStatement extends Statement if ($this->options->has('FUNCTION')) { $prev_token = $token; $token = $list->getNextOfType(Token::TYPE_KEYWORD); - if (is_null($token) || $token->keyword !== 'RETURNS') { + if ($token === null || $token->keyword !== 'RETURNS') { $parser->error( 'A "RETURNS" keyword was expected.', - is_null($token) ? $prev_token : $token + $token ?? $prev_token ); } else { ++$list->idx; @@ -718,10 +714,10 @@ class CreateStatement extends Statement $this->table = Expression::parse( $parser, $list, - array( + [ 'parseField' => 'table', - 'breakOnAlias' => true - ) + 'breakOnAlias' => true, + ] ); ++$list->idx; diff --git a/src/Statements/DeleteStatement.php b/src/Statements/DeleteStatement.php index 088489d..57e100b 100644 --- a/src/Statements/DeleteStatement.php +++ b/src/Statements/DeleteStatement.php @@ -1,8 +1,8 @@ <?php - /** * `DELETE` statement. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Statements; @@ -41,11 +41,6 @@ use PhpMyAdmin\SqlParser\TokensList; * FROM tbl_name[.*] [, tbl_name[.*]] ... * USING table_references * [WHERE where_condition] - * - * - * @category Statements - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class DeleteStatement extends Statement { @@ -54,11 +49,11 @@ class DeleteStatement extends Statement * * @var array */ - public static $OPTIONS = array( + public static $OPTIONS = [ 'LOW_PRIORITY' => 1, 'QUICK' => 2, - 'IGNORE' => 3 - ); + 'IGNORE' => 3, + ]; /** * The clauses of this statement, in order. @@ -67,41 +62,41 @@ class DeleteStatement extends Statement * * @var array */ - public static $CLAUSES = array( - 'DELETE' => array( + public static $CLAUSES = [ + 'DELETE' => [ 'DELETE', 2, - ), + ], // Used for options. - '_OPTIONS' => array( + '_OPTIONS' => [ '_OPTIONS', 1, - ), - 'FROM' => array( + ], + 'FROM' => [ 'FROM', 3, - ), - 'PARTITION' => array( + ], + 'PARTITION' => [ 'PARTITION', 3, - ), - 'USING' => array( + ], + 'USING' => [ 'USING', 3, - ), - 'WHERE' => array( + ], + 'WHERE' => [ 'WHERE', 3, - ), - 'ORDER BY' => array( + ], + 'ORDER BY' => [ 'ORDER BY', 3, - ), - 'LIMIT' => array( + ], + 'LIMIT' => [ 'LIMIT', 3, - ) - ); + ], + ]; /** * Table(s) used as sources for this statement. @@ -166,25 +161,25 @@ class DeleteStatement extends Statement { $ret = 'DELETE ' . OptionsArray::build($this->options); - if (! is_null($this->columns) && count($this->columns) > 0) { + if ($this->columns !== null && count($this->columns) > 0) { $ret .= ' ' . ExpressionArray::build($this->columns); } - if (! is_null($this->from) && count($this->from) > 0) { + if ($this->from !== null && count($this->from) > 0) { $ret .= ' FROM ' . ExpressionArray::build($this->from); } - if (! is_null($this->join) && count($this->join) > 0) { + if ($this->join !== null && count($this->join) > 0) { $ret .= ' ' . JoinKeyword::build($this->join); } - if (! is_null($this->using) && count($this->using) > 0) { + if ($this->using !== null && count($this->using) > 0) { $ret .= ' USING ' . ExpressionArray::build($this->using); } - if (! is_null($this->where) && count($this->where) > 0) { + if ($this->where !== null && count($this->where) > 0) { $ret .= ' WHERE ' . Condition::build($this->where); } - if (! is_null($this->order) && count($this->order) > 0) { + if ($this->order !== null && count($this->order) > 0) { $ret .= ' ORDER BY ' . ExpressionArray::build($this->order); } - if (! is_null($this->limit) && strlen($this->limit) > 0) { + if ($this->limit !== null && strlen((string) $this->limit) > 0) { $ret .= ' LIMIT ' . Limit::build($this->limit); } diff --git a/src/Statements/DropStatement.php b/src/Statements/DropStatement.php index 7b9da2c..202d5e0 100644 --- a/src/Statements/DropStatement.php +++ b/src/Statements/DropStatement.php @@ -1,8 +1,8 @@ <?php - /** * `DROP` statement. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Statements; @@ -11,10 +11,6 @@ use PhpMyAdmin\SqlParser\Statement; /** * `DROP` statement. - * - * @category Statements - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class DropStatement extends Statement { @@ -23,7 +19,7 @@ class DropStatement extends Statement * * @var array */ - public static $OPTIONS = array( + public static $OPTIONS = [ 'DATABASE' => 1, 'EVENT' => 1, 'FUNCTION' => 1, @@ -39,8 +35,8 @@ class DropStatement extends Statement 'USER' => 1, 'TEMPORARY' => 2, - 'IF EXISTS' => 3 - ); + 'IF EXISTS' => 3, + ]; /** * The clauses of this statement, in order. @@ -49,26 +45,26 @@ class DropStatement extends Statement * * @var array */ - public static $CLAUSES = array( - 'DROP' => array( + public static $CLAUSES = [ + 'DROP' => [ 'DROP', 2, - ), + ], // Used for options. - '_OPTIONS' => array( + '_OPTIONS' => [ '_OPTIONS', 1, - ), + ], // Used for select expressions. - 'DROP_' => array( + 'DROP_' => [ 'DROP', 1, - ), - 'ON' => array( + ], + 'ON' => [ 'ON', 3, - ) - ); + ], + ]; /** * Dropped elements. diff --git a/src/Statements/ExplainStatement.php b/src/Statements/ExplainStatement.php index 96a5828..15e6add 100644 --- a/src/Statements/ExplainStatement.php +++ b/src/Statements/ExplainStatement.php @@ -1,17 +1,13 @@ <?php - /** * `EXPLAIN` statement. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Statements; /** * `EXPLAIN` statement. - * - * @category Statements - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class ExplainStatement extends NotImplementedStatement { diff --git a/src/Statements/InsertStatement.php b/src/Statements/InsertStatement.php index 4e48c0d..6f63235 100644 --- a/src/Statements/InsertStatement.php +++ b/src/Statements/InsertStatement.php @@ -1,13 +1,13 @@ <?php - /** * `INSERT` statement. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Statements; -use PhpMyAdmin\SqlParser\Components\ArrayObj; use PhpMyAdmin\SqlParser\Components\Array2d; +use PhpMyAdmin\SqlParser\Components\ArrayObj; use PhpMyAdmin\SqlParser\Components\IntoKeyword; use PhpMyAdmin\SqlParser\Components\OptionsArray; use PhpMyAdmin\SqlParser\Components\SetOperation; @@ -48,10 +48,6 @@ use PhpMyAdmin\SqlParser\TokensList; * [ ON DUPLICATE KEY UPDATE * col_name=expr * [, col_name=expr] ... ] - * - * @category Statements - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class InsertStatement extends Statement { @@ -60,12 +56,12 @@ class InsertStatement extends Statement * * @var array */ - public static $OPTIONS = array( + public static $OPTIONS = [ 'LOW_PRIORITY' => 1, 'DELAYED' => 2, 'HIGH_PRIORITY' => 3, - 'IGNORE' => 4 - ); + 'IGNORE' => 4, + ]; /** * Tables used as target for this statement. @@ -113,15 +109,15 @@ class InsertStatement extends Statement $ret = 'INSERT ' . $this->options; $ret = trim($ret) . ' INTO ' . $this->into; - if (! is_null($this->values) && count($this->values) > 0) { + if ($this->values !== null && count($this->values) > 0) { $ret .= ' VALUES ' . Array2d::build($this->values); - } elseif (! is_null($this->set) && count($this->set) > 0) { + } elseif ($this->set !== null && count($this->set) > 0) { $ret .= ' SET ' . SetOperation::build($this->set); - } elseif (! is_null($this->select) && strlen($this->select) > 0) { + } elseif ($this->select !== null && strlen((string) $this->select) > 0) { $ret .= ' ' . $this->select->build(); } - if (! is_null($this->onDuplicateSet) && count($this->onDuplicateSet) > 0) { + if ($this->onDuplicateSet !== null && count($this->onDuplicateSet) > 0) { $ret .= ' ON DUPLICATE KEY UPDATE ' . SetOperation::build($this->onDuplicateSet); } @@ -195,7 +191,7 @@ class InsertStatement extends Statement $this->into = IntoKeyword::parse( $parser, $list, - array('fromInsert' => true) + ['fromInsert' => true] ); $state = 1; diff --git a/src/Statements/LoadStatement.php b/src/Statements/LoadStatement.php index 422efc7..62ef50f 100644 --- a/src/Statements/LoadStatement.php +++ b/src/Statements/LoadStatement.php @@ -1,8 +1,8 @@ <?php - /** * `LOAD` statement. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Statements; @@ -36,11 +36,6 @@ use PhpMyAdmin\SqlParser\TokensList; * [IGNORE number {LINES | ROWS}] * [(col_name_or_user_var,...)] * [SET col_name = expr,...] - * - * - * @category Statements - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class LoadStatement extends Statement { @@ -49,48 +44,48 @@ class LoadStatement extends Statement * * @var array */ - public static $OPTIONS = array( + public static $OPTIONS = [ 'LOW_PRIORITY' => 1, 'CONCURRENT' => 1, - 'LOCAL' => 2 - ); + 'LOCAL' => 2, + ]; /** * FIELDS/COLUMNS Options for `LOAD DATA...INFILE` statements. * * @var array */ - public static $FIELDS_OPTIONS = array( - 'TERMINATED BY' => array( + public static $FIELDS_OPTIONS = [ + 'TERMINATED BY' => [ 1, 'expr', - ), + ], 'OPTIONALLY' => 2, - 'ENCLOSED BY' => array( + 'ENCLOSED BY' => [ 3, 'expr', - ), - 'ESCAPED BY' => array( + ], + 'ESCAPED BY' => [ 4, 'expr', - ) - ); + ], + ]; /** * LINES Options for `LOAD DATA...INFILE` statements. * * @var array */ - public static $LINES_OPTIONS = array( - 'STARTING BY' => array( + public static $LINES_OPTIONS = [ + 'STARTING BY' => [ 1, 'expr', - ), - 'TERMINATED BY' => array( + ], + 'TERMINATED BY' => [ 2, 'expr', - ) - ); + ], + ]; /** * File name being used to load data. @@ -123,9 +118,9 @@ class LoadStatement extends Statement /** * Options for FIELDS/COLUMNS keyword. * - * @var OptionsArray - * * @see static::$FIELDS_OPTIONS + * + * @var OptionsArray */ public $fields_options; @@ -139,9 +134,9 @@ class LoadStatement extends Statement /** * Options for OPTIONS keyword. * - * @var OptionsArray - * * @see static::$LINES_OPTIONS + * + * @var OptionsArray */ public $lines_options; @@ -194,7 +189,7 @@ class LoadStatement extends Statement $ret .= ' INTO TABLE ' . $this->table; - if ($this->partition !== null && strlen($this->partition) > 0) { + if ($this->partition !== null && strlen((string) $this->partition) > 0) { $ret .= ' PARTITION ' . ArrayObj::build($this->partition); } @@ -206,7 +201,7 @@ class LoadStatement extends Statement $ret .= ' ' . $this->fields_keyword . ' ' . $this->fields_options; } - if ($this->lines_options !== null && strlen($this->lines_options) > 0) { + if ($this->lines_options !== null && strlen((string) $this->lines_options) > 0) { $ret .= ' LINES ' . $this->lines_options; } @@ -281,7 +276,7 @@ class LoadStatement extends Statement $this->file_name = Expression::parse( $parser, $list, - array('parseField' => 'file') + ['parseField' => 'file'] ); $state = 1; } elseif ($state === 1) { @@ -298,7 +293,7 @@ class LoadStatement extends Statement && $token->keyword === 'TABLE' ) { ++$list->idx; - $this->table = Expression::parse($parser, $list, array('parseField' => 'table')); + $this->table = Expression::parse($parser, $list, ['parseField' => 'table']); $state = 3; } else { $parser->error('Unexpected token.', $token); diff --git a/src/Statements/LockStatement.php b/src/Statements/LockStatement.php index d4c6cb1..6444586 100644 --- a/src/Statements/LockStatement.php +++ b/src/Statements/LockStatement.php @@ -1,8 +1,8 @@ <?php - /** * `LOCK` statement. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Statements; @@ -14,10 +14,6 @@ use PhpMyAdmin\SqlParser\TokensList; /** * `LOCK` statement. - * - * @category Statements - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class LockStatement extends Statement { @@ -26,7 +22,7 @@ class LockStatement extends Statement * * @var LockExpression[] */ - public $locked = array(); + public $locked = []; /** * Whether it's a LOCK statement diff --git a/src/Statements/MaintenanceStatement.php b/src/Statements/MaintenanceStatement.php index ac3b8c9..273188f 100644 --- a/src/Statements/MaintenanceStatement.php +++ b/src/Statements/MaintenanceStatement.php @@ -1,8 +1,8 @@ <?php - /** * Maintenance statement. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Statements; @@ -18,10 +18,6 @@ use PhpMyAdmin\SqlParser\TokensList; * * They follow the syntax: * STMT [some options] tbl_name [, tbl_name] ... [some more options] - * - * @category Statements - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class MaintenanceStatement extends Statement { diff --git a/src/Statements/NotImplementedStatement.php b/src/Statements/NotImplementedStatement.php index e534cdf..dae6f85 100644 --- a/src/Statements/NotImplementedStatement.php +++ b/src/Statements/NotImplementedStatement.php @@ -1,8 +1,8 @@ <?php - /** * Not implemented (yet) statements. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Statements; @@ -15,10 +15,6 @@ use PhpMyAdmin\SqlParser\TokensList; * Not implemented (yet) statements. * * The `after` function makes the parser jump straight to the first delimiter. - * - * @category Statements - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class NotImplementedStatement extends Statement { @@ -27,7 +23,7 @@ class NotImplementedStatement extends Statement * * @var Token[] */ - public $unknown = array(); + public $unknown = []; /** * @return string diff --git a/src/Statements/OptimizeStatement.php b/src/Statements/OptimizeStatement.php index 1aff056..c9c4979 100644 --- a/src/Statements/OptimizeStatement.php +++ b/src/Statements/OptimizeStatement.php @@ -1,8 +1,8 @@ <?php - /** * `OPTIMIZE` statement. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Statements; @@ -14,10 +14,6 @@ use PhpMyAdmin\SqlParser\Statement; * * OPTIMIZE [NO_WRITE_TO_BINLOG | LOCAL] TABLE * tbl_name [, tbl_name] ... - * - * @category Statements - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class OptimizeStatement extends Statement { @@ -26,12 +22,12 @@ class OptimizeStatement extends Statement * * @var array */ - public static $OPTIONS = array( + public static $OPTIONS = [ 'TABLE' => 1, 'NO_WRITE_TO_BINLOG' => 2, - 'LOCAL' => 3 - ); + 'LOCAL' => 3, + ]; /** * Optimized tables. diff --git a/src/Statements/PurgeStatement.php b/src/Statements/PurgeStatement.php index 0374813..1f74f42 100644 --- a/src/Statements/PurgeStatement.php +++ b/src/Statements/PurgeStatement.php @@ -1,13 +1,12 @@ <?php - /** * `PURGE` statement. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Statements; use PhpMyAdmin\SqlParser\Components\Expression; -use PhpMyAdmin\SqlParser\Components\OptionsArray; use PhpMyAdmin\SqlParser\Parser; use PhpMyAdmin\SqlParser\Statement; use PhpMyAdmin\SqlParser\Token; @@ -18,10 +17,6 @@ use PhpMyAdmin\SqlParser\TokensList; * * PURGE { BINARY | MASTER } LOGS * { TO 'log_name' | BEFORE datetime_expr } - * - * @category Statements - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class PurgeStatement extends Statement { @@ -51,7 +46,7 @@ class PurgeStatement extends Statement */ public function build() { - $ret = 'PURGE ' . $this->log_type . ' ' . 'LOGS ' + $ret = 'PURGE ' . $this->log_type . ' LOGS ' . ($this->end_option !== null ? ($this->end_option . ' ' . $this->end_expr) : ''); return trim($ret); } @@ -71,6 +66,7 @@ class PurgeStatement extends Statement */ $state = 0; + $prevToken = null; for (; $list->idx < $list->count; ++$list->idx) { /** * Token parsed at this moment. @@ -92,19 +88,19 @@ class PurgeStatement extends Statement switch ($state) { case 0: // parse `{ BINARY | MASTER }` - $this->log_type = self::parseExpectedKeyword($parser, $token, array('BINARY', 'MASTER')); + $this->log_type = self::parseExpectedKeyword($parser, $token, ['BINARY', 'MASTER']); break; case 1: // parse `LOGS` - self::parseExpectedKeyword($parser, $token, array('LOGS')); + self::parseExpectedKeyword($parser, $token, ['LOGS']); break; case 2: // parse `{ TO | BEFORE }` - $this->end_option = self::parseExpectedKeyword($parser, $token, array('TO', 'BEFORE')); + $this->end_option = self::parseExpectedKeyword($parser, $token, ['TO', 'BEFORE']); break; case 3: // parse `expr` - $this->end_expr = Expression::parse($parser, $list, array()); + $this->end_expr = Expression::parse($parser, $list, []); break; default: $parser->error('Unexpected token.', $token); diff --git a/src/Statements/RenameStatement.php b/src/Statements/RenameStatement.php index e1bcf0d..6e3d0ec 100644 --- a/src/Statements/RenameStatement.php +++ b/src/Statements/RenameStatement.php @@ -1,8 +1,8 @@ <?php - /** * `RENAME` statement. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Statements; @@ -17,10 +17,6 @@ use PhpMyAdmin\SqlParser\TokensList; * * RENAME TABLE tbl_name TO new_tbl_name * [, tbl_name2 TO new_tbl_name2] ... - * - * @category Statements - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class RenameStatement extends Statement { diff --git a/src/Statements/RepairStatement.php b/src/Statements/RepairStatement.php index fb76855..ee96e3b 100644 --- a/src/Statements/RepairStatement.php +++ b/src/Statements/RepairStatement.php @@ -1,8 +1,8 @@ <?php - /** * `REPAIR` statement. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Statements; @@ -12,10 +12,6 @@ namespace PhpMyAdmin\SqlParser\Statements; * REPAIR [NO_WRITE_TO_BINLOG | LOCAL] TABLE * tbl_name [, tbl_name] ... * [QUICK] [EXTENDED] [USE_FRM] - * - * @category Statements - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class RepairStatement extends MaintenanceStatement { @@ -24,7 +20,7 @@ class RepairStatement extends MaintenanceStatement * * @var array */ - public static $OPTIONS = array( + public static $OPTIONS = [ 'TABLE' => 1, 'NO_WRITE_TO_BINLOG' => 2, @@ -32,6 +28,6 @@ class RepairStatement extends MaintenanceStatement 'QUICK' => 4, 'EXTENDED' => 5, - 'USE_FRM' => 6 - ); + 'USE_FRM' => 6, + ]; } diff --git a/src/Statements/ReplaceStatement.php b/src/Statements/ReplaceStatement.php index d912da0..132eef8 100644 --- a/src/Statements/ReplaceStatement.php +++ b/src/Statements/ReplaceStatement.php @@ -1,8 +1,8 @@ <?php - /** * `REPLACE` statement. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Statements; @@ -35,10 +35,6 @@ use PhpMyAdmin\SqlParser\TokensList; * [PARTITION (partition_name,...)] * [(col_name,...)] * SELECT ... - * - * @category Statements - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class ReplaceStatement extends Statement { @@ -47,10 +43,10 @@ class ReplaceStatement extends Statement * * @var array */ - public static $OPTIONS = array( + public static $OPTIONS = [ 'LOW_PRIORITY' => 1, - 'DELAYED' => 1 - ); + 'DELAYED' => 1, + ]; /** * Tables used as target for this statement. @@ -90,11 +86,11 @@ class ReplaceStatement extends Statement $ret = 'REPLACE ' . $this->options; $ret = trim($ret) . ' INTO ' . $this->into; - if (! is_null($this->values) && count($this->values) > 0) { + if ($this->values !== null && count($this->values) > 0) { $ret .= ' VALUES ' . Array2d::build($this->values); - } elseif (! is_null($this->set) && count($this->set) > 0) { + } elseif ($this->set !== null && count($this->set) > 0) { $ret .= ' SET ' . SetOperation::build($this->set); - } elseif (! is_null($this->select) && strlen($this->select) > 0) { + } elseif ($this->select !== null && strlen((string) $this->select) > 0) { $ret .= ' ' . $this->select->build(); } @@ -160,7 +156,7 @@ class ReplaceStatement extends Statement $this->into = IntoKeyword::parse( $parser, $list, - array('fromReplace' => true) + ['fromReplace' => true] ); $state = 1; diff --git a/src/Statements/RestoreStatement.php b/src/Statements/RestoreStatement.php index a7bf2c8..72b2ea2 100644 --- a/src/Statements/RestoreStatement.php +++ b/src/Statements/RestoreStatement.php @@ -1,8 +1,8 @@ <?php - /** * `RESTORE` statement. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Statements; @@ -10,10 +10,6 @@ namespace PhpMyAdmin\SqlParser\Statements; * `RESTORE` statement. * * RESTORE TABLE tbl_name [, tbl_name] ... FROM '/path/to/backup/directory' - * - * @category Statements - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class RestoreStatement extends MaintenanceStatement { @@ -22,12 +18,12 @@ class RestoreStatement extends MaintenanceStatement * * @var array */ - public static $OPTIONS = array( + public static $OPTIONS = [ 'TABLE' => 1, - 'FROM' => array( + 'FROM' => [ 2, 'var', - ) - ); + ], + ]; } diff --git a/src/Statements/SelectStatement.php b/src/Statements/SelectStatement.php index 852dc0b..4fecd90 100644 --- a/src/Statements/SelectStatement.php +++ b/src/Statements/SelectStatement.php @@ -1,8 +1,8 @@ <?php - /** * `SELECT` statement. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Statements; @@ -33,10 +33,10 @@ use PhpMyAdmin\SqlParser\Statement; * [PARTITION partition_list] * [WHERE where_condition] * [GROUP BY {col_name | expr | position} - * [ASC | DESC), ... [WITH ROLLUP]] + * [ASC | DESC], ... [WITH ROLLUP]] * [HAVING where_condition] * [ORDER BY {col_name | expr | position} - * [ASC | DESC), ...] + * [ASC | DESC], ...] * [LIMIT {[offset,] row_count | row_count OFFSET offset}] * [PROCEDURE procedure_name(argument_list)] * [INTO OUTFILE 'file_name' @@ -45,10 +45,6 @@ use PhpMyAdmin\SqlParser\Statement; * | INTO DUMPFILE 'file_name' * | INTO var_name [, var_name]] * [FOR UPDATE | LOCK IN SHARE MODE]] - * - * @category Statements - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class SelectStatement extends Statement { @@ -57,28 +53,28 @@ class SelectStatement extends Statement * * @var array */ - public static $OPTIONS = array( + public static $OPTIONS = [ 'ALL' => 1, 'DISTINCT' => 1, 'DISTINCTROW' => 1, 'HIGH_PRIORITY' => 2, - 'MAX_STATEMENT_TIME' => array( + 'MAX_STATEMENT_TIME' => [ 3, 'var=', - ), + ], 'STRAIGHT_JOIN' => 4, 'SQL_SMALL_RESULT' => 5, 'SQL_BIG_RESULT' => 6, 'SQL_BUFFER_RESULT' => 7, 'SQL_CACHE' => 8, 'SQL_NO_CACHE' => 8, - 'SQL_CALC_FOUND_ROWS' => 9 - ); + 'SQL_CALC_FOUND_ROWS' => 9, + ]; - public static $END_OPTIONS = array( + public static $END_OPTIONS = [ 'FOR UPDATE' => 1, - 'LOCK IN SHARE MODE' => 1 - ); + 'LOCK IN SHARE MODE' => 1, + ]; /** * The clauses of this statement, in order. @@ -87,153 +83,153 @@ class SelectStatement extends Statement * * @var array */ - public static $CLAUSES = array( - 'SELECT' => array( + public static $CLAUSES = [ + 'SELECT' => [ 'SELECT', 2, - ), + ], // Used for options. - '_OPTIONS' => array( + '_OPTIONS' => [ '_OPTIONS', 1, - ), + ], // Used for selected expressions. - '_SELECT' => array( + '_SELECT' => [ 'SELECT', 1, - ), - 'INTO' => array( + ], + 'INTO' => [ 'INTO', 3, - ), - 'FROM' => array( + ], + 'FROM' => [ 'FROM', 3, - ), - 'FORCE' => array( + ], + 'FORCE' => [ 'FORCE', 1, - ), - 'USE' => array( + ], + 'USE' => [ 'USE', 1, - ), - 'IGNORE' => array( + ], + 'IGNORE' => [ 'IGNORE', 3, - ), - 'PARTITION' => array( + ], + 'PARTITION' => [ 'PARTITION', 3, - ), + ], - 'JOIN' => array( + 'JOIN' => [ 'JOIN', 1, - ), - 'FULL JOIN' => array( + ], + 'FULL JOIN' => [ 'FULL JOIN', 1, - ), - 'INNER JOIN' => array( + ], + 'INNER JOIN' => [ 'INNER JOIN', 1, - ), - 'LEFT JOIN' => array( + ], + 'LEFT JOIN' => [ 'LEFT JOIN', 1, - ), - 'LEFT OUTER JOIN' => array( + ], + 'LEFT OUTER JOIN' => [ 'LEFT OUTER JOIN', 1, - ), - 'RIGHT JOIN' => array( + ], + 'RIGHT JOIN' => [ 'RIGHT JOIN', 1, - ), - 'RIGHT OUTER JOIN' => array( + ], + 'RIGHT OUTER JOIN' => [ 'RIGHT OUTER JOIN', 1, - ), - 'NATURAL JOIN' => array( + ], + 'NATURAL JOIN' => [ 'NATURAL JOIN', 1, - ), - 'NATURAL LEFT JOIN' => array( + ], + 'NATURAL LEFT JOIN' => [ 'NATURAL LEFT JOIN', 1, - ), - 'NATURAL RIGHT JOIN' => array( + ], + 'NATURAL RIGHT JOIN' => [ 'NATURAL RIGHT JOIN', 1, - ), - 'NATURAL LEFT OUTER JOIN' => array( + ], + 'NATURAL LEFT OUTER JOIN' => [ 'NATURAL LEFT OUTER JOIN', 1, - ), - 'NATURAL RIGHT OUTER JOIN' => array( + ], + 'NATURAL RIGHT OUTER JOIN' => [ 'NATURAL RIGHT JOIN', 1, - ), + ], - 'WHERE' => array( + 'WHERE' => [ 'WHERE', 3, - ), - 'GROUP BY' => array( + ], + 'GROUP BY' => [ 'GROUP BY', 3, - ), - 'HAVING' => array( + ], + 'HAVING' => [ 'HAVING', 3, - ), - 'ORDER BY' => array( + ], + 'ORDER BY' => [ 'ORDER BY', 3, - ), - 'LIMIT' => array( + ], + 'LIMIT' => [ 'LIMIT', 3, - ), - 'PROCEDURE' => array( + ], + 'PROCEDURE' => [ 'PROCEDURE', 3, - ), - 'UNION' => array( + ], + 'UNION' => [ 'UNION', 1, - ), - 'EXCEPT' => array( + ], + 'EXCEPT' => [ 'EXCEPT', 1, - ), - 'INTERSECT' => array( + ], + 'INTERSECT' => [ 'INTERSECT', 1, - ), - '_END_OPTIONS' => array( + ], + '_END_OPTIONS' => [ '_END_OPTIONS', 1, - ), + ], // These are available only when `UNION` is present. - // 'ORDER BY' => array('ORDER BY', 3), - // 'LIMIT' => array('LIMIT', 3) - ); + // 'ORDER BY' => ['ORDER BY', 3], + // 'LIMIT' => ['LIMIT', 3], + ]; /** * Expressions that are being selected by this statement. * * @var Expression[] */ - public $expr = array(); + public $expr = []; /** * Tables used as sources for this statement. * * @var Expression[] */ - public $from = array(); + public $from = []; /** * Index hints @@ -310,14 +306,14 @@ class SelectStatement extends Statement * * @var SelectStatement[] */ - public $union = array(); + public $union = []; /** * The end options of this query. * - * @var OptionsArray - * * @see static::$END_OPTIONS + * + * @var OptionsArray */ public $end_options; @@ -334,14 +330,14 @@ class SelectStatement extends Statement if (! empty($this->union)) { $clauses = static::$CLAUSES; unset($clauses['ORDER BY'], $clauses['LIMIT']); - $clauses['ORDER BY'] = array( + $clauses['ORDER BY'] = [ 'ORDER BY', - 3 - ); - $clauses['LIMIT'] = array( + 3, + ]; + $clauses['LIMIT'] = [ 'LIMIT', - 3 - ); + 3, + ]; return $clauses; } diff --git a/src/Statements/SetStatement.php b/src/Statements/SetStatement.php index d62b6f0..80a1dc7 100644 --- a/src/Statements/SetStatement.php +++ b/src/Statements/SetStatement.php @@ -1,8 +1,8 @@ <?php - /** * `SET` statement. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Statements; @@ -12,10 +12,6 @@ use PhpMyAdmin\SqlParser\Statement; /** * `SET` statement. - * - * @category Statements - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class SetStatement extends Statement { @@ -26,39 +22,39 @@ class SetStatement extends Statement * * @var array */ - public static $CLAUSES = array( - 'SET' => array( + public static $CLAUSES = [ + 'SET' => [ 'SET', - 3 - ), - '_END_OPTIONS' => array( + 3, + ], + '_END_OPTIONS' => [ '_END_OPTIONS', - 1 - ) - ); + 1, + ], + ]; /** * Possible exceptions in SET statment. * * @var array */ - public static $OPTIONS = array( - 'CHARSET' => array( + public static $OPTIONS = [ + 'CHARSET' => [ 3, 'var', - ), - 'CHARACTER SET' => array( + ], + 'CHARACTER SET' => [ 3, 'var', - ), - 'NAMES' => array( + ], + 'NAMES' => [ 3, 'var', - ), - 'PASSWORD' => array( + ], + 'PASSWORD' => [ 3, 'expr', - ), + ], 'SESSION' => 3, 'GLOBAL' => 3, 'PERSIST' => 3, @@ -67,15 +63,15 @@ class SetStatement extends Statement '@@GLOBAL' => 3, '@@PERSIST' => 3, '@@PERSIST_ONLY' => 3, - ); + ]; - public static $END_OPTIONS = array( - 'COLLATE' => array( + public static $END_OPTIONS = [ + 'COLLATE' => [ 1, 'var', - ), - 'DEFAULT' => 1 - ); + ], + 'DEFAULT' => 1, + ]; /** * Options used in current statement. @@ -87,9 +83,9 @@ class SetStatement extends Statement /** * The end options of this query. * - * @var OptionsArray - * * @see static::$END_OPTIONS + * + * @var OptionsArray */ public $end_options; diff --git a/src/Statements/ShowStatement.php b/src/Statements/ShowStatement.php index 1e9e67e..266b74e 100644 --- a/src/Statements/ShowStatement.php +++ b/src/Statements/ShowStatement.php @@ -1,17 +1,13 @@ <?php - /** * `SHOW` statement. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Statements; /** * `SHOW` statement. - * - * @category Statements - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class ShowStatement extends NotImplementedStatement { @@ -20,7 +16,7 @@ class ShowStatement extends NotImplementedStatement * * @var array */ - public static $OPTIONS = array( + public static $OPTIONS = [ 'CREATE' => 1, 'AUTHORS' => 2, 'BINARY' => 2, @@ -61,6 +57,6 @@ class ShowStatement extends NotImplementedStatement 'TRIGGERS' => 2, 'VARIABLES' => 2, 'VIEW' => 2, - 'WARNINGS' => 2 - ); + 'WARNINGS' => 2, + ]; } diff --git a/src/Statements/TransactionStatement.php b/src/Statements/TransactionStatement.php index 59bd9c6..f47f86f 100644 --- a/src/Statements/TransactionStatement.php +++ b/src/Statements/TransactionStatement.php @@ -1,8 +1,8 @@ <?php - /** * Transaction statement. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Statements; @@ -13,10 +13,6 @@ use PhpMyAdmin\SqlParser\TokensList; /** * Transaction statement. - * - * @category Statements - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class TransactionStatement extends Statement { @@ -60,7 +56,7 @@ class TransactionStatement extends Statement * * @var array */ - public static $OPTIONS = array( + public static $OPTIONS = [ 'START TRANSACTION' => 1, 'BEGIN' => 1, 'COMMIT' => 1, @@ -70,8 +66,8 @@ class TransactionStatement extends Statement 'AND NO CHAIN' => 3, 'AND CHAIN' => 3, 'RELEASE' => 4, - 'NO RELEASE' => 4 - ); + 'NO RELEASE' => 4, + ]; /** * @param Parser $parser the instance that requests parsing diff --git a/src/Statements/TruncateStatement.php b/src/Statements/TruncateStatement.php index 13a4d21..9397573 100644 --- a/src/Statements/TruncateStatement.php +++ b/src/Statements/TruncateStatement.php @@ -1,8 +1,8 @@ <?php - /** * `TRUNCATE` statement. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Statements; @@ -11,10 +11,6 @@ use PhpMyAdmin\SqlParser\Statement; /** * `TRUNCATE` statement. - * - * @category Statements - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class TruncateStatement extends Statement { @@ -23,9 +19,9 @@ class TruncateStatement extends Statement * * @var array */ - public static $OPTIONS = array( - 'TABLE' => 1 - ); + public static $OPTIONS = [ + 'TABLE' => 1, + ]; /** * The name of the truncated table. diff --git a/src/Statements/UpdateStatement.php b/src/Statements/UpdateStatement.php index da7d741..82adeb1 100644 --- a/src/Statements/UpdateStatement.php +++ b/src/Statements/UpdateStatement.php @@ -1,8 +1,8 @@ <?php - /** * `UPDATE` statement. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Statements; @@ -27,10 +27,6 @@ use PhpMyAdmin\SqlParser\Statement; * UPDATE [LOW_PRIORITY] [IGNORE] table_references * SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ... * [WHERE where_condition] - * - * @category Statements - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class UpdateStatement extends Statement { @@ -39,10 +35,10 @@ class UpdateStatement extends Statement * * @var array */ - public static $OPTIONS = array( + public static $OPTIONS = [ 'LOW_PRIORITY' => 1, - 'IGNORE' => 2 - ); + 'IGNORE' => 2, + ]; /** * The clauses of this statement, in order. @@ -51,38 +47,38 @@ class UpdateStatement extends Statement * * @var array */ - public static $CLAUSES = array( - 'UPDATE' => array( + public static $CLAUSES = [ + 'UPDATE' => [ 'UPDATE', 2, - ), + ], // Used for options. - '_OPTIONS' => array( + '_OPTIONS' => [ '_OPTIONS', 1, - ), + ], // Used for updated tables. - '_UPDATE' => array( + '_UPDATE' => [ 'UPDATE', 1, - ), - 'SET' => array( + ], + 'SET' => [ 'SET', 3, - ), - 'WHERE' => array( + ], + 'WHERE' => [ 'WHERE', 3, - ), - 'ORDER BY' => array( + ], + 'ORDER BY' => [ 'ORDER BY', 3, - ), - 'LIMIT' => array( + ], + 'LIMIT' => [ 'LIMIT', 3, - ) - ); + ], + ]; /** * Tables used as sources for this statement. |