PhpParser\ErrorHandler::handleError PHP Method

handleError() public method

Handle an error generated during lexing, parsing or some other operation.
public handleError ( Error $error )
$error Error The error that needs to be handled
    public function handleError(Error $error);

Usage Example

Example #1
0
 private function handleInvalidCharacterRange($start, $end, $line, ErrorHandler $errorHandler)
 {
     for ($i = $start; $i < $end; $i++) {
         $chr = $this->code[$i];
         if ($chr === 'b' || $chr === 'B') {
             // HHVM does not treat b" tokens correctly, so ignore these
             continue;
         }
         if ($chr === "") {
             // 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' => $line, 'endLine' => $line, 'startFilePos' => $i, 'endFilePos' => $i]));
     }
 }
ErrorHandler