1<?php 2/** 3 * Ensure that class definitions are not empty. 4 * 5 * @author Greg Sherwood <gsherwood@squiz.net> 6 * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) 7 * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence 8 */ 9 10namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS; 11 12use PHP_CodeSniffer\Files\File; 13use PHP_CodeSniffer\Sniffs\Sniff; 14use PHP_CodeSniffer\Util\Tokens; 15 16class EmptyClassDefinitionSniff implements Sniff 17{ 18 19 /** 20 * A list of tokenizers this sniff supports. 21 * 22 * @var array 23 */ 24 public $supportedTokenizers = ['CSS']; 25 26 27 /** 28 * Returns the token types that this sniff is interested in. 29 * 30 * @return int[] 31 */ 32 public function register() 33 { 34 return [T_OPEN_CURLY_BRACKET]; 35 36 }//end register() 37 38 39 /** 40 * Processes the tokens that this sniff is interested in. 41 * 42 * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found. 43 * @param int $stackPtr The position in the stack where 44 * the token was found. 45 * 46 * @return void 47 */ 48 public function process(File $phpcsFile, $stackPtr) 49 { 50 $tokens = $phpcsFile->getTokens(); 51 $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true); 52 53 if ($next === false || $tokens[$next]['code'] === T_CLOSE_CURLY_BRACKET) { 54 $error = 'Class definition is empty'; 55 $phpcsFile->addError($error, $stackPtr, 'Found'); 56 } 57 58 }//end process() 59 60 61}//end class 62