2019-05-08 20:26:52 +02:00
|
|
|
<?php
|
2019-06-09 18:37:28 +02:00
|
|
|
namespace Psalm\Report;
|
2019-05-08 20:26:52 +02:00
|
|
|
|
2019-07-05 22:24:00 +02:00
|
|
|
use function htmlspecialchars;
|
2019-06-09 18:37:28 +02:00
|
|
|
use Psalm\Report;
|
2019-06-26 22:52:29 +02:00
|
|
|
use function sprintf;
|
2019-05-08 20:26:52 +02:00
|
|
|
|
2019-06-09 18:37:28 +02:00
|
|
|
class CheckstyleReport extends Report
|
2019-05-08 20:26:52 +02:00
|
|
|
{
|
|
|
|
/**
|
2019-07-05 22:24:00 +02:00
|
|
|
* {@inheritdoc}
|
2019-05-08 20:26:52 +02:00
|
|
|
*/
|
|
|
|
public function create(): string
|
|
|
|
{
|
|
|
|
$output = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
|
|
|
|
|
|
|
|
$output .= '<checkstyle>' . "\n";
|
|
|
|
|
|
|
|
foreach ($this->issues_data as $issue_data) {
|
|
|
|
$message = sprintf(
|
|
|
|
'%s: %s',
|
2020-02-17 00:24:40 +01:00
|
|
|
$issue_data->type,
|
|
|
|
$issue_data->message
|
2019-05-08 20:26:52 +02:00
|
|
|
);
|
|
|
|
|
2020-02-17 00:24:40 +01:00
|
|
|
$output .= '<file name="' . htmlspecialchars($issue_data->file_name) . '">' . "\n";
|
2019-05-08 20:26:52 +02:00
|
|
|
$output .= ' ';
|
|
|
|
$output .= '<error';
|
2020-02-17 00:24:40 +01:00
|
|
|
$output .= ' line="' . $issue_data->line_from . '"';
|
|
|
|
$output .= ' column="' . $issue_data->column_from . '"';
|
|
|
|
$output .= ' severity="' . $issue_data->severity . '"';
|
2019-05-15 17:03:10 +02:00
|
|
|
$output .= ' message="' . htmlspecialchars($message) . '"';
|
2019-05-08 20:26:52 +02:00
|
|
|
$output .= '/>' . "\n";
|
|
|
|
$output .= '</file>' . "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
$output .= '</checkstyle>' . "\n";
|
|
|
|
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
}
|