function Emulative::fixupErrors
Fixup line and position information in errors.
Parameters
Error[] $errors:
1 call to Emulative::fixupErrors()
- Emulative::tokenize in vendor/
nikic/ php-parser/ lib/ PhpParser/ Lexer/ Emulative.php - Tokenize the provided source code.
File
-
vendor/
nikic/ php-parser/ lib/ PhpParser/ Lexer/ Emulative.php, line 197
Class
Namespace
PhpParser\LexerCode
private function fixupErrors(array $errors) : void {
foreach ($errors as $error) {
$attrs = $error->getAttributes();
$posDelta = 0;
$lineDelta = 0;
foreach ($this->patches as $patch) {
list($patchPos, $patchType, $patchText) = $patch;
if ($patchPos >= $attrs['startFilePos']) {
// No longer relevant
break;
}
if ($patchType === 'add') {
$posDelta += strlen($patchText);
$lineDelta += substr_count($patchText, "\n");
}
elseif ($patchType === 'remove') {
$posDelta -= strlen($patchText);
$lineDelta -= substr_count($patchText, "\n");
}
}
$attrs['startFilePos'] += $posDelta;
$attrs['endFilePos'] += $posDelta;
$attrs['startLine'] += $lineDelta;
$attrs['endLine'] += $lineDelta;
$error->setAttributes($attrs);
}
}