Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds AddClosureParamTypeFromObjectRector #6265

Conversation

peterfox
Copy link
Contributor

Changes

  • Adds a AddClosureParamTypeFromObjectRector
  • Adds a AddClosureParamTypeFromObject value object
  • Adds tests for the new rule

Why

Similar to AddClosureParamTypeFromArgRector there's a few times where classes will automatically use the type of the object in a method call to pass to a Closure as an argument. I feel it makes sense to allow Rector to do this with a configurable rule as it's a common pattern.

$request = new Request();
-$request->when(true, function ($request) {});
+$request->when(true, function (Request $request) {});

@TomasVotruba
Copy link
Member

I'm looking into this...

@TomasVotruba TomasVotruba merged commit 96b585b into rectorphp:main Sep 1, 2024
36 checks passed
@TomasVotruba
Copy link
Member

Looks great 👍 thanks 🙏

@MrPunyapal
Copy link

Wow 😲

Thank you @peterfox 💪💪💪

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants