3
* Squiz_Sniffs_ControlStructures_ElseIfDeclarationSniff.
8
* @package PHP_CodeSniffer
9
* @author Greg Sherwood <gsherwood@squiz.net>
10
* @author Marc McIntyre <mmcintyre@squiz.net>
11
* @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
12
* @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
13
* @version CVS: $Id: ElseIfDeclarationSniff.php,v 1.2 2007/07/23 01:47:53 squiz Exp $
14
* @link http://pear.php.net/package/PHP_CodeSniffer
18
* Squiz_Sniffs_ControlStructures_ElseIfDeclarationSniff.
20
* Verifies that there are not elseif statements. The else and the if should
21
* be separated by a space.
24
* @package PHP_CodeSniffer
25
* @author Greg Sherwood <gsherwood@squiz.net>
26
* @author Marc McIntyre <mmcintyre@squiz.net>
27
* @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
28
* @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
29
* @version Release: 1.1.0
30
* @link http://pear.php.net/package/PHP_CodeSniffer
32
class Squiz_Sniffs_ControlStructures_ElseIfDeclarationSniff implements PHP_CodeSniffer_Sniff
37
* Returns an array of tokens this test wants to listen for.
41
public function register()
43
return array(T_ELSEIF);
49
* Processes this test, when one of its tokens is encountered.
51
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
52
* @param int $stackPtr The position of the current token in the
53
* stack passed in $tokens.
57
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
59
$error = 'Usage of ELSEIF not allowed. Use ELSE IF instead.';
60
$phpcsFile->addError($error, $stackPtr);