public function Drupal_Sniffs_Semantics_LStringTranslatableSniff::processFunctionCall in Coder 7.2
Processes this function call.
Parameters
PHP_CodeSniffer_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.
Drupal_Sniffs_Semantics_FunctionCallSniff $sniff: Can be used to retreive the function's arguments with the getArgument() method.
Return value
void
Overrides Drupal_Sniffs_Semantics_FunctionCall::processFunctionCall
File
- coder_sniffer/
Drupal/ Sniffs/ Semantics/ LStringTranslatableSniff.php, line 52
Class
- Drupal_Sniffs_Semantics_LStringTranslatableSniff
- Checks that string literals passed to l() are translatable.
Code
public function processFunctionCall(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $openBracket, $closeBracket, Drupal_Sniffs_Semantics_FunctionCallSniff $sniff) {
$tokens = $phpcsFile
->getTokens();
// Get the first argument passed to l().
$argument = $sniff
->getArgument(1);
if ($tokens[$argument['start']]['code'] === T_CONSTANT_ENCAPSED_STRING && $tokens[$argument['start']]['content'][1] !== '<') {
$error = 'The $text argument to l() should be enclosed within t() so that it is translatable';
$phpcsFile
->addError($error, $stackPtr, 'LArg');
}
}