-
-
Notifications
You must be signed in to change notification settings - Fork 70
Chain calls must be put on separate lines #155
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
Comments
Already checked and seems it can't be automated with StyleCI. |
I usually do it as: $object
->method1()
->method2(); |
Me too, and also when chain is long sometime writes it as:
to easy move/remove any method. |
This rule is overhead for me. Don't want to significantly expand the PSR-12. Although, I prefer @samdark variant: $object
->method1()
->method2(); |
We may have it as a soft-rule with |
What about such inliners? in array (from: yii3-app/config/routes.php):
as variable (yii3-app/tests/Unit/HelloCest.php): as return (yii3-app/tests/Support/_generated/UnitTesterActions.php): It will be more clear if it would be stated here as examples of different usage cases. |
Is this correct?
|
Yes, it is. |
More examples (I had during code review), are they correct? one argument (single method) with concatenation:
one argument (chain calls):
multiple arguments (single/chained), with concatenation:
chaining in if() with multiple conditions:
property after method:
|
No one will use it. It can be implemented as a plugin to such tools as php-cs-fixer, rector, prettier or others. |
Well, if somebody will make a plugin I will be happy. At least until now, no changes were made and as @arogachev was pointed out: "Already checked and seems it can't be automated with StyleCI." And within two month, nobody made any changes according to this issue. But if somebody will make a plugin, let me know, so I could be happy. :) @xepozz can you make it? |
I don't think so :) StyleCI should be omitted as for me. So with php-cs-fixer you can create your own rule. It's simple. |
The reason - readability. Suggested by @xepozz.
Even if there are only 2 methods and it fits on 1line. Or are there any exceptions? Not sure about
$object->formatter->format()
though.If everyone is OK with that, I'll add it to the code style.
The text was updated successfully, but these errors were encountered: