-
Couldn't load subscription status.
- Fork 8k
Closed
Labels
Description
Description
When catching a failed match it would be very handy if the UnhandledMatchError had a method such as getUnmatchedValue() : mixed that contained the actual unmatched value.
This could allow more graceful handling of failed match handlers.
This would allow as a very basic example:
function getTypeName( mixed $value ) : string {
return match (gettype($value)) {
'integer', 'double' => 'number',
'string' => 'string',
'NULL' => 'null',
};
}
try {
getTypeName($item);
} catch(\UnhandledMatchError $e) {
$log->info("Received unhandled type: " . $e->getUnmatchedValue());
}I'm sure there is more involved handling you could do with it as well.
@derickr advised me to open a ticket for this idea