From 997c35060c30a0f28893df9bec8e979c45055216 Mon Sep 17 00:00:00 2001 From: Ruud Kamphuis Date: Mon, 15 Dec 2025 15:04:29 +0100 Subject: [PATCH] Print tip and identifier when output is not decorated --- src/TicketSwapErrorFormatter.php | 10 ++++++++++ tests/TicketSwapErrorFormatterTest.php | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/src/TicketSwapErrorFormatter.php b/src/TicketSwapErrorFormatter.php index ca502c7..37cc849 100644 --- a/src/TicketSwapErrorFormatter.php +++ b/src/TicketSwapErrorFormatter.php @@ -198,6 +198,16 @@ private static function trimPath(string $path) : string public static function highlight(string $message, ?string $tip, ?string $identifier, bool $isDecorated) : string { if (!$isDecorated) { + if ($tip !== null) { + foreach (explode("\n", $tip) as $line) { + $message .= "\nTip: " . ltrim($line, ' •'); + } + } + + if ($identifier !== null) { + $message .= "\nIdentifier: " . $identifier; + } + return $message; } diff --git a/tests/TicketSwapErrorFormatterTest.php b/tests/TicketSwapErrorFormatterTest.php index 08a4aa3..cd9321c 100644 --- a/tests/TicketSwapErrorFormatterTest.php +++ b/tests/TicketSwapErrorFormatterTest.php @@ -196,6 +196,13 @@ public static function provideHighlight() : iterable null, false ]; + yield [ + "Parameter #1 \$currentWorkingDirectory of method Application\AnalyzeCommand: getFinder() expects string, string|false given.\nTip: you can do blabla.\nIdentifier: argument.type", + 'Parameter #1 $currentWorkingDirectory of method Application\AnalyzeCommand: getFinder() expects string, string|false given.', + 'you can do blabla.', + 'argument.type', + false + ]; yield [ "Parameter #1 \$currentWorkingDirectory of method Application\AnalyzeCommand: getFinder() expects string, string|false given.\nšŸ’” Tip: you can do blabla.\nšŸ”– argument.type", 'Parameter #1 $currentWorkingDirectory of method Application\AnalyzeCommand: getFinder() expects string, string|false given.',