File tree Expand file tree Collapse file tree 4 files changed +11
-24
lines changed
Expand file tree Collapse file tree 4 files changed +11
-24
lines changed Original file line number Diff line number Diff line change 229229 <code ><![CDATA[ $keywordToken->value]]> </code >
230230 </PropertyTypeCoercion >
231231 <RiskyTruthyFalsyComparison >
232- <code ><![CDATA[ ! $flags]]> </code >
233232 <code ><![CDATA[ ! $flags]]> </code >
234233 <code ><![CDATA[ ! $flags]]> </code >
235234 <code ><![CDATA[ Context::isComment($token)]]> </code >
Original file line number Diff line number Diff line change @@ -445,25 +445,14 @@ public static function isNumber(string $string): bool
445445 *
446446 * @return int|null the appropriate flag for the symbol type
447447 */
448- public static function isSymbol (string $ string ): int |null
448+ public static function isSymbol (string $ character ): int |null
449449 {
450- if ($ string === '' ) {
451- return null ;
452- }
453-
454- if (str_starts_with ($ string , '@ ' )) {
455- return Token::FLAG_SYMBOL_VARIABLE ;
456- }
457-
458- if (str_starts_with ($ string , '` ' )) {
459- return Token::FLAG_SYMBOL_BACKTICK ;
460- }
461-
462- if (str_starts_with ($ string , ': ' ) || str_starts_with ($ string , '? ' )) {
463- return Token::FLAG_SYMBOL_PARAMETER ;
464- }
465-
466- return null ;
450+ return match ($ character ) {
451+ '@ ' => Token::FLAG_SYMBOL_VARIABLE ,
452+ '` ' => Token::FLAG_SYMBOL_BACKTICK ,
453+ ': ' , '? ' => Token::FLAG_SYMBOL_PARAMETER ,
454+ default => null ,
455+ };
467456 }
468457
469458 /**
Original file line number Diff line number Diff line change @@ -918,7 +918,7 @@ public function parseSymbol(): Token|null
918918 $ token = $ this ->str [$ this ->last ];
919919 $ flags = Context::isSymbol ($ token );
920920
921- if (! $ flags ) {
921+ if ($ flags === null ) {
922922 return null ;
923923 }
924924
Original file line number Diff line number Diff line change @@ -115,12 +115,11 @@ public function testIsSymbol(): void
115115 {
116116 $ this ->assertEquals (Token::FLAG_SYMBOL_VARIABLE , Context::isSymbol ('@ ' ));
117117 $ this ->assertEquals (Token::FLAG_SYMBOL_BACKTICK , Context::isSymbol ('` ' ));
118-
119- $ this ->assertEquals (Token::FLAG_SYMBOL_VARIABLE , Context::isSymbol ('@id ' ));
120- $ this ->assertEquals (Token::FLAG_SYMBOL_BACKTICK , Context::isSymbol ('`id` ' ));
118+ $ this ->assertEquals (Token::FLAG_SYMBOL_PARAMETER , Context::isSymbol (': ' ));
119+ $ this ->assertEquals (Token::FLAG_SYMBOL_PARAMETER , Context::isSymbol ('? ' ));
121120
122121 $ this ->assertNull (Context::isSymbol ('' ));
123- $ this ->assertNull (Context::isSymbol ('id ' ));
122+ $ this ->assertNull (Context::isSymbol ('i ' ));
124123 }
125124
126125 public function testisSeparator (): void
You can’t perform that action at this time.
0 commit comments