2019-05-11 00:07:13 +02:00
|
|
|
<?php
|
2021-12-15 04:58:32 +01:00
|
|
|
|
2019-06-09 18:37:28 +02:00
|
|
|
namespace Psalm\Report;
|
2019-05-11 00:07:13 +02:00
|
|
|
|
2020-05-18 14:40:20 +02:00
|
|
|
use Psalm\Internal\Json\Json;
|
2019-07-05 22:24:00 +02:00
|
|
|
use Psalm\Report;
|
2019-05-11 00:07:13 +02:00
|
|
|
|
2022-02-04 03:51:18 +01:00
|
|
|
final class JsonSummaryReport extends Report
|
2019-05-11 00:07:13 +02:00
|
|
|
{
|
|
|
|
public function create(): string
|
|
|
|
{
|
|
|
|
$type_counts = [];
|
|
|
|
|
|
|
|
foreach ($this->issues_data as $issue_data) {
|
2020-02-17 00:24:40 +01:00
|
|
|
$type = $issue_data->type;
|
2019-05-11 00:07:13 +02:00
|
|
|
|
|
|
|
if (!isset($type_counts[$type])) {
|
|
|
|
$type_counts[$type] = 0;
|
|
|
|
}
|
|
|
|
|
2019-07-05 22:24:00 +02:00
|
|
|
++$type_counts[$type];
|
2019-05-11 00:07:13 +02:00
|
|
|
}
|
|
|
|
|
2020-05-18 14:40:20 +02:00
|
|
|
$options = $this->pretty ? Json::PRETTY : Json::DEFAULT;
|
|
|
|
|
|
|
|
return Json::encode([
|
2019-05-11 00:07:13 +02:00
|
|
|
'issue_counts' => $type_counts,
|
|
|
|
'mixed_expression_count' => $this->mixed_expression_count,
|
2019-07-05 22:24:00 +02:00
|
|
|
'total_expression_count' => $this->total_expression_count,
|
2020-05-18 14:40:20 +02:00
|
|
|
], $options) . "\n";
|
2019-05-11 00:07:13 +02:00
|
|
|
}
|
|
|
|
}
|