You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Incorrect behavior of WithConsecutiveRector: variables in willReturnOnConsecutiveCalls() not added to closure use() #9962
$title is used in the closure but not captured, so the test now fails with "Undefined variable $title".
Responsible rules
WithConsecutiveRector
Expected Behavior
Variables used in the willReturnOnConsecutiveCalls() arguments should be added to the closure's use(), like variables from withConsecutive() and willReturn() already are:
function (...$parameters) use ($matcher, $title) {
Looks like UsedVariablesResolver::resolveUsedVariables() only looks at the withConsecutive() call and the single return statement, while WillReturnIfNodeDecorator adds the willReturnOnConsecutiveCalls() values afterwards.
Found in the wild in Drupal's lingotek module (tests/src/Unit/Plugin/RelatedEntitiesDetector/NestedErViewmodeEntitiesDetectorTest.php) while running Rector over all Drupal contrib projects.
Activity
TomasVotruba commentedon Nov 9, 2026
Thanks for reporting 👍
Fixed in rectorphp/rector-phpunit#821