1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-04 10:38:49 +01:00
psalm/src/Psalm/Report/JsonSummaryReport.php

33 lines
755 B
PHP
Raw Normal View History

2019-05-11 00:07:13 +02:00
<?php
namespace Psalm\Report;
2019-05-11 00:07:13 +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
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
}
$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,
], $options) . "\n";
2019-05-11 00:07:13 +02:00
}
}