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

Breadcrumb

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

function Lexer::handleInvalidCharacter

1 call to Lexer::handleInvalidCharacter()
Lexer::postprocessTokens in vendor/nikic/php-parser/lib/PhpParser/Lexer.php

File

vendor/nikic/php-parser/lib/PhpParser/Lexer.php, line 41

Class

Lexer

Namespace

PhpParser

Code

private function handleInvalidCharacter(Token $token, ErrorHandler $errorHandler) : void {
    $chr = $token->text;
    if ($chr === "\x00") {
        // PHP cuts error message after null byte, so need special case
        $errorMsg = 'Unexpected null byte';
    }
    else {
        $errorMsg = sprintf('Unexpected character "%s" (ASCII %d)', $chr, ord($chr));
    }
    $errorHandler->handleError(new Error($errorMsg, [
        'startLine' => $token->line,
        'endLine' => $token->line,
        'startFilePos' => $token->pos,
        'endFilePos' => $token->pos,
    ]));
}
RSS feed
Powered by Drupal