1
0
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:
Dave Liddament 2018-12-18 18:13:21 +00:00 committed by Matthew Brown
parent 5103dfd680
commit 0655e1c19c
3 changed files with 37 additions and 1 deletions

View File

@ -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,
];

View File

@ -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
View 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;
}
}