Skip to content

Commit

Permalink
bug #1840 [Bug] BracesFixer - Do add a line before close tag (SpacePo…
Browse files Browse the repository at this point in the history
…ssum)

This PR was submitted for the 1.12 branch but it was merged into the 1.11 branch instead (closes #1840).

Discussion
----------

[Bug] BracesFixer - Do add a line before close tag

Test for #1829

Commits
-------

9578a00 Handle close tag.
  • Loading branch information
keradus committed Jun 15, 2016
2 parents 361c891 + 9578a00 commit 521f522
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Symfony/CS/Fixer/PSR2/BracesFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ function ($item) {
// and it is not a `${"a"}->...` and `${"b{$foo}"}->...` situation
!($nestToken->equals('}') && $tokens[$nestIndex - 1]->equalsAny(array('"', "'", array(T_CONSTANT_ENCAPSED_STRING))))
) {
if ($nextNonWhitespaceNestToken->isGivenKind($this->getControlContinuationTokens())) {
if ($nextNonWhitespaceNestToken->isGivenKind($this->getControlContinuationTokens()) || $nextNonWhitespaceNestToken->isGivenKind(T_CLOSE_TAG)) {
$whitespace = ' ';
} else {
$nextToken = $tokens[$nestIndex + 1];
Expand Down
14 changes: 14 additions & 0 deletions Symfony/CS/Tests/Fixer/PSR2/BracesFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ public function provideFixControlContinuationBracesCases()
return array(
array(
'<?php
class Foo
{
public function A()
{
?>
Test<?php echo $foobar; ?>Test
<?php
$a = 1;
}
}
',
),
array(
'<?php
if (true) {
$a = 1;
} else {
Expand Down

0 comments on commit 521f522

Please sign in to comment.