Skip to content

Commit

Permalink
BracesFixer: allows empty lines before else, elseif, catch & finally
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Oct 29, 2020
1 parent c572609 commit 888670a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Fixer/Basic/BracesFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,10 @@ static function ($item) {
$indent = $this->detectIndent($tokens, $index);

// fix indent near closing brace
$tokens->ensureWhitespaceAtIndex($endBraceIndex - 1, 1, $this->whitespacesConfig->getLineEnding().$indent);
$endBraceNextNonWhitespaceIndex = $tokens->getNextNonWhitespace($endBraceIndex);
if ($endBraceNextNonWhitespaceIndex === NULL || !$tokens[$endBraceNextNonWhitespaceIndex]->isGivenKind([T_ELSE, T_ELSEIF, T_CATCH, T_FINALLY])) {
$tokens->ensureWhitespaceAtIndex($endBraceIndex - 1, 1, $this->whitespacesConfig->getLineEnding().$indent);
}

// fix indent between braces
$lastCommaIndex = $tokens->getPrevTokenOfKind($endBraceIndex - 1, [';', '}']);
Expand Down

0 comments on commit 888670a

Please sign in to comment.