Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields
ClassNamingSniff Class Reference
Inheritance diagram for ClassNamingSniff:

Public Member Functions

 register ()
 
 process (File $phpcsFile, $stackPtr)
 

Data Fields

const STRING_HELPER_CLASSES_PREFIX = '_'
 
const STRING_ALLOWED_UNDERSCORES = '__'
 
 $supportedTokenizers = [TokenizerSymbolsInterface::TOKENIZER_CSS]
 

Detailed Description

Class ClassNamingSniff

Ensure that class name responds to the following requirements:

http://devdocs.magento.com/guides/v2.0/coding-standards/code-standard-less.html#standard-classes

Definition at line 23 of file ClassNamingSniff.php.

Member Function Documentation

◆ process()

process ( File  $phpcsFile,
  $stackPtr 
)

{}

Definition at line 48 of file ClassNamingSniff.php.

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  }
$tokens
Definition: cards_list.phtml:9
if($currentSelectedMethod==$_code) $className
Definition: form.phtml:31

◆ register()

register ( )

{}

Definition at line 40 of file ClassNamingSniff.php.

41  {
42  return [T_STRING_CONCAT];
43  }

Field Documentation

◆ $supportedTokenizers

$supportedTokenizers = [TokenizerSymbolsInterface::TOKENIZER_CSS]

Definition at line 35 of file ClassNamingSniff.php.

◆ STRING_ALLOWED_UNDERSCORES

const STRING_ALLOWED_UNDERSCORES = '__'

Definition at line 28 of file ClassNamingSniff.php.

◆ STRING_HELPER_CLASSES_PREFIX

const STRING_HELPER_CLASSES_PREFIX = '_'

Definition at line 26 of file ClassNamingSniff.php.


The documentation for this class was generated from the following file: