diff --git a/src/Command/ErrorFormatter/TableErrorFormatter.php b/src/Command/ErrorFormatter/TableErrorFormatter.php index 7da56bdff1..b0cf5f90fc 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; @@ -82,7 +83,7 @@ public function formatErrors( $filePath = $error->getTraitFilePath() ?? $error->getFilePath(); if ($error->getIdentifier() !== null && $error->canBeIgnored()) { $message .= "\n"; - $message .= '🪪 ' . $error->getIdentifier(); + $message .= '🪪 ' . $error->getIdentifier(); } if ($error->getTip() !== null) { $tip = $error->getTip(); @@ -94,6 +95,7 @@ public function formatErrors( foreach ($lines as $line) { $message .= '💡 ' . ltrim($line, ' •') . "\n"; } + $message = rtrim($message, "\n"); } else { $message .= '💡 ' . $tip; } @@ -115,7 +117,7 @@ public function formatErrors( $title = $this->relativePathHelper->getRelativePath($filePath); } - $message .= "\n✏️ <href=" . OutputFormatter::escape($url) . '>' . $title . '</>'; + $message .= "\n✏️ <href=" . OutputFormatter::escape($url) . '>' . $title . '</>'; } $rows[] = [ $this->formatLineNumber($error->getLine()), diff --git a/tests/PHPStan/Command/ErrorFormatter/TableErrorFormatterTest.php b/tests/PHPStan/Command/ErrorFormatter/TableErrorFormatterTest.php index 40db6547a8..1ada3c4624 100644 --- a/tests/PHPStan/Command/ErrorFormatter/TableErrorFormatterTest.php +++ b/tests/PHPStan/Command/ErrorFormatter/TableErrorFormatterTest.php @@ -190,13 +190,13 @@ public function dataFormatterOutputProvider(): iterable 'numGenericErrors' => 0, 'verbose' => false, 'extraEnvVars' => [], - 'expected' => ' ------ ---------------- + 'expected' => ' ------ --------------- Line foo.php - ------ ---------------- + ------ --------------- 5 Foobar\Buz - 🪪 foobar.buz + 🪪 foobar.buz 💡 a tip - ------ ---------------- + ------ --------------- [ERROR] Found 1 error @@ -211,13 +211,13 @@ public function dataFormatterOutputProvider(): iterable 'numGenericErrors' => 0, 'verbose' => true, 'extraEnvVars' => [], - 'expected' => ' ------ ---------------- + 'expected' => ' ------ --------------- Line foo.php - ------ ---------------- + ------ --------------- 5 Foobar\Buz - 🪪 foobar.buz + 🪪 foobar.buz 💡 a tip - ------ ---------------- + ------ --------------- [ERROR] Found 1 error