Skip to content

Commit

Permalink
Priority: Braces before MethodChainingIndentation
Browse files Browse the repository at this point in the history
  • Loading branch information
dmvdbrugge committed Nov 8, 2018
1 parent d1e1ae2 commit c0358e8
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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 c0358e8

Please sign in to comment.