Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ClassNamingSniff.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 
23 class ClassNamingSniff implements Sniff
24 {
25 
27 
29 
36 
40  public function register()
41  {
42  return [T_STRING_CONCAT];
43  }
44 
48  public function process(File $phpcsFile, $stackPtr)
49  {
50  $tokens = $phpcsFile->getTokens();
51 
52  if (T_WHITESPACE !== $tokens[$stackPtr - 1]['code']
53  && !in_array($tokens[$stackPtr - 1]['content'], [
56  ])
57  ) {
58  return;
59  }
60 
61  $className = $tokens[$stackPtr + 1]['content'];
62  if (preg_match_all('/[^a-z0-9\-_]/U', $className, $matches)) {
63  $phpcsFile->addError('Class name contains not allowed symbols', $stackPtr, 'NotAllowedSymbol', $matches);
64  }
65  }
66 }
process(File $phpcsFile, $stackPtr)
$tokens
Definition: cards_list.phtml:9
if($currentSelectedMethod==$_code) $className
Definition: form.phtml:31