Re: [RFC] Transform void into an alias for null
| From: | Gina P. Banyard | Date: | Tue, 03 Jun 2025 14:55:33 +0000 |
| Subject: | Re: [RFC] Transform void into an alias for null | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-127557@lists.php.net to get a copy of this message | ||
On Monday, 2 June 2025 at 18:08, Kamil Tekiela <tekiela246@gmail.com> wrote:
> The RFC mentions that this will now become valid:
>
> function foo(): void {
> return null;
> }
>
> But what about the opposite:
>
> function foo(): null {
> return;
> }
This would also work indeed.
> or what Larry was trying to suggest:
>
> function foo(): null {
> print 'test';
> }
>
> $val = foo();
This would also work, as null and void would be isomorphic.
However, if you have a return type of T|null then you'd get errors in both cases.
I will clarify this in the RFC.
Best regards,
Gina P. Banyard