rfc:mixed_type_v2
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:mixed_type_v2 [2020/04/20 11:16] – unlinked email address to avoid spam. danack | rfc:mixed_type_v2 [2020/05/22 14:22] (current) – kocsismate | ||
---|---|---|---|
Line 4: | Line 4: | ||
* Author: Máté Kocsis < | * Author: Máté Kocsis < | ||
* Based on previous RFC by: Michael Moravec | * Based on previous RFC by: Michael Moravec | ||
- | * Status: | + | * Status: |
* Implementation: | * Implementation: | ||
* First Published at: https:// | * First Published at: https:// | ||
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 {} | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | ==== 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 | ||
+ | </ | ||
+ | |||
+ | 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 | ||
+ | |||
</ | </ | ||
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 '' | + | <doodle title=" |
+ | * Yes | ||
+ | * No | ||
+ | </doodle> | ||
rfc/mixed_type_v2.txt · Last modified: 2020/05/22 14:22 by kocsismate