Skip to content

ClosureToArrowFunctionRector not working as expected with compact #9420

@melicerte

Description

@melicerte

Bug Report

Subject Details
2.1.1 Rector 2.1.1

When converting callback to arrow functions, if the callback uses parameters which are exclusively used in a compact call, it removes the parameters, but compact does not know about them anymore (See example code below).

Minimal PHP Code Causing Issue

Here it is: https://getrector.com/demo/71bd1985-bd97-4cda-af96-440b328bb962

Expected Behaviour

Maybe the best call would be to convert compact calls to explicit array, but it does more than what the rule says.
Or maybe Rector should not convert this callback at all.
I'm not pretty sure what is the best solution here, but happy to talk about it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions