Skip to content

Commit

Permalink
bug #4084 MethodChainingIndentation - fix priority with Braces (dmvdb…
Browse files Browse the repository at this point in the history
…rugge)

This PR was merged into the 2.12 branch.

Discussion
----------

MethodChainingIndentation - fix priority with Braces

Fixes #3854

Commits
-------

c0358e8 Priority: Braces before MethodChainingIndentation
  • Loading branch information
keradus committed Nov 12, 2018
2 parents bb2d1f3 + c0358e8 commit 5d82d40
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Fixer/Whitespace/MethodChainingIndentationFixer.php
Expand Up @@ -37,6 +37,15 @@ public function getDefinition()
);
}

/**
* {@inheritdoc}
*/
public function getPriority()
{
// Should run after BracesFixer
return -30;
}

/**
* {@inheritdoc}
*/
Expand Down
1 change: 1 addition & 0 deletions tests/AutoReview/FixerFactoryTest.php
Expand Up @@ -66,6 +66,7 @@ public function provideFixersPriorityCases()
[$fixers['backtick_to_shell_exec'], $fixers['escape_implicit_backslashes']],
[$fixers['blank_line_after_opening_tag'], $fixers['no_blank_lines_before_namespace']],
[$fixers['braces'], $fixers['array_indentation']],
[$fixers['braces'], $fixers['method_chaining_indentation']],
[$fixers['class_attributes_separation'], $fixers['braces']],
[$fixers['class_attributes_separation'], $fixers['indentation_type']],
[$fixers['class_keyword_remove'], $fixers['no_unused_imports']],
Expand Down
@@ -0,0 +1,37 @@
--TEST--
Integration of fixers: braces,method_chaining_indentation.
--RULESET--
{"braces": true, "method_chaining_indentation": true}
--EXPECT--
<?php
class SomeUnitTest extends PHPUnit\Framework\TestCase
{
public function testSomething()
{
// *Only* the next line is indented wrong _before_ fixing
$this->entity
->expects($this->once())
->method('toXml')
->willReturnCallback(
function (\DOMDocument $dom) {
return $dom->createElement('elem');
});
}
}

--INPUT--
<?php
class SomeUnitTest extends PHPUnit\Framework\TestCase
{
public function testSomething()
{
// *Only* the next line is indented wrong _before_ fixing
$this->entity
->expects($this->once())
->method('toXml')
->willReturnCallback(
function (\DOMDocument $dom) {
return $dom->createElement('elem');
});
}
}

0 comments on commit 5d82d40

Please sign in to comment.