Hi,
May I suggest adding a little "instanceof" magic to match? Like this:
match ($object) {
Someinterface => 'foo',
AnotherInterface => 'bar',
}
this can not clash with any existing code as using identifiers like this
are a syntax error currently.
Currently you could do the same with
match (true) {
$object instanceof Someinterface::class => 'foo',
$object instanceof AnotherInterface::class => 'bar',
}
Indeed, the former could be considered syntactic sugar for the latter. And
I do not think there's any ambiguity here for the casual reader or is it
just me who thinks no other sensible reading is possible?
Thanks for your consideration.
Karoly Negyesi