Skip to content

Fix double backslash in FunctionFirstClassCallableRector - #8398

Merged
TomasVotruba merged 1 commit into
mainfrom
tv-fix-first-class-callable-double-slash
Aug 29, 2026
Merged

Fix double backslash in FunctionFirstClassCallableRector#8398
TomasVotruba merged 1 commit into
mainfrom
tv-fix-first-class-callable-double-slash

Conversation

@TomasVotruba

@TomasVotruba TomasVotruba commented Aug 29, 2026

Copy link
Copy Markdown
Member

Fixes rectorphp/rector#9871

FunctionFirstClassCallableRector produced invalid PHP for a fully qualified string callable with a leading backslash. The leading \ was passed straight into FullyQualified, which then printed a doubled backslash.

-\array_map('\trim', $input);
+\array_map(\trim(...), $input);

Before the fix the output was \array_map(\\trim(...), $input) - invalid syntax.

Fix: strip the leading backslash before building the name and keep it fully qualified when one was present.

@TomasVotruba
TomasVotruba enabled auto-merge (squash) August 29, 2026 07:27
@TomasVotruba
TomasVotruba disabled auto-merge August 29, 2026 07:27
Strip leading backslash before building the callable name so a fully
qualified string callable like '\trim' produces \trim(...) instead of
invalid \\trim(...).

Claude-Session: https://claude.ai/code/session_01NAL2P8PQ3MY37Faby2r8st
@TomasVotruba
TomasVotruba force-pushed the tv-fix-first-class-callable-double-slash branch from d8e75f5 to fabecca Compare August 29, 2026 07:28
@TomasVotruba
TomasVotruba merged commit 4705fb5 into main Aug 29, 2026
44 checks passed
@TomasVotruba
TomasVotruba deleted the tv-fix-first-class-callable-double-slash branch August 29, 2026 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect behavior of FunctionFirstClassCallableRector

1 participant