Skip to content

Commit 8d5f51f

Browse files
committed
Fixes old php versions
1 parent 581065b commit 8d5f51f

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/Components/WithKeyword.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@
1616
*/
1717
class WithKeyword extends Component
1818
{
19-
public string $name;
20-
public array $columns = [];
21-
public Parser $statement;
19+
/** @var string $statement */
20+
public $name;
21+
/** @var ArrayObj[] $statement */
22+
public $columns = [];
23+
/** @var Parser $statement */
24+
public $statement;
2225

2326
public function __construct(string $name)
2427
{

tests/Parser/WithStatementTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@ class WithStatementTest extends TestCase
1212
{
1313
public function testWith()
1414
{
15-
$lexer = new Lexer(<<<SQL
15+
$sql = <<<SQL
1616
WITH categories(identifier, name, parent_id) AS (
1717
SELECT c.identifier, c.name, c.parent_id FROM category c WHERE c.identifier = 'a'
1818
UNION ALL
1919
SELECT c.identifier, c.name, c.parent_id FROM categories, category c WHERE c.identifier = categories.parent_id
2020
), foo AS ( SELECT * FROM test )
2121
SELECT * FROM categories
22-
SQL
23-
);
22+
SQL;
23+
24+
$lexer = new Lexer($sql);
2425

2526
$lexerErrors = $this->getErrorsAsArray($lexer);
2627
$this->assertCount(0, $lexerErrors);
@@ -30,10 +31,11 @@ public function testWith()
3031
$this->assertCount(2, $parser->statements);
3132

3233
// phpcs:disable Generic.Files.LineLength.TooLong
33-
$this->assertEquals(<<<SQL
34+
$expected = <<<SQL
3435
WITH categories(identifier, name, parent_id) AS (SELECT c.identifier, c.name, c.parent_id FROM category AS `c` WHERE c.identifier = 'a' UNION ALL SELECT c.identifier, c.name, c.parent_id FROM categories, category AS `c` WHERE c.identifier = categories.parent_id), foo AS (SELECT * FROM test)
35-
SQL, $parser->statements[0]->build());
36+
SQL;
3637
// phpcs:enable
38+
$this->assertEquals($expected, $parser->statements[0]->build());
3739

3840
$this->assertEquals(<<<SQL
3941
SELECT * FROM categories

0 commit comments

Comments
 (0)