diff --git a/rules-tests/CodingStyle/Rector/FuncCall/FunctionFirstClassCallableRector/Fixture/leading_backslash.php.inc b/rules-tests/CodingStyle/Rector/FuncCall/FunctionFirstClassCallableRector/Fixture/leading_backslash.php.inc new file mode 100644 index 00000000000..14a46694060 --- /dev/null +++ b/rules-tests/CodingStyle/Rector/FuncCall/FunctionFirstClassCallableRector/Fixture/leading_backslash.php.inc @@ -0,0 +1,27 @@ + +----- + diff --git a/rules/CodingStyle/Rector/FuncCall/FunctionFirstClassCallableRector.php b/rules/CodingStyle/Rector/FuncCall/FunctionFirstClassCallableRector.php index 8b98d55fcf0..b94041c893c 100644 --- a/rules/CodingStyle/Rector/FuncCall/FunctionFirstClassCallableRector.php +++ b/rules/CodingStyle/Rector/FuncCall/FunctionFirstClassCallableRector.php @@ -101,11 +101,14 @@ public function refactor(Node $node): ?FuncCall continue; } + $isFullyQualified = str_starts_with($arg->value->value, '\\'); + $callableName = ltrim($arg->value->value, '\\'); + $node->args[$key] = new Arg( new FuncCall( - str_contains($arg->value->value, '\\') - ? new FullyQualified($arg->value->value) - : new Name($arg->value->value), + $isFullyQualified || str_contains($callableName, '\\') + ? new FullyQualified($callableName) + : new Name($callableName), [new VariadicPlaceholder()] ), name: $arg->name