Skip to content

Commit

Permalink
Merge branch '2.14'
Browse files Browse the repository at this point in the history
* 2.14:
  Change BracesFixer to avoid indenting PHP inline brace before a closing tag, add test
  • Loading branch information
SpacePossum committed Mar 19, 2019
2 parents 6899287 + f7a1bb6 commit 47b2711
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Fixer/Basic/BracesFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,11 @@ static function ($item) {
continue;
}

/* if CLOSE_TAG is after { on the same line, do not indent. e.g. <?php if ($condition) { ?> */
if ($tokens[$tokens->getNextNonWhitespace($startBraceIndex, " \t")]->isGivenKind(T_CLOSE_TAG)) {
continue;
}

$endBraceIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $startBraceIndex);

$indent = $this->detectIndent($tokens, $index);
Expand Down
8 changes: 8 additions & 0 deletions tests/Fixer/Basic/BracesFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,14 @@ public function bar() {
}
}',
],
[
'<?php if ($condition) { ?>
echo 1;
<?php } else { ?>
echo 2;
<?php } ?>
',
],
];
}

Expand Down

0 comments on commit 47b2711

Please sign in to comment.