WordPress-Coding-Standards/Sniffs/VIP/AdminBarRemovalSniff.php
Shady Sharaf b830b3c16a Flag removal of admin bar
Closes #77
2013-10-20 18:42:17 +02:00

51 lines
1.2 KiB
PHP

<?php
/**
* Verifies that all outputted strings are sanitized
*
* @category PHP
* @package PHP_CodeSniffer
* @author Shady Sharaf <shady@x-team.com>
* @link http://codex.wordpress.org/Data_Validation Data Validation on WordPress Codex
*/
class WordPress_Sniffs_VIP_AdminBarRemovalSniff implements PHP_CodeSniffer_Sniff
{
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
*/
public function register()
{
return array(
T_STRING,
T_CONSTANT_ENCAPSED_STRING,
T_DOUBLE_QUOTED_STRING,
);
}//end register()
/**
* 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();
if ( in_array( trim( $tokens[$stackPtr]['content'], '"\'' ), array( 'show_admin_bar' ) ) ) {
$phpcsFile->addError( 'Removal of admin bar is prohibited.', $stackPtr );
}
}//end process()
}//end class
?>