diff --git a/src/Command/ErrorFormatter/TableErrorFormatter.php b/src/Command/ErrorFormatter/TableErrorFormatter.php index 7da56bdff1..17ae3c1da8 100644 --- a/src/Command/ErrorFormatter/TableErrorFormatter.php +++ b/src/Command/ErrorFormatter/TableErrorFormatter.php @@ -15,6 +15,7 @@ use function getenv; use function is_string; use function ltrim; +use function rtrim; use function sprintf; use function str_contains; use function str_replace; @@ -92,10 +93,11 @@ public function formatErrors( if (str_contains($tip, "\n")) { $lines = explode("\n", $tip); foreach ($lines as $line) { - $message .= '💡 ' . ltrim($line, ' •') . "\n"; + $message .= '💡 ' . ltrim($line, ' •') . "\n"; } + $message = rtrim($message, "\n"); } else { - $message .= '💡 ' . $tip; + $message .= '💡 ' . $tip; } } if (is_string($this->editorUrl)) { diff --git a/tests/PHPStan/Command/ErrorFormatter/TableErrorFormatterTest.php b/tests/PHPStan/Command/ErrorFormatter/TableErrorFormatterTest.php index 40db6547a8..1622363910 100644 --- a/tests/PHPStan/Command/ErrorFormatter/TableErrorFormatterTest.php +++ b/tests/PHPStan/Command/ErrorFormatter/TableErrorFormatterTest.php @@ -94,14 +94,14 @@ public function dataFormatterOutputProvider(): iterable 4 Foo ------ ------------------------------------------------------------------- - ------ ---------- + ------ ----------- Line foo.php - ------ ---------- + ------ ----------- 1 Foo 5 Bar Bar2 - 💡 a tip - ------ ---------- + 💡 a tip + ------ ----------- [ERROR] Found 4 errors @@ -143,14 +143,14 @@ public function dataFormatterOutputProvider(): iterable 4 Foo ------ ------------------------------------------------------------------- - ------ ---------- + ------ ----------- Line foo.php - ------ ---------- + ------ ----------- 1 Foo 5 Bar Bar2 - 💡 a tip - ------ ---------- + 💡 a tip + ------ ----------- -- ----------------------- Error @@ -195,7 +195,7 @@ public function dataFormatterOutputProvider(): iterable ------ ---------------- 5 Foobar\Buz 🪪 foobar.buz - 💡 a tip + 💡 a tip ------ ---------------- @@ -216,7 +216,7 @@ public function dataFormatterOutputProvider(): iterable ------ ---------------- 5 Foobar\Buz 🪪 foobar.buz - 💡 a tip + 💡 a tip ------ ----------------