class Drupal_Sniffs_ControlStructures_ElseIfSniff in Coder 7.2
Verifies that control statements conform to their coding standards.
@category PHP @package PHP_CodeSniffer @author Greg Sherwood <gsherwood@squiz.net> @author Marc McIntyre <mmcintyre@squiz.net> @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600) @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence @version Release: 1.2.0RC3 @link http://pear.php.net/package/PHP_CodeSniffer
Hierarchy
- class \Drupal_Sniffs_ControlStructures_ElseIfSniff implements \PHP_CodeSniffer_Sniff
Expanded class hierarchy of Drupal_Sniffs_ControlStructures_ElseIfSniff
File
- coder_sniffer/
Drupal/ Sniffs/ ControlStructures/ ElseIfSniff.php, line 32
View source
class Drupal_Sniffs_ControlStructures_ElseIfSniff implements PHP_CodeSniffer_Sniff {
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
*/
public function register() {
return array(
T_ELSE,
);
}
//end register()
/**
* Processes this test, when one of its tokens is encountered.
*
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
* @param int $stackPtr The position of the current token in the
* stack passed in $tokens.
*
* @return void
*/
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
$tokens = $phpcsFile
->getTokens();
$nextNonWhiteSpace = $phpcsFile
->findNext(T_WHITESPACE, $stackPtr + 1, null, true, null, true);
if ($tokens[$nextNonWhiteSpace]['code'] == T_IF) {
$phpcsFile
->addError('Use "elseif" in place of "else if"', $nextNonWhiteSpace);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Drupal_Sniffs_ControlStructures_ElseIfSniff:: |
public | function | Processes this test, when one of its tokens is encountered. | |
Drupal_Sniffs_ControlStructures_ElseIfSniff:: |
public | function | Returns an array of tokens this test wants to listen for. |