Permalink
Browse files

Merge branch 'master' of https://github.com/asnyder/PHP_CodeSniffer

  • Loading branch information...
gsherwood committed Feb 18, 2013
2 parents 44f7cc8 + 7c10e36 commit 9ca728259e8d9ff01448853b7876a959a65bbaa6
Showing with 10 additions and 3 deletions.
  1. +10 −3 CodeSniffer/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php
@@ -29,6 +29,13 @@ class PSR2_Sniffs_ControlStructures_SwitchDeclarationSniff implements PHP_CodeSn
{
+ /**
+ * The number of spaces code should be indented.
+ *
+ * @var int
+ */
+ public $indent = 4;
+
/**
* Returns an array of tokens this test wants to listen for.
*
@@ -63,7 +70,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
$switch = $tokens[$stackPtr];
$nextCase = $stackPtr;
- $caseAlignment = ($switch['column'] + 4);
+ $caseAlignment = ($switch['column'] + $this->indent);
$caseCount = 0;
$foundDefault = false;
@@ -87,7 +94,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
}
if ($tokens[$nextCase]['column'] !== $caseAlignment) {
- $error = strtoupper($type).' keyword must be indented 4 spaces from SWITCH keyword';
+ $error = strtoupper($type).' keyword must be indented ' . $this->indent . ' spaces from SWITCH keyword';
$phpcsFile->addError($error, $nextCase, $type.'Indent');
}
@@ -123,7 +130,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
// Only need to check some things once, even if the
// closer is shared between multiple case statements, or even
// the default case.
- if ($tokens[$nextCloser]['column'] !== ($caseAlignment + 4)) {
+ if ($tokens[$nextCloser]['column'] !== ($caseAlignment + $this->indent)) {
$error = 'Terminating statement must be indented to the same level as the CASE body';
$phpcsFile->addError($error, $nextCloser, 'BreakIndent');
}

0 comments on commit 9ca7282

Please sign in to comment.