Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Emulative.php

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

Emulative

Namespace

PhpParser\Lexer

Code

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);
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal