Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Solution for the Allman/BSD style switch indentation, now check in al…

…lman style if the control sequence is Switch, and then add one additional indentation
  • Loading branch information...
commit 36956298ee60ea9b21ab8ce6fd237ab7fbf87141 1 parent d603c81
Jesús Espino jespino authored
Showing with 17 additions and 0 deletions.
  1. +11 −0 Beautifier.php
  2. +6 −0 Beautifier/Filter/IndentStyles.filter.php
11 Beautifier.php
View
@@ -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 Beautifier/Filter/IndentStyles.filter.php
View
@@ -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();
}
@@ -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();
Please sign in to comment.
Something went wrong with that request. Please try again.