Re: [RFC] Transform void into an alias for null

From: Date: Tue, 03 Jun 2025 16:43:38 +0000
Subject: Re: [RFC] Transform void into an alias for null
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-127565@lists.php.net to get a copy of this message
On Tue, Jun 3, 2025, at 4:33 AM, Christoph M. Becker wrote: > On 03.06.2025 at 03:36, Anton Smirnov wrote: > >> On 02/06/2025 20:01, Larry Garfield wrote: >> >>> 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(); >> >> There is no error: https://3v4l.org/UD4vn > > I guess that Larry meant return instead of > print: > <https://3v4l.org/7dtYH>. No, I did not. I was sure I've run into places before where even trying to assign the return value of a void function to something gives me an error, but perhaps it was one of the many SA tools I use (IDE, PHPStan, etc.). --Larry Garfield

« previous php.internals (#127565) next »