Skip to content

Commit

Permalink
Allow some tokens, by code, to be ignored by the Sniff.
Browse files Browse the repository at this point in the history
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
stronk7 committed Feb 28, 2013
1 parent e5bc3c5 commit e6ed549
Showing 1 changed file with 17 additions and 0 deletions.
Expand Up @@ -49,6 +49,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.
*
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e6ed549

Please sign in to comment.