mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
UPDATE add issue type to text output
Adds issue type to text output. Leaves .emacs output as before.
This commit is contained in:
parent
5103dfd680
commit
0655e1c19c
@ -139,6 +139,7 @@ class ProjectAnalyzer
|
||||
const TYPE_JSON = 'json';
|
||||
const TYPE_EMACS = 'emacs';
|
||||
const TYPE_XML = 'xml';
|
||||
const TYPE_TEXT = 'text';
|
||||
|
||||
const SUPPORTED_OUTPUT_TYPES = [
|
||||
self::TYPE_COMPACT,
|
||||
@ -147,6 +148,7 @@ class ProjectAnalyzer
|
||||
self::TYPE_JSON,
|
||||
self::TYPE_EMACS,
|
||||
self::TYPE_XML,
|
||||
self::TYPE_TEXT,
|
||||
];
|
||||
|
||||
/**
|
||||
@ -200,7 +202,7 @@ class ProjectAnalyzer
|
||||
$mapping = [
|
||||
'.xml' => self::TYPE_XML,
|
||||
'.json' => self::TYPE_JSON,
|
||||
'.txt' => self::TYPE_EMACS,
|
||||
'.txt' => self::TYPE_TEXT,
|
||||
'.emacs' => self::TYPE_EMACS,
|
||||
'.pylint' => self::TYPE_PYLINT,
|
||||
];
|
||||
|
@ -11,6 +11,7 @@ use Psalm\Output\Console;
|
||||
use Psalm\Output\Emacs;
|
||||
use Psalm\Output\Json;
|
||||
use Psalm\Output\Pylint;
|
||||
use Psalm\Output\Text;
|
||||
use Psalm\Output\Xml;
|
||||
|
||||
class IssueBuffer
|
||||
@ -391,6 +392,10 @@ class IssueBuffer
|
||||
$output = new Emacs(self::$issues_data, $use_color, $show_snippet, $show_info);
|
||||
break;
|
||||
|
||||
case ProjectAnalyzer::TYPE_TEXT:
|
||||
$output = new Text(self::$issues_data, $use_color, $show_snippet, $show_info);
|
||||
break;
|
||||
|
||||
case ProjectAnalyzer::TYPE_JSON:
|
||||
$output = new Json(self::$issues_data, $use_color, $show_snippet, $show_info);
|
||||
break;
|
||||
|
29
src/Psalm/Output/Text.php
Normal file
29
src/Psalm/Output/Text.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
namespace Psalm\Output;
|
||||
|
||||
use Psalm\Config;
|
||||
use Psalm\Output;
|
||||
|
||||
class Text extends Output
|
||||
{
|
||||
/**
|
||||
* {{@inheritdoc}}
|
||||
*/
|
||||
public function create(): string
|
||||
{
|
||||
$output = null;
|
||||
foreach ($this->issues_data as $issue_data) {
|
||||
$output .= sprintf(
|
||||
'%s:%s:%s:%s - %s: %s',
|
||||
$issue_data['file_path'],
|
||||
$issue_data['line_from'],
|
||||
$issue_data['column_from'],
|
||||
($issue_data['severity'] === Config::REPORT_ERROR ? 'error' : 'warning'),
|
||||
$issue_data['type'],
|
||||
$issue_data['message']
|
||||
) . "\n";
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user