Skip to content

Commit f7a1bb6

Browse files
committed
Merge branch '2.12' into 2.14
* 2.12: Change BracesFixer to avoid indenting PHP inline brace before a closing tag, add test
2 parents 055ad6d + dbcbead commit f7a1bb6

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/Fixer/Basic/BracesFixer.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,11 @@ static function ($item) {
342342
continue;
343343
}
344344

345+
/* if CLOSE_TAG is after { on the same line, do not indent. e.g. <?php if ($condition) { ?> */
346+
if ($tokens[$tokens->getNextNonWhitespace($startBraceIndex, " \t")]->isGivenKind(T_CLOSE_TAG)) {
347+
continue;
348+
}
349+
345350
$endBraceIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $startBraceIndex);
346351

347352
$indent = $this->detectIndent($tokens, $index);

tests/Fixer/Basic/BracesFixerTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,14 @@ public function bar() {
806806
}
807807
}',
808808
],
809+
[
810+
'<?php if ($condition) { ?>
811+
echo 1;
812+
<?php } else { ?>
813+
echo 2;
814+
<?php } ?>
815+
',
816+
],
809817
];
810818
}
811819

0 commit comments

Comments
 (0)