Skip to content

Commit 7974af9

Browse files
committed
Merge branch 'master' into 6.0.x
Signed-off-by: Maurício Meneghini Fauth <[email protected]>
2 parents f4753fd + 43fb5bd commit 7974af9

File tree

84 files changed

+478
-372
lines changed

Some content is hidden

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

84 files changed

+478
-372
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
* Add missing return types annotations
66
* Improve the WITH statements parser (#363)
7+
* Add support for passing `Context::SQL_MODE*` constants to `Context::setMode` method
8+
* Deprecate passing strings to the `Context::setMode` method
79

810
## [5.5.0] - 2021-12-08
911

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ composer require phpmyadmin/sql-parser
2424

2525
## Documentation
2626

27-
The API documentation is available at
27+
The API documentation is available at
2828
<https://develdocs.phpmyadmin.net/sql-parser/>.
2929

3030
## Usage
@@ -96,7 +96,7 @@ $query2 = $statement->build();
9696
var_dump($query2); // outputs string(19) 'SELECT * FROM `b` '
9797

9898
// Change SQL mode
99-
PhpMyAdmin\SqlParser\Context::setMode('ANSI_QUOTES');
99+
PhpMyAdmin\SqlParser\Context::setMode(PhpMyAdmin\SqlParser\Context::SQL_MODE_ANSI_QUOTES);
100100

101101
// build the query again using different quotes
102102
$query2 = $statement->build();

infection.json.dist

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
]
66
},
77
"logs": {
8-
"badge": {
9-
"branch": "master"
8+
"text": "build/logs/infection.log",
9+
"stryker": {
10+
"report": "master"
1011
}
1112
},
1213
"mutators": {

phpstan-baseline.neon

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,25 @@ parameters:
5656
path: src/Components/ArrayObj.php
5757

5858
-
59-
message: "#^Array \\(array\\<PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\>\\) does not accept PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|null\\.$#"
60-
count: 3
59+
message: "#^Binary operation \"\\.\" between ' AS ' and array\\<string\\>\\|string results in an error\\.$#"
60+
count: 1
6161
path: src/Components/CaseExpression.php
6262

6363
-
64-
message: "#^Binary operation \"\\.\" between ' AS ' and array\\<string\\>\\|string results in an error\\.$#"
64+
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\CaseExpression\\:\\:\\$alias \\(string\\|null\\) does not accept mixed\\.$#"
6565
count: 1
6666
path: src/Components/CaseExpression.php
6767

6868
-
69-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\CaseExpression\\:\\:\\$alias \\(string\\|null\\) does not accept mixed\\.$#"
69+
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\CaseExpression\\:\\:\\$compareValues \\(array\\<PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\>\\) does not accept array\\<PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|null\\>\\.$#"
7070
count: 1
7171
path: src/Components/CaseExpression.php
7272

73+
-
74+
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\CaseExpression\\:\\:\\$results \\(array\\<PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\>\\) does not accept array\\<PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|null\\>\\.$#"
75+
count: 2
76+
path: src/Components/CaseExpression.php
77+
7378
-
7479
message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\Condition\\:\\:build\\(\\) expects array\\<PhpMyAdmin\\\\SqlParser\\\\Components\\\\Condition\\>, \\$this\\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\Condition\\) given\\.$#"
7580
count: 1
@@ -266,17 +271,17 @@ parameters:
266271
path: src/Components/JoinKeyword.php
267272

268273
-
269-
message: "#^Array \\(array\\<array\\{name\\?\\: string, length\\?\\: int, order\\?\\: string\\}\\>\\) does not accept non\\-empty\\-array\\<string, mixed\\>\\.$#"
274+
message: "#^Binary operation \"\\.\" between array\\<string\\>\\|string and ' ' results in an error\\.$#"
270275
count: 1
271276
path: src/Components/Key.php
272277

273278
-
274-
message: "#^Binary operation \"\\.\" between array\\<string\\>\\|string and ' ' results in an error\\.$#"
279+
message: "#^Binary operation \"\\.\\=\" between '' and array\\<string\\>\\|string results in an error\\.$#"
275280
count: 1
276281
path: src/Components/Key.php
277282

278283
-
279-
message: "#^Binary operation \"\\.\\=\" between '' and array\\<string\\>\\|string results in an error\\.$#"
284+
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\Key\\:\\:\\$columns \\(array\\<array\\{name\\?\\: string, length\\?\\: int, order\\?\\: string\\}\\>\\) does not accept non\\-empty\\-array\\<array\\<string, mixed\\>\\>\\.$#"
280285
count: 1
281286
path: src/Components/Key.php
282287

@@ -360,6 +365,11 @@ parameters:
360365
count: 1
361366
path: src/Components/OptionsArray.php
362367

368+
-
369+
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\:\\:\\$options \\(array\\<int, mixed\\>\\) does not accept array\\<int\\|string, mixed\\>\\.$#"
370+
count: 8
371+
path: src/Components/OptionsArray.php
372+
363373
-
364374
message: "#^Right side of && is always true\\.$#"
365375
count: 1
@@ -530,19 +540,14 @@ parameters:
530540
count: 1
531541
path: src/Lexer.php
532542

533-
-
534-
message: "#^Array \\(array\\<PhpMyAdmin\\\\SqlParser\\\\Statements\\\\SelectStatement\\>\\) does not accept array\\<int, PhpMyAdmin\\\\SqlParser\\\\Statements\\\\SelectStatement\\|string\\|true\\>\\.$#"
535-
count: 1
536-
path: src/Parser.php
537-
538543
-
539544
message: "#^Cannot access property \\$count on PhpMyAdmin\\\\SqlParser\\\\TokensList\\|null\\.$#"
540545
count: 1
541546
path: src/Parser.php
542547

543548
-
544549
message: "#^Cannot access property \\$idx on PhpMyAdmin\\\\SqlParser\\\\TokensList\\|null\\.$#"
545-
count: 7
550+
count: 8
546551
path: src/Parser.php
547552

548553
-
@@ -565,6 +570,11 @@ parameters:
565570
count: 3
566571
path: src/Parser.php
567572

573+
-
574+
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\SelectStatement\\:\\:\\$union \\(array\\<PhpMyAdmin\\\\SqlParser\\\\Statements\\\\SelectStatement\\>\\) does not accept array\\<array\\<int, bool\\|PhpMyAdmin\\\\SqlParser\\\\Statements\\\\SelectStatement\\|string\\>\\|PhpMyAdmin\\\\SqlParser\\\\Statements\\\\SelectStatement\\>\\.$#"
575+
count: 1
576+
path: src/Parser.php
577+
568578
-
569579
message: "#^Cannot access property \\$type on PhpMyAdmin\\\\SqlParser\\\\Token\\|null\\.$#"
570580
count: 1
@@ -1161,7 +1171,7 @@ parameters:
11611171
path: tests/Parser/WithStatementTest.php
11621172

11631173
-
1164-
message: "#^Cannot access offset int on non\\-empty\\-array\\<int, string\\>\\|false\\.$#"
1174+
message: "#^Cannot access offset int\\<0, max\\> on non\\-empty\\-array\\<int, string\\>\\|false\\.$#"
11651175
count: 1
11661176
path: tests/Utils/BufferedQueryTest.php
11671177

psalm-baseline.xml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="4.18.0.0">
2+
<files psalm-version="4.18.1@dda05fa913f4dc6eb3386f2f7ce5a45d37a71bcb">
33
<file src="src/Components/AlterOperation.php">
44
<DocblockTypeContradiction occurrences="1">
55
<code>$component-&gt;field !== ''</code>
@@ -597,13 +597,9 @@
597597
<InvalidReturnType occurrences="1">
598598
<code>string|string[]</code>
599599
</InvalidReturnType>
600-
<MixedAssignment occurrences="2">
600+
<MixedAssignment occurrences="1">
601601
<code>self::$keywords</code>
602-
<code>static::$mode</code>
603602
</MixedAssignment>
604-
<MixedOperand occurrences="1">
605-
<code>constant('static::SQL_MODE_' . $m)</code>
606-
</MixedOperand>
607603
</file>
608604
<file src="src/Contexts/ContextMariaDb100000.php">
609605
<PropertyTypeCoercion occurrences="1"/>

src/Component.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
use Stringable;
88

99
/**
10-
* A component (of a statement) is a part of a statement that is common to multiple query types.
11-
*
1210
* Defines a component that is later extended to parse specialized components or keywords.
1311
*
14-
* There is a small difference between *Component and *Keyword classes: usually, *Component parsers can be reused
15-
* in multiple situations and *Keyword parsers count on the *Component classes to do their job.
12+
* There is a small difference between *Component and *Keyword classes: usually, *Component parsers can be reused in
13+
* multiple situations and *Keyword parsers count on the *Component classes to do their job.
14+
*
15+
* A component (of a statement) is a part of a statement that is common to multiple query types.
1616
*/
1717
interface Component extends Stringable
1818
{

src/Components/AlterOperation.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
<?php
2-
/**
3-
* Parses an alter operation.
4-
*/
52

63
declare(strict_types=1);
74

src/Components/Array2d.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
<?php
2-
/**
3-
* `VALUES` keyword parser.
4-
*/
52

63
declare(strict_types=1);
74

src/Components/ArrayObj.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
<?php
2-
/**
3-
* Parses an array.
4-
*/
52

63
declare(strict_types=1);
74

src/Components/CaseExpression.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
<?php
2-
/**
3-
* Parses a reference to a CASE expression.
4-
*/
52

63
declare(strict_types=1);
74

0 commit comments

Comments
 (0)