public function render(Report $report)
 {
     $output = $this->getOutput();
     foreach ($report->getViolations() as $violation) {
         $text = sprintf('Rule "%s" violation: <info>%s</info>', $violation->getRule()->getName(), $violation->getItem()->getRelativePathname());
         $output->writeln($text);
     }
 }
 /**
  * @test
  */
 public function violationsCanBeAdded()
 {
     $rule = new Rule('Dummy Rule', 'item.type == file');
     $item = new Item(new SplFileInfo('/a/fake/path/dummy.php', 'path/', 'path/dummy.php'), '/a/fake');
     $report = new Report();
     $report->addViolation($rule, $item);
     $violations = $report->getViolations();
     $this->assertCount(1, $violations);
     $this->assertTrue($report->hasViolations());
     $this->assertSame($rule, $violations[0]->getRule());
     $this->assertSame($item, $violations[0]->getItem());
 }
Exemple #3
0
 public function check(Item $item, Report $report)
 {
     $result = $this->getLanguage()->evaluate($this->getExpression(), ['item' => $item]);
     if (false === $result) {
         $report->addViolation($this, $item);
     }
     return $result;
 }