Skip to content

Commit d47024b

Browse files
committed
Merge #444 - Update OptionsArray phpdoc & add tests for SET GLOBAL
2 parents a3a699d + 24d9cfa commit d47024b

8 files changed

Lines changed: 276 additions & 19 deletions

File tree

phpstan-baseline.neon

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -790,19 +790,9 @@ parameters:
790790
count: 1
791791
path: src/Statements/ReplaceStatement.php
792792

793-
-
794-
message: "#^PHPDoc type array\\<PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\>\\|null of property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\SetStatement\\:\\:\\$options is not covariant with PHPDoc type PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\|null of overridden property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$options\\.$#"
795-
count: 1
796-
path: src/Statements/SetStatement.php
797-
798793
-
799794
message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\:\\:build\\(\\) expects PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray, PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\|null given\\.$#"
800-
count: 1
801-
path: src/Statements/SetStatement.php
802-
803-
-
804-
message: "#^Parameter \\#1 \\$component of static method PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\:\\:build\\(\\) expects PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray, array\\<PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\>\\|null given\\.$#"
805-
count: 1
795+
count: 2
806796
path: src/Statements/SetStatement.php
807797

808798
-

psalm-baseline.xml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,14 +1087,9 @@
10871087
</PossiblyNullOperand>
10881088
</file>
10891089
<file src="src/Statements/SetStatement.php">
1090-
<InvalidArgument occurrences="1">
1091-
<code>$this-&gt;options</code>
1092-
</InvalidArgument>
1093-
<NonInvariantDocblockPropertyType occurrences="1">
1094-
<code>$options</code>
1095-
</NonInvariantDocblockPropertyType>
1096-
<PossiblyNullArgument occurrences="2">
1090+
<PossiblyNullArgument occurrences="3">
10971091
<code>$this-&gt;end_options</code>
1092+
<code>$this-&gt;options</code>
10981093
<code>$this-&gt;set</code>
10991094
</PossiblyNullArgument>
11001095
</file>

src/Statements/SetStatement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class SetStatement extends Statement
8282
/**
8383
* Options used in current statement.
8484
*
85-
* @var OptionsArray[]|null
85+
* @var OptionsArray|null
8686
*/
8787
public $options;
8888

tests/Parser/SetStatementTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public function setProvider(): array
3131
['parser/parseSetNamesError'],
3232
['parser/parseSetError1'],
3333
['parser/parseInsertIntoSet'],
34+
['parser/parseSetVariable'],
35+
['parser/parseSetGlobalVariable'],
3436
];
3537
}
3638
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SET GLOBAL max_connections = 1
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
{
2+
"query": "SET GLOBAL max_connections = 1",
3+
"lexer": {
4+
"@type": "PhpMyAdmin\\SqlParser\\Lexer",
5+
"str": "SET GLOBAL max_connections = 1",
6+
"len": 30,
7+
"last": 30,
8+
"list": {
9+
"@type": "PhpMyAdmin\\SqlParser\\TokensList",
10+
"tokens": [
11+
{
12+
"@type": "PhpMyAdmin\\SqlParser\\Token",
13+
"token": "SET",
14+
"value": "SET",
15+
"keyword": "SET",
16+
"type": 1,
17+
"flags": 11,
18+
"position": 0
19+
},
20+
{
21+
"@type": "PhpMyAdmin\\SqlParser\\Token",
22+
"token": " ",
23+
"value": " ",
24+
"keyword": null,
25+
"type": 3,
26+
"flags": 0,
27+
"position": 3
28+
},
29+
{
30+
"@type": "PhpMyAdmin\\SqlParser\\Token",
31+
"token": "GLOBAL",
32+
"value": "GLOBAL",
33+
"keyword": "GLOBAL",
34+
"type": 1,
35+
"flags": 1,
36+
"position": 4
37+
},
38+
{
39+
"@type": "PhpMyAdmin\\SqlParser\\Token",
40+
"token": " ",
41+
"value": " ",
42+
"keyword": null,
43+
"type": 3,
44+
"flags": 0,
45+
"position": 10
46+
},
47+
{
48+
"@type": "PhpMyAdmin\\SqlParser\\Token",
49+
"token": "max_connections",
50+
"value": "max_connections",
51+
"keyword": null,
52+
"type": 0,
53+
"flags": 0,
54+
"position": 11
55+
},
56+
{
57+
"@type": "PhpMyAdmin\\SqlParser\\Token",
58+
"token": " ",
59+
"value": " ",
60+
"keyword": null,
61+
"type": 3,
62+
"flags": 0,
63+
"position": 26
64+
},
65+
{
66+
"@type": "PhpMyAdmin\\SqlParser\\Token",
67+
"token": "=",
68+
"value": "=",
69+
"keyword": null,
70+
"type": 2,
71+
"flags": 2,
72+
"position": 27
73+
},
74+
{
75+
"@type": "PhpMyAdmin\\SqlParser\\Token",
76+
"token": " ",
77+
"value": " ",
78+
"keyword": null,
79+
"type": 3,
80+
"flags": 0,
81+
"position": 28
82+
},
83+
{
84+
"@type": "PhpMyAdmin\\SqlParser\\Token",
85+
"token": "1",
86+
"value": 1,
87+
"keyword": null,
88+
"type": 6,
89+
"flags": 0,
90+
"position": 29
91+
},
92+
{
93+
"@type": "PhpMyAdmin\\SqlParser\\Token",
94+
"token": null,
95+
"value": null,
96+
"keyword": null,
97+
"type": 9,
98+
"flags": 0,
99+
"position": null
100+
}
101+
],
102+
"count": 10,
103+
"idx": 10
104+
},
105+
"delimiter": ";",
106+
"delimiterLen": 1,
107+
"strict": false,
108+
"errors": []
109+
},
110+
"parser": {
111+
"@type": "PhpMyAdmin\\SqlParser\\Parser",
112+
"list": {
113+
"@type": "@1"
114+
},
115+
"statements": [
116+
{
117+
"@type": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement",
118+
"options": {
119+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
120+
"options": {
121+
"3": "GLOBAL"
122+
}
123+
},
124+
"endOptions": null,
125+
"set": [
126+
{
127+
"@type": "PhpMyAdmin\\SqlParser\\Components\\SetOperation",
128+
"column": "max_connections",
129+
"value": "1"
130+
}
131+
],
132+
"first": 0,
133+
"last": 8
134+
}
135+
],
136+
"brackets": 0,
137+
"strict": false,
138+
"errors": []
139+
},
140+
"errors": {
141+
"lexer": [],
142+
"parser": []
143+
}
144+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SET @foo = 1
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
{
2+
"query": "SET @foo = 1",
3+
"lexer": {
4+
"@type": "PhpMyAdmin\\SqlParser\\Lexer",
5+
"str": "SET @foo = 1",
6+
"len": 12,
7+
"last": 12,
8+
"list": {
9+
"@type": "PhpMyAdmin\\SqlParser\\TokensList",
10+
"tokens": [
11+
{
12+
"@type": "PhpMyAdmin\\SqlParser\\Token",
13+
"token": "SET",
14+
"value": "SET",
15+
"keyword": "SET",
16+
"type": 1,
17+
"flags": 11,
18+
"position": 0
19+
},
20+
{
21+
"@type": "PhpMyAdmin\\SqlParser\\Token",
22+
"token": " ",
23+
"value": " ",
24+
"keyword": null,
25+
"type": 3,
26+
"flags": 0,
27+
"position": 3
28+
},
29+
{
30+
"@type": "PhpMyAdmin\\SqlParser\\Token",
31+
"token": "@foo",
32+
"value": "foo",
33+
"keyword": null,
34+
"type": 8,
35+
"flags": 1,
36+
"position": 4
37+
},
38+
{
39+
"@type": "PhpMyAdmin\\SqlParser\\Token",
40+
"token": " ",
41+
"value": " ",
42+
"keyword": null,
43+
"type": 3,
44+
"flags": 0,
45+
"position": 8
46+
},
47+
{
48+
"@type": "PhpMyAdmin\\SqlParser\\Token",
49+
"token": "=",
50+
"value": "=",
51+
"keyword": null,
52+
"type": 2,
53+
"flags": 2,
54+
"position": 9
55+
},
56+
{
57+
"@type": "PhpMyAdmin\\SqlParser\\Token",
58+
"token": " ",
59+
"value": " ",
60+
"keyword": null,
61+
"type": 3,
62+
"flags": 0,
63+
"position": 10
64+
},
65+
{
66+
"@type": "PhpMyAdmin\\SqlParser\\Token",
67+
"token": "1",
68+
"value": 1,
69+
"keyword": null,
70+
"type": 6,
71+
"flags": 0,
72+
"position": 11
73+
},
74+
{
75+
"@type": "PhpMyAdmin\\SqlParser\\Token",
76+
"token": null,
77+
"value": null,
78+
"keyword": null,
79+
"type": 9,
80+
"flags": 0,
81+
"position": null
82+
}
83+
],
84+
"count": 8,
85+
"idx": 8
86+
},
87+
"delimiter": ";",
88+
"delimiterLen": 1,
89+
"strict": false,
90+
"errors": []
91+
},
92+
"parser": {
93+
"@type": "PhpMyAdmin\\SqlParser\\Parser",
94+
"list": {
95+
"@type": "@1"
96+
},
97+
"statements": [
98+
{
99+
"@type": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement",
100+
"options": {
101+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
102+
"options": []
103+
},
104+
"endOptions": null,
105+
"set": [
106+
{
107+
"@type": "PhpMyAdmin\\SqlParser\\Components\\SetOperation",
108+
"column": "@foo",
109+
"value": "1"
110+
}
111+
],
112+
"first": 0,
113+
"last": 6
114+
}
115+
],
116+
"brackets": 0,
117+
"strict": false,
118+
"errors": []
119+
},
120+
"errors": {
121+
"lexer": [],
122+
"parser": []
123+
}
124+
}

0 commit comments

Comments
 (0)