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
|
|
|
|
|
|
|
use LSS\Array2XML;
|
2019-06-09 18:37:28 +02:00
|
|
|
use Psalm\Report;
|
2019-06-26 22:52:29 +02:00
|
|
|
use function sprintf;
|
|
|
|
use function htmlspecialchars;
|
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
|
|
|
{
|
|
|
|
/**
|
|
|
|
* {{@inheritdoc}}
|
|
|
|
*/
|
|
|
|
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',
|
|
|
|
$issue_data['type'],
|
|
|
|
$issue_data['message']
|
|
|
|
);
|
|
|
|
|
2019-05-15 17:03:10 +02:00
|
|
|
$output .= '<file name="' . htmlspecialchars($issue_data['file_name']) . '">' . "\n";
|
2019-05-08 20:26:52 +02:00
|
|
|
$output .= ' ';
|
|
|
|
$output .= '<error';
|
|
|
|
$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;
|
|
|
|
}
|
|
|
|
}
|