Skip to content

Commit

Permalink
Colorized file name and line in console output
Browse files Browse the repository at this point in the history
Fixes #4129
  • Loading branch information
Rarst committed Sep 8, 2020
1 parent 993e112 commit d23b160
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Psalm/Report/ConsoleReport.php
Expand Up @@ -5,6 +5,8 @@
use Psalm\Report;
use Psalm\Internal\Analyzer\TaintNodeData;
use function substr;
use function basename;
use function strlen;

class ConsoleReport extends Report
{
Expand Down Expand Up @@ -34,10 +36,12 @@ private function format(\Psalm\Internal\Analyzer\IssueData $issue_data): string
}

$issue_reference = ' (see ' . $issue_data->link . ')';
$file_basename = basename($issue_data->file_name);
$file_path = substr($issue_data->file_name, 0, -strlen($file_basename));

$issue_string .= ': ' . $issue_data->type
. ' - ' . $issue_data->file_name . ':' . $issue_data->line_from . ':' . $issue_data->column_from
. ' - ' . $issue_data->message . $issue_reference . "\n";
. ' - ' . $file_path . "\e[1;31m" . $file_basename . ':' . $issue_data->line_from . "\e[0m"
. ':' . $issue_data->column_from . ' - ' . $issue_data->message . $issue_reference . "\n";


if ($issue_data->taint_trace) {
Expand Down

0 comments on commit d23b160

Please sign in to comment.