Skip to content

[CodeQuality] Fix MergeWithCallableAndWillReturnRector to add closure use() for variables nested in willReturn expr#683

Merged
TomasVotruba merged 1 commit into
mainfrom
fix-merge-callable-closure-use
Jun 26, 2026
Merged

[CodeQuality] Fix MergeWithCallableAndWillReturnRector to add closure use() for variables nested in willReturn expr#683
TomasVotruba merged 1 commit into
mainfrom
fix-merge-callable-closure-use

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Previously only a bare Variable willReturn arg got a closure use(). A variable nested inside an array (e.g. willReturn([$initialStatements, []])) was moved into the closure without a use(), producing a syntax error.

Now all variables referenced in the returned expression are collected (skipping closure params and $this) and added as closure uses.

Fixes #604

… use() for variables nested in willReturn expr

Previously only a bare Variable willReturn arg got a closure use().
A variable nested inside an array (e.g. willReturn([$initialStatements, []]))
was moved into the closure without a use(), producing a syntax error.

Now all variables referenced in the returned expression are collected
(skipping closure params and $this) and added as closure uses.

Fixes #604
@TomasVotruba TomasVotruba merged commit f7c61b8 into main Jun 26, 2026
8 checks passed
@TomasVotruba TomasVotruba deleted the fix-merge-callable-closure-use branch June 26, 2026 09:55
@staabm

staabm commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

thank you!

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.

2 participants