Re: Union `&` operator
| From: | Marco Pivetta | Date: | Sun, 08 Nov 2020 14:53:08 +0000 |
| Subject: | Re: Union `&` operator | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-112206@lists.php.net to get a copy of this message | ||
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/