Skip to content

Commit

Permalink
Fixed detection of array return types for arrow functions
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Jan 21, 2020
1 parent bb50f79 commit 0e4fe74
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
- The PHP 7.4 numeric separator backfill is no longer run on PHP version 7.4.0 or greater
- File::getCondition() now accepts a 3rd argument that allows for the closest matching token to be returned
-- By default, it continues to return the first matched token found from the top of the file
- Fixed detection of array return types for arrow functions
- Added Generic.PHP.DisallowRequestSuperglobal to ban the use of the $_REQUEST superglobal
-- Thanks to Morerice for the contribution
- PSR12.ControlStructures.BooleanOperatorPlacement can now be configured to enforce a specific operator position
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ abstract function foo(): array;
abstract function foo(): Foo\Bar;

abstract function foo(): \Foo\Bar;

array_map(
static fn (array $value): array => array_filter($value),
[]
);
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ abstract function foo(): array;
abstract function foo(): Foo\Bar;

abstract function foo(): \Foo\Bar;

array_map(
static fn (array $value): array => array_filter($value),
[]
);
3 changes: 2 additions & 1 deletion src/Tokenizers/PHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,8 @@ protected function tokenize($string)
*/

if ($tokenIsArray === true
&& $token[0] === T_FUNCTION
&& ($token[0] === T_FUNCTION
|| $token[0] === T_FN)
&& $finalTokens[$lastNotEmptyToken]['code'] !== T_USE
) {
for ($x = ($stackPtr + 1); $x < $numTokens; $x++) {
Expand Down

0 comments on commit 0e4fe74

Please sign in to comment.