/**
  * Writes a report in checkstyle XML format.
  *
  * @param \Helmich\TypoScriptLint\Linter\Report\Report $report The report to print.
  * @return void
  */
 public function writeReport(Report $report)
 {
     $xml = new \DOMDocument('1.0', 'UTF-8');
     $root = $xml->createElement('checkstyle');
     $root->setAttribute('version', APP_NAME . '-' . APP_VERSION);
     foreach ($report->getFiles() as $file) {
         $xmlFile = $xml->createElement('file');
         $xmlFile->setAttribute('name', $file->getFilename());
         foreach ($file->getWarnings() as $warning) {
             $xmlWarning = $xml->createElement('error');
             $xmlWarning->setAttribute('line', $warning->getLine());
             $xmlWarning->setAttribute('severity', $warning->getSeverity());
             $xmlWarning->setAttribute('message', $warning->getMessage());
             $xmlWarning->setAttribute('source', $warning->getSource());
             if ($warning->getColumn() !== NULL) {
                 $xmlWarning->setAttribute('column', $warning->getColumn());
             }
             $xmlFile->appendChild($xmlWarning);
         }
         $root->appendChild($xmlFile);
     }
     $xml->appendChild($root);
     $xml->formatOutput = TRUE;
     $this->output->write($xml->saveXML());
 }
 /**
  * Writes a report in human-readable table form.
  *
  * @param \Helmich\TypoScriptLint\Linter\Report\Report $report The report to print.
  * @return void
  */
 public function writeReport(Report $report)
 {
     $count = 0;
     $this->output->writeln('');
     $this->output->writeln('<comment>CHECKSTYLE REPORT</comment>');
     $styleMap = [Warning::SEVERITY_ERROR => 'error', Warning::SEVERITY_WARNING => 'comment', Warning::SEVERITY_INFO => 'info'];
     foreach ($report->getFiles() as $file) {
         $this->output->writeln("=> <comment>{$file->getFilename()}</comment>.");
         foreach ($file->getWarnings() as $warning) {
             $count++;
             $style = $styleMap[$warning->getSeverity()];
             $this->output->writeln(sprintf('<comment>%4d <%s>%s</%s></comment>', $warning->getLine(), $style, $warning->getMessage(), $style));
         }
     }
     $this->output->writeln("");
     $this->output->writeln('<comment>SUMMARY</comment>');
     $this->output->writeln("<info><comment>{$count}</comment> warnings in total.</info>");
 }