Re: Literal types RFC
| From: | Bogdan Ungureanu | Date: | Mon, 05 Oct 2020 00:03:14 +0000 |
| Subject: | Re: Literal types RFC | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-111998@lists.php.net to get a copy of this message | ||
Yeah, kind of, the problem with enums from what I understood from the
current RFCs is that you'll need extra code to map a scalar to that
specific enum value.
Besides that, a literal type implementation is afaik simpler to
implement/spec than enums, thus having a better chance to pass voting.
On Mon, Oct 5, 2020 at 2:56 AM Max Semenik <maxsem.wiki@gmail.com> wrote:
> пн, 5 окт. 2020 г., 02:38 Bogdan Ungureanu <bogdanungureanu21@gmail.com>:
>
>>
>> function getStatus(): "draft" | "published" { }
>>
>
> It sounds that what you're really asking for is enums, e.g.
>
> enum Status {
> Draft,
> Published
> };
>
> function getStatus(): Status { ... }
>
>>