Re: [RFC] [DISCUSSION] Allow void return type for constructors/destructors
| From: | Christoph M. Becker | Date: | Tue, 16 Jun 2020 20:57:04 +0000 |
| Subject: | Re: [RFC] [DISCUSSION] Allow void return type for constructors/destructors | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-110611@lists.php.net to get a copy of this message | ||
On 16.06.2020 at 21:30, Benas IML wrote:
> I put the original RFC on hold and created a new PR [0] for implicitly
> enforcing
void rules on both constructors and destructors.
> Note, that
> this results in a BC break since it is no longer legal to return non-void
> value from constructors/destructors. In other words, it is now illegal to
> return something from ctor.
>
> As a side bonus, it is also allowed to explicitly declare both
> __construct() and __destruct()
> as void (but this is by no means
> mandatory, it's optional).
>
> I'm not sure whether this needs a proper RFC since this is more of a patch
> (fix: #79679) than a new feature, so let me know!
>
> 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).
Thanks, I tend to prefer this solution. Given the potential BC break
(constructors may be called like normal methods, so returning something
can make sense), I think an RFC is justified.
--
Christoph M. Becker