Skip to content

Commit 95df5e0

Browse files
committed
Merge branch 'master' into 6.0.x
Signed-off-by: William Desportes <williamdes@wdes.fr>
2 parents ff440a0 + c8a83aa commit 95df5e0

File tree

359 files changed

+4819
-70
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

359 files changed

+4819
-70
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ phpstan-baseline.neon export-ignore
1212
psalm.xml export-ignore
1313
psalm-baseline.xml export-ignore
1414
CODE_OF_CONDUCT.md export-ignore
15+
CONTRIBUTING.md export-ignore

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
custom: https://www.phpmyadmin.net/donate/

.github/workflows/lint-and-analyse-php.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,6 @@ jobs:
6262
- name: Analyse files with PHPStan
6363
run: composer run phpstan
6464
- name: Analyse files with Psalm
65+
# Allow the previous check to fail but not abort
66+
if: always()
6567
run: composer run psalm -- --shepherd

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Change Log
22

3-
## [5.6.0] - YYYY-MM-DD
3+
## [5.x.x] - YYYY-MM-DD
4+
5+
* Performance improvement to use less the `nextToken()` function (#397)
6+
* Lexer - Solving ambiguity on function keywords (#385)
7+
8+
## [5.6.0] - 2023-01-02
49

510
* Add missing return types annotations
611
* Improve the WITH statements parser (#363)
@@ -16,6 +21,7 @@
1621
* Implement the `EXPLAIN` Parser (#389)
1722
* Context: Updated contexts to contain `multipoint` and `multipolygon` data types (#393)
1823
* Support more keywords on `Expression` component (#399)
24+
* Fix PHP 8.3 failing tests (#400)
1925

2026
## [5.5.0] - 2021-12-08
2127

composer.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "phpmyadmin/sql-parser",
33
"description": "A validating SQL lexer and parser with a focus on MySQL dialect.",
44
"license": "GPL-2.0-or-later",
5-
"keywords": ["sql", "lexer", "parser", "analysis"],
5+
"keywords": ["sql", "lexer", "parser", "analysis", "sql syntax highlighter", "sql lexer", "sql tokenizer", "sql parser", "sql linter", "query linter"],
66
"homepage": "https://github.com/phpmyadmin/sql-parser",
77
"authors": [
88
{
@@ -15,6 +15,12 @@
1515
"issues": "https://github.com/phpmyadmin/sql-parser/issues",
1616
"source": "https://github.com/phpmyadmin/sql-parser"
1717
},
18+
"funding": [
19+
{
20+
"type": "other",
21+
"url": "https://www.phpmyadmin.net/donate/"
22+
}
23+
],
1824
"require": {
1925
"php": "^7.2.5 || ^8.0",
2026
"symfony/polyfill-mbstring": "^1.3",

phpcs.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
<rule ref="Squiz.Arrays.ArrayDeclaration.IndexNoNewline">
3030
<exclude-pattern>src/Contexts/*</exclude-pattern>
31+
<exclude-pattern>tests/Tools/templates/*</exclude-pattern>
3132
</rule>
3233

3334
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName">

phpstan-baseline.neon

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,16 @@ parameters:
530530
count: 1
531531
path: src/Exceptions/ParserException.php
532532

533+
-
534+
message: "#^Cannot access property \\$type on PhpMyAdmin\\\\SqlParser\\\\Token\\|null\\.$#"
535+
count: 2
536+
path: src/Lexer.php
537+
538+
-
539+
message: "#^Cannot access property \\$value on PhpMyAdmin\\\\SqlParser\\\\Token\\|null\\.$#"
540+
count: 3
541+
path: src/Lexer.php
542+
533543
-
534544
message: "#^Parameter \\#1 \\$msg \\(string\\) of method PhpMyAdmin\\\\SqlParser\\\\Lexer\\:\\:error\\(\\) should be compatible with parameter \\$error \\(Exception\\) of method PhpMyAdmin\\\\SqlParser\\\\Core\\:\\:error\\(\\)$#"
535545
count: 1
@@ -1150,8 +1160,18 @@ parameters:
11501160
count: 2
11511161
path: tests/Components/CreateDefinitionTest.php
11521162

1163+
-
1164+
message: "#^Cannot access property \\$alias on PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|null\\.$#"
1165+
count: 2
1166+
path: tests/Components/ExpressionTest.php
1167+
11531168
-
11541169
message: "#^Cannot access property \\$expr on PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|null\\.$#"
1170+
count: 4
1171+
path: tests/Components/ExpressionTest.php
1172+
1173+
-
1174+
message: "#^Cannot access property \\$table on PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|null\\.$#"
11551175
count: 2
11561176
path: tests/Components/ExpressionTest.php
11571177

phpunit.xml.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
<testsuite name="Utils">
3535
<directory suffix=".php">./tests/Utils</directory>
3636
</testsuite>
37+
<testsuite name="Tools">
38+
<directory suffix=".php">./tests/Tools</directory>
39+
</testsuite>
3740
</testsuites>
3841
<filter>
3942
<whitelist processUncoveredFilesFromWhitelist="true">

psalm-baseline.xml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,12 @@
793793
<PossiblyNullPropertyAssignmentValue occurrences="1">
794794
<code>null</code>
795795
</PossiblyNullPropertyAssignmentValue>
796+
<PossiblyNullPropertyFetch occurrences="4">
797+
<code>$next-&gt;type</code>
798+
<code>$next-&gt;value</code>
799+
<code>$next-&gt;value</code>
800+
<code>$next-&gt;value</code>
801+
</PossiblyNullPropertyFetch>
796802
<RedundantCondition occurrences="1">
797803
<code>USE_UTF_STRINGS</code>
798804
</RedundantCondition>
@@ -1027,11 +1033,6 @@
10271033
<PropertyNotSetInConstructor occurrences="1">
10281034
<code>$statementAlias</code>
10291035
</PropertyNotSetInConstructor>
1030-
<UnusedVariable occurrences="3">
1031-
<code>$connectionToken</code>
1032-
<code>$currToken</code>
1033-
<code>$forToken</code>
1034-
</UnusedVariable>
10351036
</file>
10361037
<file src="src/Statements/InsertStatement.php">
10371038
<PossiblyNullOperand occurrences="2">
@@ -1532,9 +1533,15 @@
15321533
</UndefinedMethod>
15331534
</file>
15341535
<file src="tests/Components/ExpressionTest.php">
1535-
<PossiblyNullPropertyFetch occurrences="2">
1536+
<PossiblyNullPropertyFetch occurrences="8">
1537+
<code>$component-&gt;alias</code>
1538+
<code>$component-&gt;alias</code>
1539+
<code>$component-&gt;expr</code>
1540+
<code>$component-&gt;expr</code>
15361541
<code>$component-&gt;expr</code>
15371542
<code>$component-&gt;expr</code>
1543+
<code>$component-&gt;table</code>
1544+
<code>$component-&gt;table</code>
15381545
</PossiblyNullPropertyFetch>
15391546
</file>
15401547
<file src="tests/Components/JoinKeywordTest.php">

src/Components/AlterOperation.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -347,12 +347,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
347347
}
348348
} elseif (! self::checkIfTokenQuotedSymbol($token)) {
349349
if (! empty(Parser::$statementParsers[$token->value])) {
350-
// We want to get the next non-comment and non-space token after $token
351-
// therefore, the first getNext call will start with the current $idx which's $token,
352-
// will return it and increase $idx by 1, which's not guaranteed to be non-comment
353-
// and non-space, that's why we're calling getNext again.
354-
355-
$list->getNext();
350+
$list->idx++; // Ignore the current token
356351
$nextToken = $list->getNext();
357352

358353
if ($token->value === 'SET' && $nextToken !== null && $nextToken->value === '(') {
@@ -385,12 +380,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
385380
$ret->unknown[] = $token;
386381
} elseif ($state === 3) {
387382
if ($partitionState === 0) {
388-
// We want to get the next non-comment and non-space token after $token
389-
// therefore, the first getNext call will start with the current $idx which's $token,
390-
// will return it and increase $idx by 1, which's not guaranteed to be non-comment
391-
// and non-space, that's why we're calling getNext again.
392-
393-
$list->getNext();
383+
$list->idx++; // Ignore the current token
394384
$nextToken = $list->getNext();
395385
if (
396386
($token->type === Token::TYPE_KEYWORD)

0 commit comments

Comments
 (0)