Re: [RFC] Nullable intersection types
| From: | Nicolas Grekas | Date: | Fri, 23 Jul 2021 12:11:43 +0000 |
| Subject: | Re: [RFC] Nullable intersection types | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-115557@lists.php.net to get a copy of this message | ||
Le ven. 23 juil. 2021 Ã 13:05, Guilliam Xavier <guilliam.xavier@gmail.com>
a écrit :
>
> On Fri, Jul 23, 2021 at 11:58 AM Nicolas Grekas <nicolas.grekas@gmail.com>
> wrote:
>
>> Hi everyone,
>>
>> as proposed by Nikita and Joe, I'm submitting this late RFC for your
>> consideration for inclusion in PHP 8.1. Intersection types as currently
>> accepted are not nullable. This RFC proposes to make them so.
>>
>> I wrote everything down about the reasons why here:
>> https://wiki.php.net/rfc/nullable_intersection_types
>>
>> Please have a look and let me know what you think.
>>
>> Have a nice read,
>>
>> Nicolas
>>
>
> Hi Nicolas, thank you for putting this up. Just two editorial notes:
>
> - "This is because any intersection that contains the null type is
> identical to the null type itself.": I don't think that
X&nullxï�
> ¼få 5õG€eJE is the
> same as null but rather like
> never (i.e. the "bottom/empty" type, or
> simply "impossible/nonsensical/bogus")?
>
> - "Should brackets around the intersection be: not needed / mandatory /
> allow both styles": maybe clearer would be e.g. "forbidden / mandatory /
> optional (allow both styles)"?
>
Thanks, I edited both to the following:
- any intersections that contain the ''null'' type are identical to the
''never'' type.
- Intersections should be: without brackets around / with brackets around /
allow both styles