Skip to content

[Php81][CodingStyle] Skip callable param assign with signature multi params on FunctionLikeToFirstClassCallableRector#7538

Merged
samsonasik merged 4 commits into
mainfrom
skip-caller-signature
Oct 22, 2025
Merged

[Php81][CodingStyle] Skip callable param assign with signature multi params on FunctionLikeToFirstClassCallableRector#7538
samsonasik merged 4 commits into
mainfrom
skip-caller-signature

Conversation

@samsonasik
Copy link
Copy Markdown
Member

…params on FunctionLikeToFirstClassCallableRector
@samsonasik
Copy link
Copy Markdown
Member Author

Fixed 🎉 /cc @calebdw


(new SkipCallableParamAssignWithSignatureMultiParams())
->withTransform(fn (string $datum): string => trim($datum))
->run(' some data ');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samsonasik, you should also test that this does convert to first class callable when both params are used:

function foo(mixed $datum, int|string|null $key) {}

(new SkipCallableParamAssignWithSignatureMultiParams())
-   ->withTransform(fn ($datum, $key) => foo($datum, $key))
+   ->withTransform(foo(...))
    ->run('  some data  ');

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@calebdw I am going to skip for now :), this is already too complex to cover, the issue is not in the withTransform(), but on usage, as run() has default value, see original issue comment rectorphp/rector#9449 (comment)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not care about the usage in run as long as the callable conforms to the signature that's specified on withTransform

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to only check multi params when dealing with native function, otherwise, skip for now, as that become hard to review changed code.

@samsonasik samsonasik merged commit c3129bc into main Oct 22, 2025
52 checks passed
@samsonasik samsonasik deleted the skip-caller-signature branch October 22, 2025 15:16
@github-actions
Copy link
Copy Markdown
Contributor

This pull request has been automatically locked because it has been closed for 150 days. Please open a new PR if you want to continue the work.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Mar 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect behavior of FunctionLikeToFirstClassCallableRector

3 participants