Skip to content

Commit

Permalink
fix: TokensAnalyzer - handle unary operator in arrow functions (#7862)
Browse files Browse the repository at this point in the history
  • Loading branch information
kubawerlos committed Mar 8, 2024
1 parent 438d5ea commit b68c8ba
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 96 deletions.
2 changes: 1 addition & 1 deletion phpstan.dist.neon
Expand Up @@ -21,6 +21,6 @@ parameters:
-
message: '#^Method PhpCsFixer\\Tests\\.+::provide.+Cases\(\) return type has no value type specified in iterable type iterable\.$#'
path: tests
count: 1021
count: 1020
tipsOfTheDay: false
tmpDir: dev-tools/phpstan/cache
1 change: 1 addition & 0 deletions src/Tokenizer/TokensAnalyzer.php
Expand Up @@ -554,6 +554,7 @@ public function isUnaryPredecessorOperator(int $index): bool
';',
'{',
'}',
[T_DOUBLE_ARROW],
[T_FN],
[T_FUNCTION],
[T_OPEN_TAG],
Expand Down
4 changes: 4 additions & 0 deletions tests/Fixer/Operator/UnaryOperatorSpacesFixerTest.php
Expand Up @@ -152,5 +152,9 @@ public static function provideFixCases(): iterable
'<?php function foo($a, ... $b) { return (-- $a) * ($b ++);}',
['only_dec_inc' => true],
];

yield [
'<?php static fn(Token $t): bool => 8 === ($t->flags & 8);',
];
}
}

0 comments on commit b68c8ba

Please sign in to comment.