Skip to content

Commit 32514df

Browse files
authored
Decorate stdClass type (#24)
* add stdClass as type * add missing testcase for stdClass * fix test
1 parent dbe8ded commit 32514df

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)(?=[:]{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
@@ -217,6 +217,13 @@ public static function provideHighlight() : iterable
217217
null,
218218
true
219219
];
220+
yield [
221+
'Property <fg=yellow>App\Models\ExampleModel</>::<fg=green>$example_property</> (<fg=magenta>stdClass</>|<fg=magenta>null</>) does not accept <fg=magenta>mixed</>.',
222+
'Property App\Models\ExampleModel::$example_property (stdClass|null) does not accept mixed.',
223+
null,
224+
null,
225+
true,
226+
];
220227
}
221228

222229
/**

0 commit comments

Comments
 (0)