* 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,56 +1,60 @@
<?php
declare(strict_types=1);
namespace PhpMyAdmin\SqlParser\Tests\Components;
use PhpMyAdmin\SqlParser\Components\ArrayObj;
use PhpMyAdmin\SqlParser\Components\Expression;
use PhpMyAdmin\SqlParser\Parser;
use PhpMyAdmin\SqlParser\Tests\TestCase;
class ArrayObjTest extends TestCase
{
public function testBuildRaw()
public function testBuildRaw(): void
{
$component = new ArrayObj(array('a', 'b'), array());
$component = new ArrayObj(['a', 'b'], []);
$this->assertEquals('(a, b)', ArrayObj::build($component));
}
public function testBuildValues()
public function testBuildValues(): void
{
$component = new ArrayObj(array(), array('a', 'b'));
$component = new ArrayObj([], ['a', 'b']);
$this->assertEquals('(a, b)', ArrayObj::build($component));
}
public function testParseType()
public function testParseType(): void
{
$components = ArrayObj::parse(
new Parser(),
$this->getTokensList('(1 + 2, 3 + 4)'),
array(
'type' => 'PhpMyAdmin\\SqlParser\\Components\\Expression',
'typeOptions' => array(
'breakOnParentheses' => true,
)
)
[
'type' => Expression::class,
'typeOptions' => ['breakOnParentheses' => true],
]
);
$this->assertInstanceOf(Expression::class, $components[0]);
$this->assertInstanceOf(Expression::class, $components[1]);
$this->assertEquals($components[0]->expr, '1 + 2');
$this->assertEquals($components[1]->expr, '3 + 4');
}
/**
* @dataProvider parseProvider
*
* @param mixed $test
*/
public function testParse($test)
public function testParse(string $test): void
{
$this->runParserTest($test);
}
public function parseProvider()
/**
* @return string[][]
*/
public function parseProvider(): array
{
return array(
array('parser/parseArrayErr1'),
array('parser/parseArrayErr3')
);
return [
['parser/parseArrayErr1'],
['parser/parseArrayErr3'],
];
}
}