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

Public Member Functions

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

Protected Attributes

 $previousLineContent = ''
 

Detailed Description

Make sure that constants are not used as the first argument of translation function.

Definition at line 14 of file ConstantUsageSniff.php.

Member Function Documentation

◆ process()

process ( File  $phpcsFile,
  $stackPtr 
)

Copied from \Generic_Sniffs_Files_LineLengthSniff, minor changes made

Definition at line 36 of file ConstantUsageSniff.php.

37  {
38  $tokens = $phpcsFile->getTokens();
39 
40  // Make sure this is the first open tag
41  $previousOpenTag = $phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1));
42  if ($previousOpenTag !== false) {
43  return;
44  }
45 
46  $tokenCount = 0;
47  $currentLineContent = '';
48  $currentLine = 1;
49 
50  for (; $tokenCount < $phpcsFile->numTokens; $tokenCount++) {
51  if ($tokens[$tokenCount]['line'] === $currentLine) {
52  $currentLineContent .= $tokens[$tokenCount]['content'];
53  } else {
54  $this->checkIfFirstArgumentConstant($phpcsFile, ($tokenCount - 1), $currentLineContent);
55  $currentLineContent = $tokens[$tokenCount]['content'];
56  $currentLine++;
57  }
58  }
59 
60  $this->checkIfFirstArgumentConstant($phpcsFile, ($tokenCount - 1), $currentLineContent);
61  }
$tokens
Definition: cards_list.phtml:9

◆ register()

register ( )

Definition at line 26 of file ConstantUsageSniff.php.

27  {
28  return [T_OPEN_TAG];
29  }

Field Documentation

◆ $previousLineContent

$previousLineContent = ''
protected

Definition at line 21 of file ConstantUsageSniff.php.


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