/**
  * @param Violation[] $violations
  */
 public function renderViolations(array $violations)
 {
     $table = new Table($this->output);
     $table->setHeaders(array('#', 'Usage', 'Line', 'Comment'));
     $tmpFile = null;
     foreach ($violations as $i => $violation) {
         if ($tmpFile !== $violation->getFile()) {
             $tmpFile = $violation->getFile();
             if (0 !== $i) {
                 $table->addRow(new TableSeparator());
             }
             $table->addRow($this->getFileHeader($tmpFile));
             $table->addRow(new TableSeparator());
         }
         $table->addRow(array(++$i, $this->messageHelper->getViolationMessage($violation), $violation->getLine(), $violation->getComment()));
     }
     $table->render();
 }
 public function testFallbackMessage()
 {
     $usage = $this->prophesize('SensioLabs\\DeprecationDetector\\FileInfo\\Usage\\ClassUsage');
     $usage->name()->willReturn('SomeClass');
     $violation = $this->prophesize('SensioLabs\\DeprecationDetector\\Violation\\Violation');
     $violation->getUsage()->willReturn($usage->reveal());
     $messageHelper = new MessageHelper();
     $this->assertRegExp('#Deprecated P[0-9]+ <info>SomeClass</info>#', $messageHelper->getViolationMessage($violation->reveal()));
 }
 /**
  * @param Violation[] $violations
  * @param Error[]     $errors
  */
 public function renderViolations(array $violations, array $errors)
 {
     $orderedViolations = array();
     // sorting and grouping violations
     foreach ($violations as $violation) {
         $key = $violation->getFile()->getPathname();
         if (!array_key_exists($key, $orderedViolations)) {
             $orderedViolations[$key] = array();
         }
         $fileViolation['message'] = $this->messageHelper->getViolationMessage($violation);
         $fileViolation['line'] = $violation->getLine();
         $fileViolation['comment'] = $violation->getComment();
         $orderedViolations[$key][] = $fileViolation;
     }
     ob_start();
     include __DIR__ . '/../../../Resources/templates/htmlTable.phtml';
     $htmlOutput = ob_get_clean();
     $this->fileSystem->mkdir(dirname($this->outputFilename));
     file_put_contents($this->outputFilename, $htmlOutput);
 }
 /**
  * @param Violation[] $violations
  * @param Error[]     $errors
  */
 public function renderViolations(array $violations, array $errors)
 {
     $table = new Table($this->output);
     $table->setHeaders(array('#', 'Usage', 'Line', 'Comment'));
     $tmpFile = null;
     foreach ($violations as $i => $violation) {
         if ($tmpFile !== $violation->getFile()) {
             $tmpFile = $violation->getFile();
             if (0 !== $i) {
                 $table->addRow(new TableSeparator());
             }
             $table->addRow($this->getFileHeader($tmpFile));
             $table->addRow(new TableSeparator());
         }
         $table->addRow(array(++$i, $this->messageHelper->getViolationMessage($violation), $violation->getLine(), $violation->getComment()));
     }
     $table->render();
     $this->output->writeln('<error>Your project contains invalid code:</error>');
     foreach ($errors as $error) {
         $this->output->writeln(sprintf('<error>%s</error>', $error->getRawMessage()));
     }
 }