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 27, 2021
1 parent b29737f commit feec9a7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Psalm/Report/ConsoleReport.php
Expand Up @@ -6,6 +6,8 @@
use Psalm\Report;

use function substr;
use function basename;
use function strlen;

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

$issue_reference = $issue_data->link ? ' (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 feec9a7

Please sign in to comment.