Skip to content

Commit 34e91de

Browse files
authored
fix: json error formatter when files are empty
1 parent ae3a484 commit 34e91de

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Command/ErrorFormatter/JsonErrorFormatter.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ public function formatErrors(AnalysisResult $analysisResult, Output $output): in
6060
$errorsArray['errors'][] = $notFileSpecificError;
6161
}
6262

63+
// When files empty format it as an empty object
64+
if ($errorsArray['files'] === []) {
65+
$errorsArray['files'] = new \stdClass();
66+
}
67+
6368
$json = Json::encode($errorsArray, $this->pretty ? Json::PRETTY : 0);
6469

6570
$output->writeRaw($json);

0 commit comments

Comments
 (0)