public function testWarningCanBeCreatedFromTokenizerError()
 {
     $tokenizerError = new TokenizerException('Could not read stuff', 0, NULL, 4321);
     $warning = Warning::createFromTokenizerError($tokenizerError);
     $this->assertEquals('Tokenization error: Could not read stuff', $warning->getMessage());
     $this->assertEquals(Warning::SEVERITY_ERROR, $warning->getSeverity());
     $this->assertEquals(4321, $warning->getLine());
 }
Example #2
0
 /**
  * @param string                                            $filename
  * @param \Helmich\TypoScriptLint\Linter\Report\Report            $report
  * @param \Helmich\TypoScriptLint\Linter\LinterConfiguration      $configuration
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  */
 public function lintFile($filename, Report $report, LinterConfiguration $configuration, OutputInterface $output)
 {
     $file = new File($filename);
     try {
         $tokens = $this->tokenizer->tokenizeStream($filename);
         $statements = $this->parser->parseTokens($tokens);
         $this->lintTokenStream($tokens, $file, $configuration, $output);
         $this->lintSyntaxTree($statements, $file, $configuration, $output);
     } catch (TokenizerException $tokenizerException) {
         $file->addWarning(Warning::createFromTokenizerError($tokenizerException));
     } catch (ParseError $parseError) {
         $file->addWarning(Warning::createFromParseError($parseError));
     }
     if (count($file->getWarnings()) > 0) {
         $report->addFile($file);
     }
 }