1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-12 09:19:40 +01:00
psalm/src/Psalm/Report/JsonSummaryReport.php

33 lines
710 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 function json_encode;
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
{
/**
2019-07-05 22:24:00 +02:00
* {@inheritdoc}
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
}
return json_encode([
'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,
2019-05-11 00:07:13 +02:00
]) . "\n";
}
}