Re: [RFC] [DISCUSSION] Allow void return type for constructors/destructors

From: Date: Wed, 17 Jun 2020 11:59:15 +0000
Subject: Re: [RFC] [DISCUSSION] Allow void return type for constructors/destructors
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-110628@lists.php.net to get a copy of this message
Thanks everybody for the replies.

> However, I am also fine if the void return value is only enforced when the void return
> type is declared. Additionally, we could emit a deprecation notice/warning when
> there is no return type declaration, but a value is returned. I think this would be
> a nice way to immediately give people the possibility to disallow a return value,
> while being respectful for older code bases.

Completely agreed. I'll update the RFC to reflect this as well.

We should allow newer codebases to enforce void rules on
constructors/destructors
by allowing to explicitly declare return type as void.

Meanwhile, we should throw a deprecation warning, if the
constructor/destructor is
returning a non-void value and doesn't have an explicit : void
declaration. Then,
presumably in PHP 9, in addition to explicit : void, also enforce
void rules implicitly
altogether.

Best regards,
Benas

On Wed, 17 Jun 2020 at 11:31, Máté Kocsis <kocsismate90@gmail.com> wrote:
>>
>> This PR should also address all of Máté's concerns since it makes
>> constructors and destructors always return void (even when no explicit
>> void return type is specified).
>
>
> To be clear, my main concern was that declaring a void return type shouldn't be
> allowed, unless it's actually enforced. Now, it's all fine because you stated your
> intentions :)
>
> However, I am also fine if the void return value is only enforced when the void return
> type is declared. Additionally, we could emit a deprecation notice/warning when
> there is no return type declaration, but a value is returned. I think this would be
> a nice way to immediately give people the possibility to disallow a return value,
> while being respectful for older code bases.
>
> Regards,
> Máté
>
>


Thread (23 messages)

« previous php.internals (#110628) next »