Re: [RFC] Transform void into an alias for null
| From: | Larry Garfield | Date: | Mon, 02 Jun 2025 17:01:54 +0000 |
| Subject: | Re: [RFC] Transform void into an alias for null | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-127537@lists.php.net to get a copy of this message | ||
On Mon, Jun 2, 2025, at 11:27 AM, Gina P. Banyard wrote:
> Hello internals,
>
> This is the second RFC out of a set of type system related RFCs I want
> to propose for PHP 8.5.
>
> The objective is to fix a weird quirk of PHP's type system, where void
> lives in its own type hierarchy.
> This is visible mainly in that a lack of return type is not isomorphic
> to a function that has a return type of mixed.
>
> Let me know what you think about it.
>
> RFC: https://wiki.php.net/rfc/void-as-null
>
> Best regards,
>
> Gina P. Banyard
The result of this RFC is that the following would no longer be an error, yes?
function test(): void {
print "test";
}
// This currently gives an error, but you propose that it
// would change to set $val to null?
$val = test();
--Larry Garfield