Re: [RFC] Enumerations
| From: | Benjamin Morel | Date: | Wed, 09 Dec 2020 20:29:37 +0000 |
| Subject: | Re: [RFC] Enumerations | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-112478@lists.php.net to get a copy of this message | ||
On Wed, 9 Dec 2020 at 19:48, Mike Schinkel <mike@newclarity.net> wrote:
5. Someone else mentioned shortcut syntax, which I would like to mention
> again, although I realize implement details might make this a non-starter.
>
> So if I have a function that accepts a Size from above, e.g.:
>
> function show(Size $size) {}
>
> Then it would be great if we could call the function like this since its
> parameter was type-hinted:
>
> show(::Medium)
>
> Rather than always having to write:
>
> show(Size::Medium)
>
> So can we consider a shortcut syntax?
>
I'm not sure what value a shortcut syntax would bring, but it would surely
break, or at least make ambiguous, union types:
function show(Enum1|Enum2 $value) {}
show(::Medium)
Which enum would Medium resolve to?
- Benjamin