Skip to content

Commit

Permalink
Merge branch '5.9.x'
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <[email protected]>
  • Loading branch information
MauricioFauth committed Jan 20, 2024
2 parents 04a9299 + c644e93 commit 43c45e2
Show file tree
Hide file tree
Showing 29 changed files with 6,197 additions and 48 deletions.
10 changes: 0 additions & 10 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -830,16 +830,6 @@ parameters:
count: 2
path: src/Utils/CLI.php

-
message: "#^Cannot access property \\$position on PhpMyAdmin\\\\SqlParser\\\\Token\\|null\\.$#"
count: 1
path: src/Utils/Error.php

-
message: "#^Cannot access property \\$token on PhpMyAdmin\\\\SqlParser\\\\Token\\|null\\.$#"
count: 1
path: src/Utils/Error.php

-
message: "#^Argument of an invalid type array\\<int, array\\<string, int\\|string\\>\\>\\|bool\\|string supplied for foreach, only iterables are supported\\.$#"
count: 1
Expand Down
24 changes: 20 additions & 4 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,16 @@
<code>ContextMariaDb110200</code>
</UnusedClass>
</file>
<file src="src/Contexts/ContextMariaDb110300.php">
<UnusedClass>
<code>ContextMariaDb110300</code>
</UnusedClass>
</file>
<file src="src/Contexts/ContextMariaDb110400.php">
<UnusedClass>
<code>ContextMariaDb110400</code>
</UnusedClass>
</file>
<file src="src/Contexts/ContextMySql50000.php">
<UnusedClass>
<code>ContextMySql50000</code>
Expand Down Expand Up @@ -631,6 +641,16 @@
<code>ContextMySql80100</code>
</UnusedClass>
</file>
<file src="src/Contexts/ContextMySql80200.php">
<UnusedClass>
<code>ContextMySql80200</code>
</UnusedClass>
</file>
<file src="src/Contexts/ContextMySql80300.php">
<UnusedClass>
<code>ContextMySql80300</code>
</UnusedClass>
</file>
<file src="src/Lexer.php">
<LoopInvalidation>
<code><![CDATA[$this->last]]></code>
Expand Down Expand Up @@ -1294,10 +1314,6 @@
<code>$err[1]</code>
<code>$err[3]</code>
</PossiblyNullArgument>
<PossiblyNullPropertyFetch>
<code><![CDATA[$err->token->position]]></code>
<code><![CDATA[$err->token->token]]></code>
</PossiblyNullPropertyFetch>
<RedundantConditionGivenDocblockType>
<code>$obj instanceof Parser</code>
</RedundantConditionGivenDocblockType>
Expand Down
6 changes: 1 addition & 5 deletions src/Components/AlterOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,7 @@ final class AlterOperation implements Component, Parseable
'ON COMPLETION PRESERVE' => 5,
'ON COMPLETION NOT PRESERVE' => 5,
'RENAME' => 6,
'TO' => [
7,
'expr',
['parseField' => 'table'],
],
'TO' => [7, 'expr', ['parseField' => 'table', 'breakOnAlias' => true]],
'ENABLE' => 8,
'DISABLE' => 8,
'DISABLE ON SLAVE' => 8,
Expand Down
5 changes: 4 additions & 1 deletion src/Components/Expression.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,10 @@ public static function parse(Parser $parser, TokensList $list, array $options =
}

$isExpr = true;
} elseif ($brackets === 0 && strlen((string) $ret->expr) > 0 && ! $alias) {
} elseif (
$brackets === 0 && strlen((string) $ret->expr) > 0 && ! $alias
&& ($ret->table === null || $ret->table === '')
) {
/* End of expression */
break;
}
Expand Down
357 changes: 357 additions & 0 deletions src/Contexts/ContextMariaDb110300.php

Large diffs are not rendered by default.

357 changes: 357 additions & 0 deletions src/Contexts/ContextMariaDb110400.php

Large diffs are not rendered by default.

357 changes: 357 additions & 0 deletions src/Contexts/ContextMySql80200.php

Large diffs are not rendered by default.

357 changes: 357 additions & 0 deletions src/Contexts/ContextMySql80300.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Statements/LoadStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public function parse(Parser $parser, TokensList $list): void
}

++$list->idx;
$this->table = Expression::parse($parser, $list, ['parseField' => 'table']);
$this->table = Expression::parse($parser, $list, ['parseField' => 'table', 'breakOnAlias' => true]);
$state = 3;
} elseif ($state >= 3 && $state <= 7) {
if ($token->type === TokenType::Keyword) {
Expand Down
4 changes: 4 additions & 0 deletions src/Tools/ContextGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class ContextGenerator
'MySql50700' => 'https://dev.mysql.com/doc/refman/5.7/en/keywords.html',
'MySql80000' => 'https://dev.mysql.com/doc/refman/8.0/en/keywords.html',
'MySql80100' => 'https://dev.mysql.com/doc/refman/8.1/en/keywords.html',
'MySql80200' => 'https://dev.mysql.com/doc/refman/8.2/en/keywords.html',
'MySql80300' => 'https://dev.mysql.com/doc/refman/8.3/en/keywords.html',
'MariaDb100000' => 'https://mariadb.com/kb/en/reserved-words/',
'MariaDb100100' => 'https://mariadb.com/kb/en/reserved-words/',
'MariaDb100200' => 'https://mariadb.com/kb/en/reserved-words/',
Expand All @@ -77,6 +79,8 @@ class ContextGenerator
'MariaDb110000' => 'https://mariadb.com/kb/en/reserved-words/',
'MariaDb110100' => 'https://mariadb.com/kb/en/reserved-words/',
'MariaDb110200' => 'https://mariadb.com/kb/en/reserved-words/',
'MariaDb110300' => 'https://mariadb.com/kb/en/reserved-words/',
'MariaDb110400' => 'https://mariadb.com/kb/en/reserved-words/',
];

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Utils/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public static function get(array $objs): array
$ret[] = [
$err->getMessage(),
$err->getCode(),
$err->token->token,
$err->token->position,
$err->token?->token ?? '',
$err->token?->position,
];
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/Misc/BugsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public static function bugProvider(): array
['bugs/gh412'],
['bugs/gh478'],
['bugs/gh492'],
['bugs/gh496'],
['bugs/gh498'],
['bugs/gh499'],
['bugs/gh508'],
Expand Down
14 changes: 14 additions & 0 deletions tests/Utils/ErrorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ public function testGet(): void
);
}

public function testGetWithNullToken(): void
{
$lexer = new Lexer('LOCK TABLES table1 AS `t1` LOCAL');
$parser = new Parser($lexer->list);
$this->assertSame(
[
['An alias was previously found.', 0, 'LOCAL', 27],
['Unexpected keyword.', 0, 'LOCAL', 27],
['Unexpected end of LOCK expression.', 0, '', null],
],
Error::get([$lexer, $parser]),
);
}

public function testFormat(): void
{
$this->assertEquals(
Expand Down
3 changes: 3 additions & 0 deletions tests/data/bugs/gh496.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT COUNT(*) AS amount
FROM one i
JOIN two io ON io.id = i.id
Loading

0 comments on commit 43c45e2

Please sign in to comment.