|
@@ -27,7 +27,7 @@ final class TokenizerLinter implements LinterInterface
|
|
|
{
|
|
|
public function __construct()
|
|
|
{
|
|
|
- if (false === \defined('TOKEN_PARSE')) {
|
|
|
+ if (false === \defined('TOKEN_PARSE') || false === class_exists(\CompileError::class)) {
|
|
|
throw new UnavailableLinterException('Cannot use tokenizer as linter.');
|
|
|
}
|
|
|
}
|
|
@@ -55,7 +55,7 @@ final class TokenizerLinter implements LinterInterface
|
|
|
{
|
|
|
try {
|
|
|
// To lint, we will parse the source into Tokens.
|
|
|
- // During that process, it might throw ParseError.
|
|
|
+ // During that process, it might throw a ParseError or CompileError.
|
|
|
// If it won't, cache of tokenized version of source will be kept, which is great for Runner.
|
|
|
// Yet, first we need to clear already existing cache to not hit it and lint the code indeed.
|
|
|
$codeHash = CodeHasher::calculateCodeHash($source);
|
|
@@ -65,6 +65,8 @@ final class TokenizerLinter implements LinterInterface
|
|
|
return new TokenizerLintingResult();
|
|
|
} catch (\ParseError $e) {
|
|
|
return new TokenizerLintingResult($e);
|
|
|
+ } catch (\CompileError $e) {
|
|
|
+ return new TokenizerLintingResult($e);
|
|
|
}
|
|
|
}
|
|
|
}
|