- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
UseArrowFunctionsFixer - introduction #4778
Conversation
8279357
to
9438853
Compare
Can you elaborate please? I think it would be nice to cover those as well but maybe I'm missing something. |
Maybe it is a matter of taste, but in my opinion the arrow functions without the braces are less readable for multiline return statements. But would it be the responsibility of this fixer to change indentation? foo($x, function () {
return bar(
$a,
$b
);
}, $y); to: foo($x, fn () => bar(
$a,
$b
), $y); And this input: foo($x, function ($a, $b) {
return $a
->aMethodCall()
->otherMethodCall($b)
->thirdMethod();
}, $y); to: foo($x, fn ($a, $b) => $a
->aMethodCall()
->otherMethodCall($b)
->thirdMethod(), $y); I think we should avoid these problems and the fixer should not touch these cases with multiline return statements. |
I do prefer to fix multiline return statements as well, @SpacePossum @keradus @kubawerlos WDYT? Maybe this can be an option?
No, that would be another fixer. |
Ping :) |
I don't think I would use the multi line version. Therefore I'm fine if this is not part of the first version of the fixer. I think it can be added as an option later. |
👍 for implementing multiline support later, but without option. It's part of the intended scope of the rule, but it's not fully implemented yet (like we do with rulesets). |
9438853
to
30ff1ed
Compare
@gharlan Could you please rebase to fix the conflict? |
30ff1ed
to
f8692e4
Compare
fc29b6d
to
9e7a558
Compare
Thank you @gharlan. |
is fixed to:
But only real one-liner return statements are transformed. If there is a comment before, or if the return statement uses more lines, there is no point in using an arrow function.
So these cases are not transformed: