File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 811811 <code >$token</code >
812812 <code >$token</code >
813813 </PossiblyNullArgument >
814- <PossiblyNullOperand occurrences =" 24 " >
814+ <PossiblyNullOperand occurrences =" 25 " >
815815 <code >$this-> delimiter</code >
816816 <code >$this-> str[$this-> last++]</code >
817817 <code >$this-> str[$this-> last]</code >
836836 <code >$this-> str[++$this-> last]</code >
837837 <code >$this-> str[++$this-> last]</code >
838838 <code >$this-> str[++$this-> last]</code >
839+ <code >$this-> str[++$this-> last]</code >
839840 </PossiblyNullOperand >
840841 <PossiblyNullPropertyAssignmentValue occurrences =" 1" >
841842 <code >null</code >
Original file line number Diff line number Diff line change @@ -443,10 +443,19 @@ public static function isComment($str, $end = false)
443443 return Token::FLAG_COMMENT_BASH ;
444444 }
445445
446- // If comment is opening C style (/*), warning, it could be a MySQL command (/*!)
446+ // If comment is opening C style (/*), warning, it could be
447+ // - a MySQL command (/*!)
448+ // - a MariaDB command (/*M!)
447449 if (($ len > 1 ) && ($ str [0 ] === '/ ' ) && ($ str [1 ] === '* ' )) {
448- return ($ len > 2 ) && ($ str [2 ] === '! ' ) ?
449- Token::FLAG_COMMENT_MYSQL_CMD : Token::FLAG_COMMENT_C ;
450+ if ($ len > 2 && $ str [2 ] === '! ' ) {
451+ return Token::FLAG_COMMENT_MYSQL_CMD ;
452+ }
453+
454+ if ($ len > 3 && $ str [2 ] === 'M ' && $ str [3 ] === '! ' ) {
455+ return Token::FLAG_COMMENT_MARIADB_CMD ;
456+ }
457+
458+ return Token::FLAG_COMMENT_C ;
450459 }
451460
452461 // If comment is closing C style (*/), warning, it could conflicts with wildcard and a real opening C style.
Original file line number Diff line number Diff line change @@ -693,10 +693,21 @@ public function parseComment()
693693 return new Token ($ token , Token::TYPE_COMMENT , $ flags );
694694 }
695695
696- // Checking if this is a MySQL-specific command.
697- if ($ this ->last + 1 < $ this ->len && $ this ->str [$ this ->last + 1 ] === '! ' ) {
698- $ flags |= Token::FLAG_COMMENT_MYSQL_CMD ;
696+ // Checking if this is a MySQL (/*!) or MariaDB (/*M!) specific command.
697+ if (
698+ $ this ->last + 1 < $ this ->len &&
699+ ($ this ->str [$ this ->last + 1 ] === '! ' ||
700+ ($ this ->str [$ this ->last + 1 ] === 'M ' &&
701+ $ this ->last + 2 < $ this ->len &&
702+ $ this ->str [$ this ->last + 2 ] === '! ' ))
703+ ) {
699704 $ token .= $ this ->str [++$ this ->last ];
705+ if ($ this ->str [$ this ->last ] === '! ' ) {
706+ $ flags |= Token::FLAG_COMMENT_MYSQL_CMD ;
707+ } else {
708+ $ flags |= Token::FLAG_COMMENT_MARIADB_CMD ;
709+ $ token .= $ this ->str [++$ this ->last ];
710+ }
700711
701712 while (
702713 ++$ this ->last < $ this ->len
Original file line number Diff line number Diff line change @@ -152,6 +152,7 @@ class Token
152152 public const FLAG_COMMENT_C = 2 ;
153153 public const FLAG_COMMENT_SQL = 4 ;
154154 public const FLAG_COMMENT_MYSQL_CMD = 8 ;
155+ public const FLAG_COMMENT_MARIADB_CMD = 16 ;
155156
156157 // Operators related flags.
157158 public const FLAG_OPERATOR_ARITHMETIC = 1 ;
Original file line number Diff line number Diff line change @@ -63,6 +63,8 @@ public function testIsComment(): void
6363 $ this ->assertEquals (Token::FLAG_COMMENT_C , Context::isComment ('/* ' ));
6464 $ this ->assertEquals (Token::FLAG_COMMENT_MYSQL_CMD , Context::isComment ('/*! ' ));
6565 $ this ->assertEquals (Token::FLAG_COMMENT_MYSQL_CMD , Context::isComment ('/*!50000 ' ));
66+ $ this ->assertEquals (Token::FLAG_COMMENT_MARIADB_CMD , Context::isComment ('/*M! ' ));
67+ $ this ->assertEquals (Token::FLAG_COMMENT_MARIADB_CMD , Context::isComment ('/*M!100300 ' ));
6668 $ this ->assertEquals (Token::FLAG_COMMENT_C , Context::isComment ('*/ ' ));
6769 $ this ->assertEquals (Token::FLAG_COMMENT_SQL , Context::isComment ('-- ' ));
6870 $ this ->assertEquals (Token::FLAG_COMMENT_SQL , Context::isComment ("-- \t" ));
Original file line number Diff line number Diff line change 262262 },
263263 {
264264 "@type": "PhpMyAdmin\\SqlParser\\Token",
265- "token": "/*M!100300 1, */ ",
266- "value": "/*M!100300 1, */ ",
265+ "token": "/*M!100300",
266+ "value": "/*M!100300",
267267 "keyword": null,
268268 "type": 4,
269- "flags": 2 ,
269+ "flags": 18 ,
270270 "position": 119
271271 },
272+ {
273+ "@type": "PhpMyAdmin\\SqlParser\\Token",
274+ "token": " ",
275+ "value": " ",
276+ "keyword": null,
277+ "type": 3,
278+ "flags": 0,
279+ "position": 129
280+ },
281+ {
282+ "@type": "PhpMyAdmin\\SqlParser\\Token",
283+ "token": "1",
284+ "value": 1,
285+ "keyword": null,
286+ "type": 6,
287+ "flags": 0,
288+ "position": 130
289+ },
290+ {
291+ "@type": "PhpMyAdmin\\SqlParser\\Token",
292+ "token": ",",
293+ "value": ",",
294+ "keyword": null,
295+ "type": 2,
296+ "flags": 16,
297+ "position": 131
298+ },
299+ {
300+ "@type": "PhpMyAdmin\\SqlParser\\Token",
301+ "token": " ",
302+ "value": " ",
303+ "keyword": null,
304+ "type": 3,
305+ "flags": 0,
306+ "position": 132
307+ },
308+ {
309+ "@type": "PhpMyAdmin\\SqlParser\\Token",
310+ "token": "*/",
311+ "value": "*/",
312+ "keyword": null,
313+ "type": 4,
314+ "flags": 2,
315+ "position": 133
316+ },
272317 {
273318 "@type": "PhpMyAdmin\\SqlParser\\Token",
274319 "token": " ",
306351 "position": null
307352 }
308353 ],
309- "count": 33 ,
354+ "count": 38 ,
310355 "idx": 0
311356 },
312357 "delimiter": ";",
Original file line number Diff line number Diff line change 109109 },
110110 {
111111 "@type": "PhpMyAdmin\\SqlParser\\Token",
112- "token": "/*M!100301 COMPRESSED*/ ",
113- "value": "/*M!100301 COMPRESSED*/ ",
112+ "token": "/*M!100301",
113+ "value": "/*M!100301",
114114 "keyword": null,
115115 "type": 4,
116- "flags": 2 ,
116+ "flags": 18 ,
117117 "position": 32
118118 },
119+ {
120+ "@type": "PhpMyAdmin\\SqlParser\\Token",
121+ "token": " ",
122+ "value": " ",
123+ "keyword": null,
124+ "type": 3,
125+ "flags": 0,
126+ "position": 42
127+ },
128+ {
129+ "@type": "PhpMyAdmin\\SqlParser\\Token",
130+ "token": "COMPRESSED",
131+ "value": "COMPRESSED",
132+ "keyword": "COMPRESSED",
133+ "type": 1,
134+ "flags": 1,
135+ "position": 43
136+ },
137+ {
138+ "@type": "PhpMyAdmin\\SqlParser\\Token",
139+ "token": "*/",
140+ "value": "*/",
141+ "keyword": null,
142+ "type": 4,
143+ "flags": 2,
144+ "position": 53
145+ },
119146 {
120147 "@type": "PhpMyAdmin\\SqlParser\\Token",
121148 "token": ")",
144171 "position": null
145172 }
146173 ],
147- "count": 15 ,
148- "idx": 15
174+ "count": 18 ,
175+ "idx": 18
149176 },
150177 "delimiter": ";",
151178 "delimiterLen": 1,
192219 "references": null,
193220 "options": {
194221 "@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
195- "options": []
222+ "options": {
223+ "16": "COMPRESSED"
224+ }
196225 }
197226 }
198227 ],
215244 }
216245 },
217246 "first": 0,
218- "last": 13
247+ "last": 16
219248 }
220249 ],
221250 "brackets": 0,
You can’t perform that action at this time.
0 commit comments