Skip to content

Commit

Permalink
PhpParserDecorator - report file with error
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Nov 27, 2020
1 parent 95c47b1 commit 41f6d34
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Parser/PhpParserDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ public function parse(string $code, ?ErrorHandler $errorHandler = null): array
try {
return $this->wrappedParser->parseString($code);
} catch (\PHPStan\Parser\ParserErrorsException $e) {
throw new \PhpParser\Error($e->getMessage());
$message = $e->getMessage();
if ($e->getParsedFile() !== null) {
$message .= sprintf(' in file %s', $e->getParsedFile());
}
throw new \PhpParser\Error($message);
}
}

Expand Down

0 comments on commit 41f6d34

Please sign in to comment.