public function fix(\SplFileInfo $file, Tokens $tokens)
{
for ($index = $tokens->count() - 1; $index >= 0; --$index) {
$token = $tokens[$index];
if (!$token->equals(array(T_STRING, 'trigger_error'), false)) {
continue;
}
$start = $index;
$prev = $tokens->getPrevMeaningfulToken($start);
if ($tokens[$prev]->isGivenKind(T_NS_SEPARATOR)) {
$start = $prev;
$prev = $tokens->getPrevMeaningfulToken($start);
}
if ($tokens[$prev]->isGivenKind(T_STRING) || $tokens[$prev]->equals('@')) {
continue;
}
$end = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $tokens->getNextTokenOfKind($index, array(T_STRING, '(')));
if ($tokens[$tokens->getPrevMeaningfulToken($end)]->equals(array(T_STRING, 'E_USER_DEPRECATED'))) {
$tokens->insertAt($start, new Token('@'));
}
}
}