You are here

public function FormErrorTSniff::processFunctionCall in Coder 8.2

Same name and namespace in other branches
  1. 8.3 coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/FormErrorTSniff.php \DrupalPractice\Sniffs\FunctionCalls\FormErrorTSniff::processFunctionCall()
  2. 8.3.x coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/FormErrorTSniff.php \DrupalPractice\Sniffs\FunctionCalls\FormErrorTSniff::processFunctionCall()

Processes this function call.

Parameters

\PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.:

int $stackPtr The position of the function call in: the stack.

int $openBracket The position of the opening: parenthesis in the stack.

int $closeBracket The position of the closing: parenthesis in the stack.

Return value

void

File

coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/FormErrorTSniff.php, line 54

Class

FormErrorTSniff
Verifiies that messages passed to form_set_error() run through t().

Namespace

DrupalPractice\Sniffs\FunctionCalls

Code

public function processFunctionCall(File $phpcsFile, $stackPtr, $openBracket, $closeBracket) {
  $tokens = $phpcsFile
    ->getTokens();
  $argument = $this
    ->getArgument(2);
  if ($argument !== false && $tokens[$argument['start']]['code'] === T_CONSTANT_ENCAPSED_STRING) {
    $warning = 'Form error messages are user facing text and must run through t() for translation';
    $phpcsFile
      ->addWarning($warning, $argument['start'], 'ErrorMessage');
  }
}