@@ -388,39 +388,20 @@ public static function isWhitespace(string $character): bool
388388 */
389389 public static function isComment (string $ string , bool $ end = false ): int |null
390390 {
391- if ($ string === '' ) {
392- return null ;
393- }
394-
395- // If comment is Bash style (#):
396- if (str_starts_with ($ string , '# ' )) {
397- return Token::FLAG_COMMENT_BASH ;
398- }
399-
400- // If comment is a MySQL command
401- if (str_starts_with ($ string , '/*! ' )) {
402- return Token::FLAG_COMMENT_MYSQL_CMD ;
403- }
404-
405- // If comment is opening C style (/*) or is closing C style (*/), warning, it could conflict
406- // with wildcard and a real opening C style.
407- // It would look like the following valid SQL statement: "SELECT */* comment */ FROM...".
408- if (str_starts_with ($ string , '/* ' ) || str_starts_with ($ string , '*/ ' )) {
409- return Token::FLAG_COMMENT_C ;
410- }
411-
412- // If comment is SQL style (--\s?):
413- if (
391+ return match (true ) {
392+ str_starts_with ($ string , '# ' ) => Token::FLAG_COMMENT_BASH ,
393+ str_starts_with ($ string , '/*! ' ) => Token::FLAG_COMMENT_MYSQL_CMD ,
394+ // If comment is opening C style (/*) or is closing C style (*/), warning, it could conflict
395+ // with wildcard and a real opening C style.
396+ // It would look like the following valid SQL statement: "SELECT */* comment */ FROM...".
397+ str_starts_with ($ string , '/* ' ) || str_starts_with ($ string , '*/ ' ) => Token::FLAG_COMMENT_C ,
414398 str_starts_with ($ string , '-- ' )
415- || str_starts_with ($ string , "-- \r" )
416- || str_starts_with ($ string , "-- \n" )
417- || str_starts_with ($ string , "-- \t" )
418- || ($ string === '-- ' && $ end )
419- ) {
420- return Token::FLAG_COMMENT_SQL ;
421- }
422-
423- return null ;
399+ || str_starts_with ($ string , "-- \r" )
400+ || str_starts_with ($ string , "-- \n" )
401+ || str_starts_with ($ string , "-- \t" )
402+ || ($ string === '-- ' && $ end ) => Token::FLAG_COMMENT_SQL ,
403+ default => null ,
404+ };
424405 }
425406
426407 /**
0 commit comments