1<?php 2/** 3 * Ensures that console is not used for function or var names. 4 * 5 * PHP version 5 6 * 7 * @category PHP 8 * @package PHP_CodeSniffer_MySource 9 * @author Greg Sherwood <gsherwood@squiz.net> 10 * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600) 11 * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence 12 * @link http://pear.php.net/package/PHP_CodeSniffer 13 */ 14 15/** 16 * Ensures that console is not used for function or var names. 17 * 18 * @category PHP 19 * @package PHP_CodeSniffer_MySource 20 * @author Greg Sherwood <gsherwood@squiz.net> 21 * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600) 22 * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence 23 * @version Release: @package_version@ 24 * @link http://pear.php.net/package/PHP_CodeSniffer 25 */ 26class MySource_Sniffs_Debug_FirebugConsoleSniff implements PHP_CodeSniffer_Sniff 27{ 28 29 /** 30 * A list of tokenizers this sniff supports. 31 * 32 * @var array 33 */ 34 public $supportedTokenizers = array('JS'); 35 36 37 /** 38 * Returns an array of tokens this test wants to listen for. 39 * 40 * @return array 41 */ 42 public function register() 43 { 44 return array( 45 T_STRING, 46 T_PROPERTY, 47 T_LABEL, 48 T_OBJECT, 49 ); 50 51 }//end register() 52 53 54 /** 55 * Processes this test, when one of its tokens is encountered. 56 * 57 * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. 58 * @param int $stackPtr The position of the current token 59 * in the stack passed in $tokens. 60 * 61 * @return void 62 */ 63 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) 64 { 65 $tokens = $phpcsFile->getTokens(); 66 67 if (strtolower($tokens[$stackPtr]['content']) === 'console') { 68 $error = 'Variables, functions and labels must not be named "console"; name may conflict with Firebug internal variable'; 69 $phpcsFile->addError($error, $stackPtr, 'ConflictFound'); 70 } 71 72 }//end process() 73 74 75}//end class 76