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

Issue between method_chaining_indentation and array_indentation #4271

Closed
julienfalque opened this issue Jan 17, 2019 · 2 comments
Closed

Issue between method_chaining_indentation and array_indentation #4271

julienfalque opened this issue Jan 17, 2019 · 2 comments
Labels

Comments

@julienfalque
Copy link
Member

julienfalque commented Jan 17, 2019

When applying array_indentation and method_chaining_indentation rules, PHP CS Fixer needs to run twice:

first run:

 function foo($foo)
 {
     $foo
         ->bar()
-            ->baz([
+        ->baz([
                 'foo' => 'bar',
             ])
     ;
 }

second run:

 function foo($foo)
 {
     $foo
         ->bar()
         ->baz([
-                'foo' => 'bar',
-            ])
+            'foo' => 'bar',
+        ])
     ;
 }

This seems to be a regression in version 1.13.2 as version 1.13.1 applies all changes at first run.

@dmvdbrugge
Copy link
Contributor

I think this is caused by #4084 (sorry 😜) where method_chaining_indentation got a priority, which is actually the same as array_indentation. I think in your case array_indentation runs first, whereas method_chaining_indentation seems to need to run first.

However, this might produce issues when you are chaining inside an array. I do think your situation is more common though, so the solution is to either give method_chaining_indentation a +1 or array_indentation a -1. (And of course couple the priority, with given example as testcase.)

The lowest version this applies to is 2.12.5

@dmvdbrugge
Copy link
Contributor

dmvdbrugge commented Jan 21, 2019

As I was the culprit, I created PR #4276 to fix my boo-boo 😅

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

No branches or pull requests

3 participants