Skip to content

Commit

Permalink
bug: Fix error in regular_callable_call with static property (#6539)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienfalque authored Aug 13, 2022
1 parent 73546a8 commit adf4d08
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Fixer/FunctionNotation/RegularCallableCallFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,13 @@ private function processCall(Tokens $tokens, int $index, array $arguments): void
$newCallTokens->clearEmptyTokens();

$this->replaceCallUserFuncWithCallback($tokens, $index, $newCallTokens, $firstArgIndex, $firstArgIndex);
} elseif ($firstArgToken->isGivenKind([T_FUNCTION, T_STATIC])) {
} elseif (
$firstArgToken->isGivenKind(T_FUNCTION)
|| (
$firstArgToken->isGivenKind(T_STATIC)
&& $tokens[$tokens->getNextMeaningfulToken($firstArgIndex)]->isGivenKind(T_FUNCTION)
)
) {
$firstArgEndIndex = $tokens->findBlockEnd(
Tokens::BLOCK_TYPE_CURLY_BRACE,
$tokens->getNextTokenOfKind($firstArgIndex, ['{'])
Expand Down
10 changes: 10 additions & 0 deletions tests/Fixer/FunctionNotation/RegularCallableCallFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,16 @@ function call_user_func($foo){}
yield 'binary string upper single quote' => [
'<?php call_user_func(B"foo", 1,);',
];

yield 'static property as first argument' => [
'<?php
class Foo {
public static $factory;
public static function createFromFactory(...$args) {
return call_user_func_array(static::$factory, $args);
}
}',
];
}

/**
Expand Down

0 comments on commit adf4d08

Please sign in to comment.