Skip to content

Commit 6faba9d

Browse files
committed
bug #4276 MethodChainingIndentationFixer, ArrayIndentationFixer - Fix priority issue (dmvdbrugge)
This PR was merged into the 2.12 branch. Discussion ---------- MethodChainingIndentationFixer, ArrayIndentationFixer - Fix priority issue Fixes #4271. Pre-2.12.5 `MethodChainingIndentationFixer` had no priority, I introduced it in #4084. It now needs to be upped because it needs to keep running before `ArrayIndentationFixer`. Lowering `ArrayIndentationFixer` was not an option as it already has multiple fixers running after it (which are in the `FixerFactoryTest`, but not in its comments, however the comments are already being fixed in #4245). Commits ------- a6bd13c MethodChainingIndentationFixer should run before ArrayIndentationFixer
2 parents e0c7ee1 + a6bd13c commit 6faba9d

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

src/Fixer/Whitespace/ArrayIndentationFixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function isCandidate(Tokens $tokens)
4949
*/
5050
public function getPriority()
5151
{
52-
// should run after BracesFixer
52+
// should run after BracesFixer, MethodChainingIndentationFixer
5353
return -30;
5454
}
5555

src/Fixer/Whitespace/MethodChainingIndentationFixer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ public function getDefinition()
4343
public function getPriority()
4444
{
4545
// Should run after BracesFixer
46-
return -30;
46+
// Should run before ArrayIndentationFixer
47+
return -29;
4748
}
4849

4950
/**

tests/AutoReview/FixerFactoryTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public function provideFixersPriorityCases()
9898
[$fixers['is_null'], $fixers['yoda_style']],
9999
[$fixers['list_syntax'], $fixers['binary_operator_spaces']],
100100
[$fixers['list_syntax'], $fixers['ternary_operator_spaces']],
101+
[$fixers['method_chaining_indentation'], $fixers['array_indentation']],
101102
[$fixers['method_separation'], $fixers['braces']],
102103
[$fixers['method_separation'], $fixers['indentation_type']],
103104
[$fixers['no_alias_functions'], $fixers['php_unit_dedicate_assert']],
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--TEST--
2+
Integration of fixers: method_chaining_indentation,array_indentation.
3+
--RULESET--
4+
{"array_indentation": true, "method_chaining_indentation": true}
5+
--EXPECT--
6+
<?php
7+
function foo($foo)
8+
{
9+
$foo
10+
->bar()
11+
->baz([
12+
'foo' => 'bar',
13+
])
14+
;
15+
}
16+
17+
--INPUT--
18+
<?php
19+
function foo($foo)
20+
{
21+
$foo
22+
->bar()
23+
->baz([
24+
'foo' => 'bar',
25+
])
26+
;
27+
}

0 commit comments

Comments
 (0)