From 97ec75cf48e4d63704573a1d844e9a43b26decab Mon Sep 17 00:00:00 2001 From: Ruud Kamphuis Date: Fri, 2 May 2025 11:44:03 +0200 Subject: [PATCH] Support highlighting of variable ending with a period --- src/TicketSwapErrorFormatter.php | 2 +- tests/TicketSwapErrorFormatterTest.php | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/TicketSwapErrorFormatter.php b/src/TicketSwapErrorFormatter.php index 4b8d994..f488bfe 100644 --- a/src/TicketSwapErrorFormatter.php +++ b/src/TicketSwapErrorFormatter.php @@ -224,7 +224,7 @@ public static function highlight(string $message, ?string $tip, ?string $identif // Variable $message = (string) preg_replace( - "/(?<=[:]{2}|[\s\"\(])([.]{3})?(\\$[A-Za-z0-9_\\-]+)(?=[\s|\"|\)]|$)/", + "/(?<=[:]{2}|[\s\"\(])([.]{3})?(\\$[A-Za-z0-9_\\-]+)(?=[\.|\s|\"|\)]|$)/", '$1$2', $message, ); diff --git a/tests/TicketSwapErrorFormatterTest.php b/tests/TicketSwapErrorFormatterTest.php index 2686e29..3f374bb 100644 --- a/tests/TicketSwapErrorFormatterTest.php +++ b/tests/TicketSwapErrorFormatterTest.php @@ -182,6 +182,13 @@ public static function provideHighlight() : iterable null, true ]; + yield [ + "Parameter #1 \$currentWorkingDirectory.", + 'Parameter #1 $currentWorkingDirectory.', + null, + null, + true + ]; yield [ 'Parameter #1 $currentWorkingDirectory of method Application\AnalyzeCommand: getFinder() expects string, string|false given.', 'Parameter #1 $currentWorkingDirectory of method Application\AnalyzeCommand: getFinder() expects string, string|false given.',