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

Public Member Functions

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

Detailed Description

Sniff prohibiting usage of global variables.

Definition at line 15 of file GlobalVariablesSniff.php.

Member Function Documentation

◆ process()

process ( File  $phpcsFile,
  $stackPtr 
)

Definition at line 28 of file GlobalVariablesSniff.php.

29  {
30  $tokens = $phpcsFile->getTokens();
31  if (preg_match('/^\$[_A-Z0-9]+$/', $tokens[$stackPtr]['content'])) {
32  $phpcsFile->addError(
33  'Usage of global variables is not allowed: ' . $tokens[$stackPtr]['content'],
34  $stackPtr,
35  'ERROR'
36  );
37  return;
38  }
39  }
$tokens
Definition: cards_list.phtml:9

◆ register()

register ( )

Definition at line 20 of file GlobalVariablesSniff.php.

21  {
22  return [T_VARIABLE];
23  }

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