public function addCheckResults(File $file, array $checkResults)
{
if (empty($this->loggedSeverities)) {
return;
}
if ($this->firstFile) {
$this->firstFile = false;
} else {
$this->write(PHP_EOL);
}
// TODO: Only output if the file has violations?
$this->write('Checking ' . $file->getFilename() . PHP_EOL);
$violations = [];
foreach ($checkResults as $checkResult) {
$violations = array_merge($violations, $this->getFilteredViolations($checkResult->getViolations()));
}
if ($violations) {
$this->write($file->getFilename() . ':' . PHP_EOL);
$this->write(str_repeat('-', 80) . PHP_EOL);
foreach ($violations as $violation) {
$this->write('Line ' . $violation->getLine());
if ($violation->getColumn() > 0) {
$this->write(':' . $violation->getColumn());
}
$this->write(' (' . $violation->getSeverityName() . ') : ');
$this->write($violation->getMessage() . PHP_EOL);
}
$this->write(PHP_EOL);
}
flush();
}