/** * Returns an array of tokens this test wants to listen for. * * @return array */ public function register() { $tokens = parent::register(); $tokens[] = T_PRINT; $tokens[] = T_ECHO; return $tokens; }
/** * 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(); $nextToken = $phpcsFile->findNext(T_WHITESPACE, $stackPtr + 1, null, true); if ($tokens[$nextToken]['code'] !== T_OPEN_PARENTHESIS) { // není to volání PHP function. return; } $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, $stackPtr - 1, null, true); if ($tokens[$prevToken]['code'] === T_COMMENT && trim($tokens[$prevToken]['content'], "!/ \n") === 'important') { // funkce je tam záměrně return; } parent::process($phpcsFile, $stackPtr); }
/** * Returns an array of tokens this test wants to listen for. * * @return array */ public function register() { $tokens = parent::register(); $tokens[] = T_EXIT; return $tokens; }