File tree Expand file tree Collapse file tree 4 files changed +9
-21
lines changed
Expand file tree Collapse file tree 4 files changed +9
-21
lines changed Original file line number Diff line number Diff line change 232232 <code ><![CDATA[ ! $flags]]> </code >
233233 <code ><![CDATA[ ! $flags]]> </code >
234234 <code ><![CDATA[ ! $flags]]> </code >
235- <code ><![CDATA[ ! $flags]]> </code >
236235 <code ><![CDATA[ Context::isComment($token)]]> </code >
237236 <code ><![CDATA[ Context::isComment($token)]]> </code >
238237 <code ><![CDATA[ Context::isComment($token, $end)]]> </code >
Original file line number Diff line number Diff line change @@ -469,25 +469,17 @@ public static function isSymbol(string $string): int|null
469469 /**
470470 * Checks if the given character is the beginning of a string.
471471 *
472- * @param string $string string to be checked
472+ * @param string $character a character to be checked
473473 *
474474 * @return int|null the appropriate flag for the string type
475475 */
476- public static function isString (string $ string ): int |null
476+ public static function isString (string $ character ): int |null
477477 {
478- if ($ string === '' ) {
479- return null ;
480- }
481-
482- if (str_starts_with ($ string , '\'' )) {
483- return Token::FLAG_STRING_SINGLE_QUOTES ;
484- }
485-
486- if (str_starts_with ($ string , '" ' )) {
487- return Token::FLAG_STRING_DOUBLE_QUOTES ;
488- }
489-
490- return null ;
478+ return match ($ character ) {
479+ '\'' => Token::FLAG_STRING_SINGLE_QUOTES ,
480+ '" ' => Token::FLAG_STRING_DOUBLE_QUOTES ,
481+ default => null ,
482+ };
491483 }
492484
493485 /**
Original file line number Diff line number Diff line change @@ -868,7 +868,7 @@ public function parseString(string $quote = ''): Token|null
868868 $ token = $ this ->str [$ this ->last ];
869869 $ flags = Context::isString ($ token );
870870
871- if (! $ flags && $ token !== $ quote ) {
871+ if ($ flags === null && $ token !== $ quote ) {
872872 return null ;
873873 }
874874
Original file line number Diff line number Diff line change @@ -107,11 +107,8 @@ public function testIsString(): void
107107 $ this ->assertEquals (Token::FLAG_STRING_SINGLE_QUOTES , Context::isString ("' " ));
108108 $ this ->assertEquals (Token::FLAG_STRING_DOUBLE_QUOTES , Context::isString ('" ' ));
109109
110- $ this ->assertEquals (Token::FLAG_STRING_SINGLE_QUOTES , Context::isString ("'foo bar' " ));
111- $ this ->assertEquals (Token::FLAG_STRING_DOUBLE_QUOTES , Context::isString ('"foo bar" ' ));
112-
113110 $ this ->assertNull (Context::isString ('' ));
114- $ this ->assertNull (Context::isString ('foo bar ' ));
111+ $ this ->assertNull (Context::isString ('f ' ));
115112 }
116113
117114 public function testIsSymbol (): void
You can’t perform that action at this time.
0 commit comments