Skip to content

Commit

Permalink
Solution for the Allman/BSD style switch indentation, now check in al…
Browse files Browse the repository at this point in the history
…lman style if the control sequence is Switch, and then add one additional indentation
  • Loading branch information
jespino committed Aug 5, 2010
1 parent d603c81 commit 3695629
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Beautifier.php
Expand Up @@ -1819,5 +1819,16 @@ public function openBraceDontProcess()
or ($this->isPreviousTokenConstant(T_STRING) and $this->getPreviousTokenConstant(2) == T_OBJECT_OPERATOR)
or $this->getMode('double_quote');
}

/**
* getLastSeq: Return the last sequence block opened and not closed
*
* @access public
* @return int
*/
public function getLastSeq()
{
return $this->aControlSeq[count($this->aControlSeq)-1];
}
}
?>
6 changes: 6 additions & 0 deletions Beautifier/Filter/IndentStyles.filter.php
Expand Up @@ -155,6 +155,9 @@ function t_open_brace_bsd($sTag)
{
$this->oBeaut->addNewLineIndent();
$this->oBeaut->add($sTag);
if ($this->oBeaut->getLastSeq() == T_SWITCH) {
$this->oBeaut->incIndent();
}
$this->oBeaut->incIndent();
$this->oBeaut->addNewLineIndent();
}
Expand All @@ -173,6 +176,9 @@ function t_close_brace_bsd($sTag)
} else {
$this->oBeaut->removeWhitespace();
$this->oBeaut->decIndent();
if ($this->oBeaut->getLastSeq() == T_SWITCH) {
$this->oBeaut->decIndent();
}
$this->oBeaut->addNewLineIndent();
$this->oBeaut->add($sTag);
$this->oBeaut->addNewLineIndent();
Expand Down

0 comments on commit 3695629

Please sign in to comment.