Skip to content
Browse files

Allow some tokens, by code, to be ignored by the Sniff.

Useful when there are different rules to perform in places like
inline html, open/close php tags, this allows easier subclassing
for customization.
  • Loading branch information...
1 parent e5bc3c5 commit e6ed549b87bd0c9eff899f0efcde8a3eb03807e4 @stronk7 stronk7 committed Feb 28, 2013
Showing with 17 additions and 0 deletions.
  1. +17 −0 CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php
View
17 CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php
@@ -50,6 +50,18 @@ class Generic_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Snif
public $exact = false;
/**
+ * List of tokens not needing to be checked for indentation.
+ *
+ * Useful to allow Sniffs based on this to easily ignore/skip some
+ * tokens from verification. For example, inline html sections
+ * or php open/close tags can escape from here and have their own
+ * rules elsewhere.
+ *
+ * @var array
+ */
+ public $ignoreIndentationTokens = array();
+
+ /**
* Any scope openers that should not cause an indent.
*
* @var array(int)
@@ -224,6 +236,11 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
$column = $tokens[$firstToken]['column'];
+ // Ignore the token for indentation if it's in the ignore list.
+ if (in_array($tokens[$firstToken]['code'], $this->ignoreIndentationTokens)) {
+ continue;
+ }
+
// Special case for non-PHP code.
if ($tokens[$firstToken]['code'] === T_INLINE_HTML) {
$trimmedContentLength

0 comments on commit e6ed549

Please sign in to comment.
Something went wrong with that request. Please try again.