* Support php 5.3 for sql parser lib.

This commit is contained in:
qixinzhi
2023-02-10 11:24:24 +08:00
parent 7c2e937eda
commit 7c122a0b29
648 changed files with 13815 additions and 279048 deletions
@@ -1,10 +1,9 @@
<?php
/**
* `SET` keyword parser.
*/
declare(strict_types=1);
namespace PhpMyAdmin\SqlParser\Components;
use PhpMyAdmin\SqlParser\Component;
@@ -12,14 +11,12 @@ use PhpMyAdmin\SqlParser\Parser;
use PhpMyAdmin\SqlParser\Token;
use PhpMyAdmin\SqlParser\TokensList;
use function implode;
use function is_array;
use function trim;
/**
* `SET` keyword parser.
*
* @final
* @category Keywords
*
* @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+
*/
class SetOperation extends Component
{
@@ -38,6 +35,8 @@ class SetOperation extends Component
public $value;
/**
* Constructor.
*
* @param string $column Field's name..
* @param string $value new value
*/
@@ -54,11 +53,11 @@ class SetOperation extends Component
*
* @return SetOperation[]
*/
public static function parse(Parser $parser, TokensList $list, array $options = [])
public static function parse(Parser $parser, TokensList $list, array $options = array())
{
$ret = [];
$ret = array();
$expr = new static();
$expr = new self();
/**
* The state of the parser.
@@ -100,8 +99,7 @@ class SetOperation extends Component
}
// No keyword is expected.
if (
($token->type === Token::TYPE_KEYWORD)
if (($token->type === Token::TYPE_KEYWORD)
&& ($token->flags & Token::FLAG_KEYWORD_RESERVED)
&& ($state === 0)
) {
@@ -120,22 +118,22 @@ class SetOperation extends Component
$tmp = Expression::parse(
$parser,
$list,
['breakOnAlias' => true]
array(
'breakOnAlias' => true
)
);
if ($tmp === null) {
if (is_null($tmp)) {
$parser->error('Missing expression.', $token);
break;
}
$expr->column = trim($expr->column);
$expr->value = $tmp->expr;
$ret[] = $expr;
$expr = new static();
$expr = new self();
$state = 0;
$commaLastSeenAt = null;
}
}
--$list->idx;
// We saw a comma, but didn't see a column-value pair after it
@@ -152,7 +150,7 @@ class SetOperation extends Component
*
* @return string
*/
public static function build($component, array $options = [])
public static function build($component, array $options = array())
{
if (is_array($component)) {
return implode(', ', $component);