19 declare(strict_types=1);
48 public function formatErrors(AnalysisResult $analysisResult, Output $output): int
51 $output->writeLineFormatted(implode(
';', $this->csv_headers));
53 foreach ($analysisResult->getFileSpecificErrors() as $fileSpecificError) {
54 $filename = str_replace($getcwd,
'', $fileSpecificError->getFile());
55 if (preg_match(self::COMPONENT_REGEX,
$filename, $matches)) {
56 $component = $matches[1] .
'/' . $matches[2];
58 $component = self::UNKNOWN;
62 self::H_COMPONENT => $component,
63 self::H_CLASS => basename($fileSpecificError->getFile()),
64 self::H_VERSION => $fileSpecificError->getMetadata()[
'version'] ?? self::UNKNOWN,
65 self::H_LINE => $fileSpecificError->getLine(),
66 self::H_RULE => $fileSpecificError->getMetadata()[
'rule'] ?? self::UNKNOWN,
67 self::H_MESSAGE => $fileSpecificError->getMessage()
69 $output->writeLineFormatted(implode(
';',
$result));
71 return $analysisResult->hasErrors() ? 1 : 0;