diff options
Diffstat (limited to 'src/Utils')
-rw-r--r-- | src/Utils/BufferedQuery.php | 16 | ||||
-rw-r--r-- | src/Utils/CLI.php | 39 | ||||
-rw-r--r-- | src/Utils/Error.php | 28 | ||||
-rw-r--r-- | src/Utils/Formatter.php | 104 | ||||
-rw-r--r-- | src/Utils/Misc.php | 32 | ||||
-rw-r--r-- | src/Utils/Query.php | 70 | ||||
-rw-r--r-- | src/Utils/Routine.php | 52 | ||||
-rw-r--r-- | src/Utils/Table.php | 28 | ||||
-rw-r--r-- | src/Utils/Tokens.php | 10 |
9 files changed, 172 insertions, 207 deletions
diff --git a/src/Utils/BufferedQuery.php b/src/Utils/BufferedQuery.php index db9c4e5..e2f269a 100644 --- a/src/Utils/BufferedQuery.php +++ b/src/Utils/BufferedQuery.php @@ -1,8 +1,8 @@ <?php - /** * Buffered query utilities. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Utils; @@ -14,10 +14,6 @@ use PhpMyAdmin\SqlParser\Context; * Implements a specialized lexer used to extract statements from large inputs * that are being buffered. After each statement has been extracted, a lexer or * a parser may be used. - * - * @category Lexer - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class BufferedQuery { @@ -49,7 +45,7 @@ class BufferedQuery * * @var array */ - public $options = array(); + public $options = []; /** * The last delimiter used. @@ -80,16 +76,14 @@ class BufferedQuery public $current = ''; /** - * Constructor. - * * @param string $query the query to be parsed * @param array $options the options of this parser */ - public function __construct($query = '', array $options = array()) + public function __construct($query = '', array $options = []) { // Merges specified options with defaults. $this->options = array_merge( - array( + [ /* * The starting delimiter. * @@ -111,7 +105,7 @@ class BufferedQuery * @var bool */ 'add_delimiter' => false, - ), + ], $options ); diff --git a/src/Utils/CLI.php b/src/Utils/CLI.php index 60af222..240c9dd 100644 --- a/src/Utils/CLI.php +++ b/src/Utils/CLI.php @@ -1,8 +1,8 @@ <?php - /** * CLI interface. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Utils; @@ -12,10 +12,6 @@ use PhpMyAdmin\SqlParser\Parser; /** * CLI interface. - * - * @category Exceptions - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class CLI { @@ -42,11 +38,11 @@ class CLI public function parseHighlight() { - $longopts = array( + $longopts = [ 'help', 'query:', - 'format:' - ); + 'format:', + ]; $params = $this->getopt( 'hq:f:', $longopts @@ -58,7 +54,7 @@ class CLI if (! isset($params['f'])) { $params['f'] = 'cli'; } - if (! in_array($params['f'], array('html', 'cli', 'text'))) { + if (! in_array($params['f'], ['html', 'cli', 'text'])) { echo "ERROR: Invalid value for format!\n"; return false; @@ -78,7 +74,7 @@ class CLI return 0; } - if (!isset($params['q'])) { + if (! isset($params['q'])) { if ($stdIn = $this->readStdin()) { $params['q'] = $stdIn; } @@ -86,7 +82,7 @@ class CLI if (isset($params['q'])) { echo Formatter::format( $params['q'], - array('type' => $params['f']) + ['type' => $params['f']] ); echo "\n"; @@ -106,11 +102,11 @@ class CLI public function parseLint() { - $longopts = array( + $longopts = [ 'help', 'query:', - 'context:' - ); + 'context:', + ]; $params = $this->getopt( 'hq:c:', $longopts @@ -134,7 +130,7 @@ class CLI if (isset($params['c'])) { Context::load($params['c']); } - if (!isset($params['q'])) { + if (! isset($params['q'])) { if ($stdIn = $this->readStdin()) { $params['q'] = $stdIn; } @@ -142,7 +138,7 @@ class CLI if (isset($params['q'])) { $lexer = new Lexer($params['q'], false); $parser = new Parser($lexer->list); - $errors = Error::get(array($lexer, $parser)); + $errors = Error::get([$lexer, $parser]); if (count($errors) === 0) { return 0; } @@ -166,10 +162,10 @@ class CLI public function parseTokenize() { - $longopts = array( + $longopts = [ 'help', - 'query:' - ); + 'query:', + ]; $params = $this->getopt( 'hq:', $longopts @@ -190,7 +186,7 @@ class CLI return 0; } - if (!isset($params['q'])) { + if (! isset($params['q'])) { if ($stdIn = $this->readStdin()) { $params['q'] = $stdIn; } @@ -218,7 +214,8 @@ class CLI return 1; } - private function readStdin() { + private function readStdin() + { stream_set_blocking(STDIN, false); $stdin = stream_get_contents(STDIN); // restore-default block-mode setting diff --git a/src/Utils/Error.php b/src/Utils/Error.php index 20310a1..484da5c 100644 --- a/src/Utils/Error.php +++ b/src/Utils/Error.php @@ -1,20 +1,18 @@ <?php - /** * Error related utilities. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Utils; +use PhpMyAdmin\SqlParser\Exceptions\LexerException; +use PhpMyAdmin\SqlParser\Exceptions\ParserException; use PhpMyAdmin\SqlParser\Lexer; use PhpMyAdmin\SqlParser\Parser; /** * Error related utilities. - * - * @category Exceptions - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class Error { @@ -32,26 +30,28 @@ class Error */ public static function get($objs) { - $ret = array(); + $ret = []; foreach ($objs as $obj) { if ($obj instanceof Lexer) { + /** @var LexerException $err */ foreach ($obj->errors as $err) { - $ret[] = array( + $ret[] = [ $err->getMessage(), $err->getCode(), $err->ch, - $err->pos - ); + $err->pos, + ]; } } elseif ($obj instanceof Parser) { + /** @var ParserException $err */ foreach ($obj->errors as $err) { - $ret[] = array( + $ret[] = [ $err->getMessage(), $err->getCode(), $err->token->token, - $err->token->position - ); + $err->token->position, + ]; } } } @@ -77,7 +77,7 @@ class Error $errors, $format = '#%1$d: %2$s (near "%4$s" at position %5$d)' ) { - $ret = array(); + $ret = []; $i = 0; foreach ($errors as $key => $err) { @@ -86,7 +86,7 @@ class Error ++$i, $err[0], $err[1], - htmlspecialchars($err[2]), + htmlspecialchars((string) $err[2]), $err[3] ); } diff --git a/src/Utils/Formatter.php b/src/Utils/Formatter.php index b608b73..6d340cc 100644 --- a/src/Utils/Formatter.php +++ b/src/Utils/Formatter.php @@ -1,8 +1,8 @@ <?php - /** * Utilities that are used for formatting queries. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Utils; @@ -14,10 +14,6 @@ use PhpMyAdmin\SqlParser\TokensList; /** * Utilities that are used for formatting queries. - * - * @category Misc - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class Formatter { @@ -46,10 +42,10 @@ class Formatter * * @var array */ - public static $SHORT_CLAUSES = array( + public static $SHORT_CLAUSES = [ 'CREATE' => true, - 'INSERT' => true - ); + 'INSERT' => true, + ]; /** * Clauses that must be inlined. @@ -58,7 +54,7 @@ class Formatter * * @var array */ - public static $INLINE_CLAUSES = array( + public static $INLINE_CLAUSES = [ 'CREATE' => true, 'INTO' => true, 'LIMIT' => true, @@ -66,15 +62,13 @@ class Formatter 'PARTITION' => true, 'PROCEDURE' => true, 'SUBPARTITION BY' => true, - 'VALUES' => true - ); + 'VALUES' => true, + ]; /** - * Constructor. - * * @param array $options the formatting options */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { $this->options = $this->getMergedOptions($options); } @@ -99,11 +93,11 @@ class Formatter $options['formats'] = $this->getDefaultFormats(); } - if (is_null($options['line_ending'])) { + if ($options['line_ending'] === null) { $options['line_ending'] = $options['type'] === 'html' ? '<br/>' : "\n"; } - if (is_null($options['indentation'])) { + if ($options['indentation'] === null) { $options['indentation'] = $options['type'] === 'html' ? ' ' : ' '; } @@ -120,7 +114,7 @@ class Formatter */ protected function getDefaultOptions() { - return array( + return [ /* * The format of the result. * @@ -170,8 +164,8 @@ class Formatter * * @var bool */ - 'indent_parts' => true - ); + 'indent_parts' => true, + ]; } /** @@ -182,78 +176,78 @@ class Formatter */ protected function getDefaultFormats() { - return array( - array( + return [ + [ 'type' => Token::TYPE_KEYWORD, 'flags' => Token::FLAG_KEYWORD_RESERVED, 'html' => 'class="sql-reserved"', 'cli' => "\x1b[35m", 'function' => 'strtoupper', - ), - array( + ], + [ 'type' => Token::TYPE_KEYWORD, 'flags' => 0, 'html' => 'class="sql-keyword"', 'cli' => "\x1b[95m", 'function' => 'strtoupper', - ), - array( + ], + [ 'type' => Token::TYPE_COMMENT, 'flags' => 0, 'html' => 'class="sql-comment"', 'cli' => "\x1b[37m", 'function' => '', - ), - array( + ], + [ 'type' => Token::TYPE_BOOL, 'flags' => 0, 'html' => 'class="sql-atom"', 'cli' => "\x1b[36m", 'function' => 'strtoupper', - ), - array( + ], + [ 'type' => Token::TYPE_NUMBER, 'flags' => 0, 'html' => 'class="sql-number"', 'cli' => "\x1b[92m", 'function' => 'strtolower', - ), - array( + ], + [ 'type' => Token::TYPE_STRING, 'flags' => 0, 'html' => 'class="sql-string"', 'cli' => "\x1b[91m", 'function' => '', - ), - array( + ], + [ 'type' => Token::TYPE_SYMBOL, 'flags' => Token::FLAG_SYMBOL_PARAMETER, 'html' => 'class="sql-parameter"', 'cli' => "\x1b[31m", 'function' => '', - ), - array( + ], + [ 'type' => Token::TYPE_SYMBOL, 'flags' => 0, 'html' => 'class="sql-variable"', 'cli' => "\x1b[36m", 'function' => '', - ) - ); + ], + ]; } private static function mergeFormats(array $formats, array $newFormats) { - $added = array(); - $integers = array( + $added = []; + $integers = [ 'flags', - 'type' - ); - $strings = array( + 'type', + ]; + $strings = [ 'html', 'cli', - 'function' - ); + 'function', + ]; /* Sanitize the array so that we do not have to care later */ foreach ($newFormats as $j => $new) { @@ -341,7 +335,7 @@ class Formatter * * @var array */ - $blocksIndentation = array(); + $blocksIndentation = []; /** * A stack that keeps track of the line endings every time a new block @@ -349,7 +343,7 @@ class Formatter * * @var array */ - $blocksLineEndings = array(); + $blocksLineEndings = []; /** * Whether clause's options were formatted. @@ -437,7 +431,7 @@ class Formatter // Inline JOINs if (($prev->type === Token::TYPE_KEYWORD && isset(JoinKeyword::$JOINS[$prev->value])) - || (in_array($curr->value, array('ON', 'USING'), true) && isset(JoinKeyword::$JOINS[$list->tokens[$list->idx - 2]->value])) + || (in_array($curr->value, ['ON', 'USING'], true) && isset(JoinKeyword::$JOINS[$list->tokens[$list->idx - 2]->value])) || isset($list->tokens[$list->idx - 4], JoinKeyword::$JOINS[$list->tokens[$list->idx - 4]->value]) || isset($list->tokens[$list->idx - 6], JoinKeyword::$JOINS[$list->tokens[$list->idx - 6]->value]) ) { @@ -494,7 +488,7 @@ class Formatter // Finishing the line. if ($lineEnded) { $ret .= $this->options['line_ending'] - . str_repeat($this->options['indentation'], $indent); + . str_repeat($this->options['indentation'], (int) $indent); $lineEnded = false; } else { @@ -507,7 +501,7 @@ class Formatter // No space after . ( || ($curr->type === Token::TYPE_OPERATOR && ($curr->value === '.' || $curr->value === ',' || $curr->value === '(' || $curr->value === ')')) // No space before . , ( ) - || $curr->type === Token::TYPE_DELIMITER && mb_strlen($curr->value, 'UTF-8') < 2 + || $curr->type === Token::TYPE_DELIMITER && mb_strlen((string) $curr->value, 'UTF-8') < 2 ) ) { $ret .= ' '; @@ -529,7 +523,7 @@ class Formatter public function escapeConsole($string) { return str_replace( - array( + [ "\x00", "\x01", "\x02", @@ -562,8 +556,8 @@ class Formatter "\x1D", "\x1E", "\x1F", - ), - array( + ], + [ '\x00', '\x01', '\x02', @@ -596,7 +590,7 @@ class Formatter '\x1D', '\x1E', '\x1F', - ), + ], $string ); } @@ -663,7 +657,7 @@ class Formatter * * @return string the formatted string */ - public static function format($query, array $options = array()) + public static function format($query, array $options = []) { $lexer = new Lexer($query); $formatter = new self($options); @@ -713,7 +707,7 @@ class Formatter } // Keeping track of this group's length. - $length += mb_strlen($list->tokens[$idx]->value, 'UTF-8'); + $length += mb_strlen((string) $list->tokens[$idx]->value, 'UTF-8'); } return $length; diff --git a/src/Utils/Misc.php b/src/Utils/Misc.php index 7e6297f..6fcc831 100644 --- a/src/Utils/Misc.php +++ b/src/Utils/Misc.php @@ -1,8 +1,8 @@ <?php - /** * Miscellaneous utilities. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Utils; @@ -11,10 +11,6 @@ use PhpMyAdmin\SqlParser\Statements\SelectStatement; /** * Miscellaneous utilities. - * - * @category Misc - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class Misc { @@ -32,12 +28,12 @@ class Misc || empty($statement->expr) || empty($statement->from) ) { - return array(); + return []; } - $retval = array(); + $retval = []; - $tables = array(); + $tables = []; /** * Expressions that may contain aliases. @@ -59,26 +55,26 @@ class Misc continue; } - $thisDb = (isset($expr->database) && ($expr->database !== '')) ? + $thisDb = isset($expr->database) && ($expr->database !== '') ? $expr->database : $database; if (! isset($retval[$thisDb])) { - $retval[$thisDb] = array( + $retval[$thisDb] = [ 'alias' => null, - 'tables' => array() - ); + 'tables' => [], + ]; } if (! isset($retval[$thisDb]['tables'][$expr->table])) { - $retval[$thisDb]['tables'][$expr->table] = array( - 'alias' => (isset($expr->alias) && ($expr->alias !== '')) ? + $retval[$thisDb]['tables'][$expr->table] = [ + 'alias' => isset($expr->alias) && ($expr->alias !== '') ? $expr->alias : null, - 'columns' => array() - ); + 'columns' => [], + ]; } if (! isset($tables[$thisDb])) { - $tables[$thisDb] = array(); + $tables[$thisDb] = []; } $tables[$thisDb][$expr->alias] = $expr->table; } @@ -89,7 +85,7 @@ class Misc continue; } - $thisDb = (isset($expr->database) && ($expr->database !== '')) ? + $thisDb = isset($expr->database) && ($expr->database !== '') ? $expr->database : $database; if (isset($expr->table) && ($expr->table !== '')) { diff --git a/src/Utils/Query.php b/src/Utils/Query.php index 2e623aa..837e8f7 100644 --- a/src/Utils/Query.php +++ b/src/Utils/Query.php @@ -1,8 +1,8 @@ <?php - /** * Statement utilities. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Utils; @@ -35,10 +35,6 @@ use PhpMyAdmin\SqlParser\TokensList; /** * Statement utilities. - * - * @category Statement - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class Query { @@ -47,7 +43,7 @@ class Query * * @var array */ - public static $FUNCTIONS = array( + public static $FUNCTIONS = [ 'SUM', 'AVG', 'STD', @@ -55,10 +51,10 @@ class Query 'MIN', 'MAX', 'BIT_OR', - 'BIT_AND' - ); + 'BIT_AND', + ]; - public static $ALLFLAGS = array( + public static $ALLFLAGS = [ /* * select ... DISTINCT ... */ @@ -211,8 +207,8 @@ class Query /* * ... UNION ... */ - 'union' => false - ); + 'union' => false, + ]; /** * Gets an array with flags select statement has. @@ -300,7 +296,7 @@ class Query */ public static function getFlags($statement, $all = false) { - $flags = array('querytype' => false); + $flags = ['querytype' => false]; if ($all) { $flags = self::$ALLFLAGS; } @@ -416,18 +412,18 @@ class Query $ret['statement'] = $statement; if ($statement instanceof SelectStatement) { - $ret['select_tables'] = array(); - $ret['select_expr'] = array(); + $ret['select_tables'] = []; + $ret['select_expr'] = []; // Finding tables' aliases and their associated real names. - $tableAliases = array(); + $tableAliases = []; foreach ($statement->from as $expr) { if (isset($expr->table, $expr->alias) && ($expr->table !== '') && ($expr->alias !== '') ) { - $tableAliases[$expr->alias] = array( + $tableAliases[$expr->alias] = [ $expr->table, - isset($expr->database) ? $expr->database : null - ); + isset($expr->database) ? $expr->database : null, + ]; } } @@ -439,11 +435,11 @@ class Query if (isset($tableAliases[$expr->table])) { $arr = $tableAliases[$expr->table]; } else { - $arr = array( + $arr = [ $expr->table, - (isset($expr->database) && ($expr->database !== '')) ? - $expr->database : null - ); + isset($expr->database) && ($expr->database !== '') ? + $expr->database : null, + ]; } if (! in_array($arr, $ret['select_tables'])) { $ret['select_tables'][] = $arr; @@ -459,11 +455,11 @@ class Query if (empty($ret['select_tables'])) { foreach ($statement->from as $expr) { if (isset($expr->table) && ($expr->table !== '')) { - $arr = array( + $arr = [ $expr->table, - (isset($expr->database) && ($expr->database !== '')) ? - $expr->database : null - ); + isset($expr->database) && ($expr->database !== '') ? + $expr->database : null, + ]; if (! in_array($arr, $ret['select_tables'])) { $ret['select_tables'][] = $arr; } @@ -484,12 +480,12 @@ class Query */ public static function getTables($statement) { - $expressions = array(); + $expressions = []; if (($statement instanceof InsertStatement) || ($statement instanceof ReplaceStatement) ) { - $expressions = array($statement->into->dest); + $expressions = [$statement->into->dest]; } elseif ($statement instanceof UpdateStatement) { $expressions = $statement->tables; } elseif (($statement instanceof SelectStatement) @@ -499,11 +495,11 @@ class Query } elseif (($statement instanceof AlterStatement) || ($statement instanceof TruncateStatement) ) { - $expressions = array($statement->table); + $expressions = [$statement->table]; } elseif ($statement instanceof DropStatement) { if (! $statement->options->has('TABLE')) { // No tables are dropped. - return array(); + return []; } $expressions = $statement->fields; } elseif ($statement instanceof RenameStatement) { @@ -512,7 +508,7 @@ class Query } } - $ret = array(); + $ret = []; foreach ($expressions as $expr) { if (! empty($expr->table)) { $expr->expr = null; // Force rebuild. @@ -796,11 +792,11 @@ class Query // No statement was found so we return the entire query as being the // remaining part. if (! $fullStatement) { - return array( + return [ null, $query, - $delimiter - ); + $delimiter, + ]; } // At least one query was found so we have to build the rest of the @@ -810,11 +806,11 @@ class Query $query .= $list->tokens[$list->idx]->token; } - return array( + return [ trim($statement), $query, - $delimiter - ); + $delimiter, + ]; } /** diff --git a/src/Utils/Routine.php b/src/Utils/Routine.php index 9b075dc..7c024c5 100644 --- a/src/Utils/Routine.php +++ b/src/Utils/Routine.php @@ -1,8 +1,8 @@ <?php - /** * Routine utilities. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Utils; @@ -14,10 +14,6 @@ use PhpMyAdmin\SqlParser\Statements\CreateStatement; /** * Routine utilities. - * - * @category Routines - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class Routine { @@ -36,27 +32,27 @@ class Routine $type = DataType::parse(new Parser(), $lexer->list); if ($type === null) { - return array( + return [ + '', '', '', '', '', - '' - ); + ]; } - $options = array(); + $options = []; foreach ($type->options->options as $opt) { $options[] = is_string($opt) ? $opt : $opt['value']; } - return array( + return [ '', '', $type->name, implode(',', $type->parameters), - implode(' ', $options) - ); + implode(' ', $options), + ]; } /** @@ -74,29 +70,29 @@ class Routine $param = ParameterDefinition::parse(new Parser(), $lexer->list); if (empty($param[0])) { - return array( + return [ + '', '', '', '', '', - '' - ); + ]; } $param = $param[0]; - $options = array(); + $options = []; foreach ($param->type->options->options as $opt) { $options[] = is_string($opt) ? $opt : $opt['value']; } - return array( + return [ empty($param->inOut) ? '' : $param->inOut, $param->name, $param->type->name, implode(',', $param->type->parameters), - implode(' ', $options) - ); + implode(' ', $options), + ]; } /** @@ -108,15 +104,15 @@ class Routine */ public static function getParameters($statement) { - $retval = array( + $retval = [ 'num' => 0, - 'dir' => array(), - 'name' => array(), - 'type' => array(), - 'length' => array(), - 'length_arr' => array(), - 'opts' => array() - ); + 'dir' => [], + 'name' => [], + 'type' => [], + 'length' => [], + 'length_arr' => [], + 'opts' => [], + ]; if (! empty($statement->parameters)) { $idx = 0; @@ -126,7 +122,7 @@ class Routine $retval['type'][$idx] = $param->type->name; $retval['length'][$idx] = implode(',', $param->type->parameters); $retval['length_arr'][$idx] = $param->type->parameters; - $retval['opts'][$idx] = array(); + $retval['opts'][$idx] = []; foreach ($param->type->options->options as $opt) { $retval['opts'][$idx][] = is_string($opt) ? $opt : $opt['value']; diff --git a/src/Utils/Table.php b/src/Utils/Table.php index e73e430..168061d 100644 --- a/src/Utils/Table.php +++ b/src/Utils/Table.php @@ -1,8 +1,8 @@ <?php - /** * Table utilities. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Utils; @@ -10,10 +10,6 @@ use PhpMyAdmin\SqlParser\Statements\CreateStatement; /** * Table utilities. - * - * @category Statement - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class Table { @@ -30,25 +26,25 @@ class Table || (! is_array($statement->fields)) || (! $statement->options->has('TABLE')) ) { - return array(); + return []; } - $ret = array(); + $ret = []; foreach ($statement->fields as $field) { if (empty($field->key) || ($field->key->type !== 'FOREIGN KEY')) { continue; } - $columns = array(); + $columns = []; foreach ($field->key->columns as $column) { $columns[] = $column['name']; } - $tmp = array( + $tmp = [ 'constraint' => $field->name, - 'index_list' => $columns - ); + 'index_list' => $columns, + ]; if (! empty($field->references)) { $tmp['ref_db_name'] = $field->references->table->database; @@ -87,10 +83,10 @@ class Table || (! is_array($statement->fields)) || (! $statement->options->has('TABLE')) ) { - return array(); + return []; } - $ret = array(); + $ret = []; foreach ($statement->fields as $field) { // Skipping keys. @@ -98,10 +94,10 @@ class Table continue; } - $ret[$field->name] = array( + $ret[$field->name] = [ 'type' => $field->type->name, - 'timestamp_not_null' => false - ); + 'timestamp_not_null' => false, + ]; if ($field->options) { if ($field->type->name === 'TIMESTAMP') { diff --git a/src/Utils/Tokens.php b/src/Utils/Tokens.php index 9166085..e823114 100644 --- a/src/Utils/Tokens.php +++ b/src/Utils/Tokens.php @@ -1,8 +1,8 @@ <?php - /** * Token utilities. */ +declare(strict_types=1); namespace PhpMyAdmin\SqlParser\Utils; @@ -12,10 +12,6 @@ use PhpMyAdmin\SqlParser\TokensList; /** * Token utilities. - * - * @category Token - * - * @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+ */ class Tokens { @@ -44,7 +40,7 @@ class Tokens } if (isset($pattern['value_str']) - && strcasecmp($pattern['value_str'], $token->value) + && strcasecmp($pattern['value_str'], (string) $token->value) ) { return false; } @@ -85,7 +81,7 @@ class Tokens * * @var array */ - $newList = array(); + $newList = []; /** * The length of the find pattern is calculated only once. |