true, ]; /** * Returns an array of tokens this test wants to listen for. * * @return array */ public function register() { return Tokens::$includeTokens; } /** * Processes this test, when one of its tokens is encountered. * * @param \PHP_CodeSniffer\Files\File $phpcsFile The PHP_CodeSniffer file where the * token was found. * @param int $stackPtr The position of the current token * in the stack. * * @return void */ public function process( File $phpcsFile, $stackPtr ) { $tokens = $phpcsFile->getTokens(); $token = $tokens[ $stackPtr ]; $file_name = basename( $phpcsFile->getFileName() ); if ( ! isset( $this->file_whitelist[ $file_name ] ) ) { $phpcsFile->addWarning( 'Check that %s is not being used to load template files. "get_template_part()" should be used to load template files.', $stackPtr, 'FileIncludeFound', [ $token['content'] ] ); } } }