* Update sqlparser to fit php8.

This commit is contained in:
songchenxuan
2024-03-19 14:52:48 +08:00
parent 39f5d2905b
commit ea516fd9b3
663 changed files with 140347 additions and 16174 deletions
@@ -1,8 +1,6 @@
<?php
/**
* `REFERENCES` keyword parser.
*/
declare(strict_types=1);
namespace PhpMyAdmin\SqlParser\Components;
@@ -12,34 +10,36 @@ use PhpMyAdmin\SqlParser\Parser;
use PhpMyAdmin\SqlParser\Token;
use PhpMyAdmin\SqlParser\TokensList;
use function implode;
use function trim;
/**
* `REFERENCES` keyword parser.
*
* @category Keywords
*
* @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+
* @final
*/
class Reference extends Component
{
/**
* All references options.
*
* @var array
* @var array<string, int|array<int, int|string>>
* @psalm-var array<string, (positive-int|array{positive-int, ('var'|'var='|'expr'|'expr=')})>
*/
public static $REFERENCES_OPTIONS = array(
'MATCH' => array(
public static $REFERENCES_OPTIONS = [
'MATCH' => [
1,
'var',
),
'ON DELETE' => array(
],
'ON DELETE' => [
2,
'var',
),
'ON UPDATE' => array(
],
'ON UPDATE' => [
3,
'var',
)
);
],
];
/**
* The referenced table.
@@ -51,7 +51,7 @@ class Reference extends Component
/**
* The referenced columns.
*
* @var array
* @var string[]
*/
public $columns;
@@ -63,13 +63,11 @@ class Reference extends Component
public $options;
/**
* Constructor.
*
* @param Expression $table the name of the table referenced
* @param array $columns the columns referenced
* @param string[] $columns the columns referenced
* @param OptionsArray $options the options
*/
public function __construct($table = null, array $columns = array(), $options = null)
public function __construct($table = null, array $columns = [], $options = null)
{
$this->table = $table;
$this->columns = $columns;
@@ -77,15 +75,15 @@ class Reference extends Component
}
/**
* @param Parser $parser the parser that serves as context
* @param TokensList $list the list of tokens that are being parsed
* @param array $options parameters for parsing
* @param Parser $parser the parser that serves as context
* @param TokensList $list the list of tokens that are being parsed
* @param array<string, mixed> $options parameters for parsing
*
* @return Reference
*/
public static function parse(Parser $parser, TokensList $list, array $options = array())
public static function parse(Parser $parser, TokensList $list, array $options = [])
{
$ret = new self();
$ret = new static();
/**
* The state of the parser.
@@ -105,8 +103,6 @@ class Reference extends Component
for (; $list->idx < $list->count; ++$list->idx) {
/**
* Token parsed at this moment.
*
* @var Token
*/
$token = $list->tokens[$list->idx];
@@ -124,10 +120,10 @@ class Reference extends Component
$ret->table = Expression::parse(
$parser,
$list,
array(
[
'parseField' => 'table',
'breakOnAlias' => true
)
'breakOnAlias' => true,
]
);
$state = 1;
} elseif ($state === 1) {
@@ -146,12 +142,12 @@ class Reference extends Component
}
/**
* @param Reference $component the component to be built
* @param array $options parameters for building
* @param Reference $component the component to be built
* @param array<string, mixed> $options parameters for building
*
* @return string
*/
public static function build($component, array $options = array())
public static function build($component, array $options = [])
{
return trim(
$component->table