rfc:mixed_type_v2

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
rfc:mixed_type_v2 [2020/04/20 11:16] – unlinked email address to avoid spam. danackrfc:mixed_type_v2 [2020/05/21 12:11] kocsismate
Line 4: Line 4:
   * Author: Máté Kocsis <kocsismate@php.net>, Danack<danack@php.net>   * Author: Máté Kocsis <kocsismate@php.net>, Danack<danack@php.net>
   * Based on previous RFC by: Michael Moravec   * Based on previous RFC by: Michael Moravec
-  * Status: In Draft+  * Status: Accepted
   * Implementation: https://github.com/php/php-src/pull/5313   * Implementation: https://github.com/php/php-src/pull/5313
   * First Published at: https://wiki.php.net/rfc/mixed_type_v2   * First Published at: https://wiki.php.net/rfc/mixed_type_v2
Line 271: Line 271:
 //INVALID - Fatal error: Mixed types cannot be nullable, null is already part of the mixed type. //INVALID - Fatal error: Mixed types cannot be nullable, null is already part of the mixed type.
 function bar(): ?mixed {} function bar(): ?mixed {}
 +</code>
 +
 +
 +
 +==== Explicit returns ==== 
 +
 +When using mixed as a return type, a value must be explicitly returned from the function, otherwise a TypeError will be thrown.
 +
 +<code php>
 +function foo(): mixed {}
 +
 +foo();
 +
 +// Uncaught TypeError: Return value of foo() must be of 
 +// the type mixed, none returned
 +</code>
 +
 +This is consistent with the existing behaviour for other return types.
 +
 +<code php>
 +function bar(): ?int {}
 +bar();
 +// Uncaught TypeError: Return value of bar() must be of 
 +// the type int or null, none returned
 +
 </code> </code>
  
Line 305: Line 330:
 Not analyzed. Not analyzed.
  
-===== Proposed Voting Choices ===== +===== Vote =====  
 +The vote starts on 2020-05-07 and ends on 2020-05-21 12:00 UTC. The vote requires 2/3 majority to be accepted.
  
-Add ''mixed'' as a type to be used as parameter, return and class property types - yes/no.+<doodle title="Add mixed as a type to be used as parameter, return and class property types?" auth="kocsismate" voteType="single" closed="true"> 
 +   * Yes 
 +   * No 
 +</doodle>
  
  
rfc/mixed_type_v2.txt · Last modified: 2020/05/22 14:22 by kocsismate