Skip to content

Commit e23b9fe

Browse files
authored
Support comma as lookbehind for types (#25)
* add stdClass as type * add missing testcase for stdClass * fix test * add comma as lookbehind for types regex * fix test
1 parent 32514df commit e23b9fe

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/TicketSwapErrorFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public static function highlight(string $message, ?string $tip, ?string $identif
245245

246246
// Types
247247
$message = (string) preg_replace(
248-
'/(?<=[\s\|\(><])(null|true|false|int|float|bool|([-\w]+-)?string|Stringable|array|object|mixed|resource|iterable|void|callable|stdClass)(?=[:]{2}|[\.\s\|><,\(\)\{\}]+)/',
248+
'/(?<=[\s\|\(><,])(null|true|false|int|float|bool|([-\w]+-)?string|Stringable|array|object|mixed|resource|iterable|void|callable|stdClass)(?=[:]{2}|[\.\s\|><,\(\)\{\}]+)/',
249249
'<fg=magenta>$1</>',
250250
$message,
251251
);

tests/TicketSwapErrorFormatterTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,13 @@ public static function provideHighlight() : iterable
224224
null,
225225
true,
226226
];
227+
yield [
228+
'Parameter #1 <fg=green>$callback</> of method <fg=yellow>Illuminate\Support\Collection</><<fg=magenta>int</>,<fg=magenta>mixed</>>::<fg=blue>map()</> expects',
229+
'Parameter #1 $callback of method Illuminate\Support\Collection<int,mixed>::map() expects',
230+
null,
231+
null,
232+
true,
233+
];
227234
}
228235

229236
/**

0 commit comments

Comments
 (0)