rfc:nullable_intersection_types

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
rfc:nullable_intersection_types [2021/07/23 12:32]
nicolasgrekas
rfc:nullable_intersection_types [2021/08/29 19:13]
marandall Updated status tag after being declined (announced on ML).
Line 3: Line 3:
   * Date: 2021-07-22   * Date: 2021-07-22
   * Author: Nicolas Grekas, nicolasgrekas@php.net   * Author: Nicolas Grekas, nicolasgrekas@php.net
-  * Status: Under Discussion+  * Status: Declined
   * Implementation: https://github.com/php/php-src/pull/7259   * Implementation: https://github.com/php/php-src/pull/7259
   * First Published at: https://wiki.php.net/rfc/nullable_intersection_types   * First Published at: https://wiki.php.net/rfc/nullable_intersection_types
Line 28: Line 28:
 } }
 </PHP> </PHP>
 +
 +On the reflection side, ''ReflectionIntersectionType::allowsNull()'' will return ''true''/''false'' depending on what the intersection type accepts.
  
 ===== Rationale ===== ===== Rationale =====
Line 39: Line 41:
  
 For all these reasons, this RFC proposes to make intersection types nullable, and to make them so right away in PHP 8.1. For all these reasons, this RFC proposes to make intersection types nullable, and to make them so right away in PHP 8.1.
 +
 +About reflection, one could imagine a more complex model based on a ''ReflectionIntersectionType'' nested inside a ''ReflectionUnionType''. This RFC proposes to rely on ''ReflectionIntersectionType::allowsNull()'' instead. This is consistent with how ''T|null'' is returned without ''ReflectionUnionType'' wrapper, and is also simpler for userland to deal with.
  
 ===== Future Scope ===== ===== Future Scope =====
Line 97: Line 101:
   * Preferred syntax: "?" prefix / "|null" suffix   * Preferred syntax: "?" prefix / "|null" suffix
   * Intersections should be: without brackets around / with brackets around / allow both styles   * Intersections should be: without brackets around / with brackets around / allow both styles
 +
 +===== Vote =====
 +
 +Voting starts 2021-08-13 09:30 UTC and ends 2021-08-27 17:00 UTC.
 +
 +<doodle title="Make intersection types nullable" auth="nicolasgrekas" voteType="single" closed="true">
 +   * Yes
 +   * No
 +</doodle>
 +
 +----
 +
 +<doodle title="Preferred syntax" auth="nicolasgrekas" voteType="single" closed="true">
 +   * "?" prefix
 +   * "|null" suffix
 +</doodle>
 +
 +----
 +
 +<doodle title="Intersections should be" auth="nicolasgrekas" voteType="single" closed="true">
 +   * without brackets around
 +   * with brackets around
 +   * allow both styles
 +</doodle>
  
 ===== Patches and Tests ===== ===== Patches and Tests =====
rfc/nullable_intersection_types.txt · Last modified: 2021/08/29 19:13 by marandall