Re: Union `&` operator
| From: | Eugene Sidelnyk | Date: | Sun, 08 Nov 2020 16:47:01 +0000 |
| Subject: | Re: Union `&` operator | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-112208@lists.php.net to get a copy of this message | ||
> As for when to allow them: as others have suggested in this thread, keep
it simple for now, and only allow intersection of class/interface
references.
Yes, I think that single intersection type should support just one class
and any/or any number of interfaces with the condition that they don't
collide with one another.
> If you want to raise an RFC, special care has to be taken for the
variance in inheritance semantics.
I don't think neither that I am able to consider all possible impacts to
write the RFC nor implement this, but Levi Morrison (levim@php.net) can.
On Sun, Nov 8, 2020 at 4:53 PM Marco Pivetta <ocramius@gmail.com> wrote:
> Hey Eugene,
>
> On Sat, Nov 7, 2020 at 4:13 PM Eugene Sidelnyk <zsidelnik@gmail.com>
> wrote:
>
>> ```php
>> function foo(A & B & E $object) {
>> // some work
>>
>> var_dump($object);
>> }
>> ```
>>
>
> Fully support this for parameter, property and return types: already
> making good use of intersection types since a few years.
>
> As for when to allow them: as others have suggested in this thread, keep
> it simple for now, and only allow intersection of class/interface
> references.
>
> If you want to raise an RFC, special care has to be taken for the variance
> in inheritance semantics.
>
> Greets,
>
> Marco Pivetta
>
> http://twitter.com/Ocramius
>
> http://ocramius.github.com/
>