function UnsilencedDeprecationSniff::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
-
vendor/
drupal/ coder/ coder_sniffer/ Drupal/ Sniffs/ Semantics/ UnsilencedDeprecationSniff.php, line 50
Class
- UnsilencedDeprecationSniff
- Checks that the trigger_error deprecation is silenced by a preceding '@'.
Namespace
Drupal\Sniffs\SemanticsCode
public function processFunctionCall(file $phpcsFile, $stackPtr, $openBracket, $closeBracket) {
$tokens = $phpcsFile->getTokens();
$argument = $this->getArgument(2);
// If no second argument then quit.
if ($argument === false) {
return;
}
// Only check deprecation messages.
if (strcasecmp($tokens[$argument['start']]['content'], 'E_USER_DEPRECATED') !== 0) {
return;
}
if ($tokens[$stackPtr - 1]['type'] !== 'T_ASPERAND') {
$error = 'All trigger_error calls used for deprecation must be prefixed by an "@"';
$fix = $phpcsFile->addFixableError($error, $stackPtr, 'UnsilencedDeprecation');
if ($fix === true) {
$phpcsFile->fixer
->addContentBefore($stackPtr, '@');
}
}
}