* 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
/**
* Routine utilities.
*/
declare(strict_types=1);
namespace PhpMyAdmin\SqlParser\Utils;
use PhpMyAdmin\SqlParser\Components\DataType;
@@ -13,11 +12,12 @@ use PhpMyAdmin\SqlParser\Lexer;
use PhpMyAdmin\SqlParser\Parser;
use PhpMyAdmin\SqlParser\Statements\CreateStatement;
use function implode;
use function is_string;
/**
* Routine utilities.
*
* @category Routines
*
* @license https://www.gnu.org/licenses/gpl-2.0.txt GPL-2.0+
*/
class Routine
{
@@ -36,27 +36,27 @@ class Routine
$type = DataType::parse(new Parser(), $lexer->list);
if ($type === null) {
return [
return array(
'',
'',
'',
'',
'',
];
''
);
}
$options = [];
$options = array();
foreach ($type->options->options as $opt) {
$options[] = is_string($opt) ? $opt : $opt['value'];
}
return [
return array(
'',
'',
$type->name,
implode(',', $type->parameters),
implode(' ', $options),
];
implode(' ', $options)
);
}
/**
@@ -74,29 +74,29 @@ class Routine
$param = ParameterDefinition::parse(new Parser(), $lexer->list);
if (empty($param[0])) {
return [
return array(
'',
'',
'',
'',
'',
];
''
);
}
$param = $param[0];
$options = [];
$options = array();
foreach ($param->type->options->options as $opt) {
$options[] = is_string($opt) ? $opt : $opt['value'];
}
return [
return array(
empty($param->inOut) ? '' : $param->inOut,
$param->name,
$param->type->name,
implode(',', $param->type->parameters),
implode(' ', $options),
];
implode(' ', $options)
);
}
/**
@@ -108,15 +108,15 @@ class Routine
*/
public static function getParameters($statement)
{
$retval = [
$retval = array(
'num' => 0,
'dir' => [],
'name' => [],
'type' => [],
'length' => [],
'length_arr' => [],
'opts' => [],
];
'dir' => array(),
'name' => array(),
'type' => array(),
'length' => array(),
'length_arr' => array(),
'opts' => array()
);
if (! empty($statement->parameters)) {
$idx = 0;
@@ -126,12 +126,11 @@ 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] = [];
$retval['opts'][$idx] = array();
foreach ($param->type->options->options as $opt) {
$retval['opts'][$idx][] = is_string($opt) ?
$opt : $opt['value'];
}
$retval['opts'][$idx] = implode(' ', $retval['opts'][$idx]);
++$idx;
}