Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ImportantPropertySniff.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Sniffs\Less;
7 
8 use PHP_CodeSniffer\Sniffs\Sniff;
9 use PHP_CodeSniffer\Files\File;
10 
19 class ImportantPropertySniff implements Sniff
20 {
27 
31  public function register()
32  {
33  return [T_BOOLEAN_NOT];
34  }
35 
39  public function process(File $phpcsFile, $stackPtr)
40  {
41  $tokens = $phpcsFile->getTokens();
42 
43  // Will be implemented in MAGETWO-49778
44  //$phpcsFile->addWarning('!important is used', $stackPtr, '!ImportantIsUsed');
45 
46  if (($tokens[$stackPtr + 1]['content'] === 'important')
47  && ($tokens[$stackPtr - 1]['content'] !== TokenizerSymbolsInterface::WHITESPACE)
48  ) {
49  $phpcsFile->addError('Space before !important is missing', $stackPtr, 'NoSpace');
50  }
51  }
52 }
$tokens
Definition: cards_list.phtml:9