class Drupal_Sniffs_CSS_ColourDefinitionSniff in Coder 7.2
Squiz_Sniffs_CSS_ColourDefinitionSniff.
Ensure colours are defined in lower-case.
@category PHP @package PHP_CodeSniffer @link http://pear.php.net/package/PHP_CodeSniffer
Hierarchy
- class \Drupal_Sniffs_CSS_ColourDefinitionSniff implements \PHP_CodeSniffer_Sniff
Expanded class hierarchy of Drupal_Sniffs_CSS_ColourDefinitionSniff
File
- coder_sniffer/
Drupal/ Sniffs/ CSS/ ColourDefinitionSniff.php, line 21
View source
class Drupal_Sniffs_CSS_ColourDefinitionSniff implements PHP_CodeSniffer_Sniff {
/**
* A list of tokenizers this sniff supports.
*
* @var array
*/
public $supportedTokenizers = array(
'CSS',
);
/**
* Returns the token types that this sniff is interested in.
*
* @return array(int)
*/
public function register() {
return array(
T_COLOUR,
);
}
//end register()
/**
* Processes the tokens that this sniff is interested in.
*
* @param PHP_CodeSniffer_File $phpcsFile The file where the token was found.
* @param int $stackPtr The position in the stack where
* the token was found.
*
* @return void
*/
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
$tokens = $phpcsFile
->getTokens();
$colour = $tokens[$stackPtr]['content'];
$expected = strtolower($colour);
if ($colour !== $expected) {
$error = 'CSS colours must be defined in lowercase; expected %s but found %s';
$data = array(
$expected,
$colour,
);
$phpcsFile
->addError($error, $stackPtr, 'NotLower', $data);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Drupal_Sniffs_CSS_ColourDefinitionSniff:: |
public | property | A list of tokenizers this sniff supports. | |
Drupal_Sniffs_CSS_ColourDefinitionSniff:: |
public | function | Processes the tokens that this sniff is interested in. | |
Drupal_Sniffs_CSS_ColourDefinitionSniff:: |
public | function | Returns the token types that this sniff is interested in. |