Re: [PHP-DEV] instance version of match ?

2022-03-31 Thread Arnaud Le Blanc
On mardi 29 mars 2022 15:33:41 CEST Thomas Nunninger wrote: > Hi, > > Am 29.03.22 um 14:34 schrieb Rowan Tommins: > > On 29/03/2022 11:59, Robert Landers wrote: > >> $object instanceof AnotherInterface => 'bar', > >> > >> We can see that `SomeInterface` will resolve the interface and

Re: [PHP-DEV] instance version of match ?

2022-03-29 Thread Thomas Nunninger
Hi, Am 29.03.22 um 14:34 schrieb Rowan Tommins: On 29/03/2022 11:59, Robert Landers wrote: $object instanceof AnotherInterface => 'bar', We can see that `SomeInterface` will resolve the interface and not the constant. Yeah, the instanceof operator is magic in that regard - it has

Re: [PHP-DEV] instance version of match ?

2022-03-29 Thread Rowan Tommins
On 29/03/2022 11:59, Robert Landers wrote: $object instanceof AnotherInterface => 'bar', We can see that `SomeInterface` will resolve the interface and not the constant. Yeah, the instanceof operator is magic in that regard - it has a special parsing rule to consume the next token

Re: [PHP-DEV] instance version of match ?

2022-03-29 Thread Robert Landers
On Tue, Mar 29, 2022 at 3:47 AM Bruce Weirdan wrote: > > On Mon, Mar 28, 2022 at 7:56 PM Karoly Negyesi wrote: > > match ($object) { > > Someinterface => 'foo', > > AnotherInterface => 'bar', > > } > > > > this can not clash with any existing code as using identifiers like this > > are a

Re: [PHP-DEV] instance version of match ?

2022-03-28 Thread Bruce Weirdan
On Mon, Mar 28, 2022 at 7:56 PM Karoly Negyesi wrote: > match ($object) { > Someinterface => 'foo', > AnotherInterface => 'bar', > } > > this can not clash with any existing code as using identifiers like this > are a syntax error currently. That's valid code actually, see

[PHP-DEV] instance version of match ?

2022-03-28 Thread Karoly Negyesi
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