Skip to content

Commit 76b094d

Browse files
authored
TableErrorFormatter: improve formatting of error tips
1 parent 4927f7b commit 76b094d

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/Command/ErrorFormatter/TableErrorFormatter.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use function in_array;
1717
use function is_string;
1818
use function ltrim;
19+
use function rtrim;
1920
use function sprintf;
2021
use function str_contains;
2122
use function str_replace;
@@ -83,7 +84,7 @@ public function formatErrors(
8384
$filePath = $error->getTraitFilePath() ?? $error->getFilePath();
8485
if ($error->getIdentifier() !== null && $error->canBeIgnored()) {
8586
$message .= "\n";
86-
$message .= '🪪 ' . $error->getIdentifier();
87+
$message .= '🪪 ' . $error->getIdentifier();
8788
}
8889
if ($error->getTip() !== null) {
8990
$tip = $error->getTip();
@@ -95,6 +96,7 @@ public function formatErrors(
9596
foreach ($lines as $line) {
9697
$message .= '💡 ' . ltrim($line, '') . "\n";
9798
}
99+
$message = rtrim($message, "\n");
98100
} else {
99101
$message .= '💡 ' . $tip;
100102
}
@@ -116,7 +118,7 @@ public function formatErrors(
116118
$title = $this->relativePathHelper->getRelativePath($filePath);
117119
}
118120

119-
$message .= "\n✏️ <href=" . OutputFormatter::escape($url) . '>' . $title . '</>';
121+
$message .= "\n✏️ <href=" . OutputFormatter::escape($url) . '>' . $title . '</>';
120122
}
121123

122124
if (

tests/PHPStan/Command/ErrorFormatter/TableErrorFormatterTest.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,13 @@ public function dataFormatterOutputProvider(): iterable
190190
'numGenericErrors' => 0,
191191
'verbose' => false,
192192
'extraEnvVars' => [],
193-
'expected' => ' ------ ----------------
193+
'expected' => ' ------ ---------------
194194
Line foo.php
195-
------ ----------------
195+
------ ---------------
196196
5 Foobar\Buz
197-
🪪 foobar.buz
197+
🪪 foobar.buz
198198
💡 a tip
199-
------ ----------------
199+
------ ---------------
200200
201201
202202
[ERROR] Found 1 error
@@ -211,13 +211,13 @@ public function dataFormatterOutputProvider(): iterable
211211
'numGenericErrors' => 0,
212212
'verbose' => true,
213213
'extraEnvVars' => [],
214-
'expected' => ' ------ ----------------
214+
'expected' => ' ------ ---------------
215215
Line foo.php
216-
------ ----------------
216+
------ ---------------
217217
5 Foobar\Buz
218-
🪪 foobar.buz
218+
🪪 foobar.buz
219219
💡 a tip
220-
------ ----------------
220+
------ ---------------
221221
222222
223223
[ERROR] Found 1 error

0 commit comments

Comments
 (0)