-
-
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
SingleTraitInsertPerStatement - fix formatting for multiline "use" #4710
SingleTraitInsertPerStatement - fix formatting for multiline "use" #4710
Conversation
What does it do with the following example: <?php
final class Example
{
use Foo,
Bar,
// Bazz,
Baz;
} |
@GrahamCampbell now it does well |
@GrahamCampbell where is this happening? Because definitely not in |
Could you add the following test case: <?php
class Example
{
use Foo, Bar;
public function baz() {}
} it should be fixed to: <?php
class Example
{
use Foo;
use Bar;
public function baz() {}
} I think your code will actually fix it to: <?php
class Example
{
use Foo;
use Bar;
public function baz() {}
} |
Added, through the expected result is different from each of your examples - we are not adding any new line if none between imports (as in very first test case), so this what would be: <?php
class Example
{
use Foo;use Bar;
public function baz() {}
} |
Right, so your fixer is fixing to the wrong thing, and then another fixer is breaking up the statements? |
// cc @SpacePossum. This fixer is meant to fix to the Symfony and PSR-12 style, but seems to not do that? |
WHAAAT? Are you kidding? See the issue it's fixing - there is a test case that covers this issue... See the original tests - they are not meant to break the lines, only to do what the fixer describes to do, which is 'Each trait
Since when? It seems like overthinking. We have a fixer to split the imports into separate lines since a long time ago, this fixer is meant to be run before it and @SpacePossum thought about it as he wrote this integration test: https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/v2.16.1/tests/Fixtures/Integration/priority/single_trait_insert_per_statement,braces.test |
Yes, I know. I am saying I think the common sense thing to do is to have the fixer split onto new lines, even though the original implementation didn't do this. This is why I have cced in the original fixer author. |
Because of exactly the problem I am describing, with the example I provided. Trying to have separation of responsibilities just leads to it being harder to use, and producing output that is not desirable. |
Though, maybe this is something we should discuss for after this PR. ;) |
This PR itself looks fine. |
No, it is meant/designed to make multiple use statements
I disagree, please provide more than an opinion and I might change my mind. For now, lets leave this out of the PR, the only issue I've seen so far is that there is no priority test between this fixer and |
Thank you @kubawerlos. |
Fixes #4709