-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed detection of T_NULLABLE for arrow functions (ref #2708)
- Loading branch information
Showing
4 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1073,6 +1073,7 @@ protected function tokenize($string) | |
} | ||
|
||
if ($tokenType === T_FUNCTION | ||
|| $tokenType === T_FN | ||
|| isset(Util\Tokens::$methodPrefixes[$tokenType]) === true | ||
) { | ||
if (PHP_CODESNIFFER_VERBOSITY > 1) { | ||
|
@@ -1285,6 +1286,11 @@ function return types. We want to keep the parenthesis map clean, | |
&& $token[0] === T_STRING | ||
&& strtolower($token[1]) === 'fn' | ||
) { | ||
// Modify the original token stack so that | ||
// future checks (like looking for T_NULLABLE) can | ||
// detect the T_FN token more easily. | ||
$tokens[$stackPtr][0] = T_FN; | ||
|
||
$finalTokens[$newStackPtr] = [ | ||
'content' => $token[1], | ||
'code' => T_FN, | ||
|
@@ -1702,8 +1708,10 @@ protected function processAdditional() | |
if ($this->tokens[$x]['code'] === T_OPEN_PARENTHESIS) { | ||
$ignore = Util\Tokens::$emptyTokens; | ||
$ignore += [ | ||
T_STRING => T_STRING, | ||
T_COLON => T_COLON, | ||
T_STRING => T_STRING, | ||
T_COLON => T_COLON, | ||
T_NS_SEPARATOR => T_COLON, | ||
T_NULLABLE => T_COLON, | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
gsherwood
Author
Member
|
||
]; | ||
|
||
$closer = $this->tokens[$x]['parenthesis_closer']; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@gsherwood is it correct ?
Shouldn't be as I've suggested:
?