Re: [PHP-DEV] Re: [RFC] [VOTE] Make constructors and destructorsreturn void

This is only part of a thread. view whole thread
  110894
July 9, 2020 13:51 kontakt@beberlei.de (Benjamin Eberlei)
On Wed, Jul 8, 2020 at 10:15 PM Benas IML iml@gmail.com> wrote:

> Hey internals, > > I have reopened the voting. It is going to close July 22nd, 2020. I have > also > added a "Why allow void return type on constructors/destructors?" section > which > I hope internals are going to read and consider before voting. Thanks! >
I wanted to give a datapoint for my no vote. I think going from forbidding return types on ctors to requiring them to be void is one step to far. Yes, the use-cases for returning something from a constructor are questionable, but why force something that strictly is not something the language should care about, as it can as easily be a coding style topic. For me the RFC vote should be "allow to dcelare return types on constructors/destructors?", then people *can* declare void, but *can* also declare other things, but nothing *must* be done. Then it becomes a question of coding styles enforcing "void" for all constructors of a project for example. I would vote Yes on that.
> RFC: > https://wiki.php.net/rfc/make_ctor_ret_void > > Best regards, > Benas > > On Fri, 3 Jul 2020 at 00:12, Benas IML iml@gmail.com> wrote: > > > > Hey internals, > > > > I have opened the voting for the RFC, let's hope everything is going > > to be smooth :). If you have any other questions, let me know! > > > > RFC: https://wiki.php.net/rfc/make_ctor_ret_void > > > > Best regards, > > Benas Seliuginas > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > >
  110897
July 9, 2020 14:27 someniatko@gmail.com (someniatko)
> I think going from forbidding > return types on ctors to requiring them to be void is one step to far.
I am afraid you've slightly misunderstood the intention of this RFC. It is proposed that it is impossible to return anything from the constructor, not that you have to add ": void" to it.
  110900
July 9, 2020 15:41 phpmailinglists@gmail.com (Peter Bowyer)
On Thu, 9 Jul 2020 at 14:52, Benjamin Eberlei <kontakt@beberlei.de> wrote:

> For me the RFC vote should be "allow to dcelare return types on > constructors/destructors?", then people *can* declare void, but *can* also > declare other things, but nothing *must* be done. Then it becomes a > question of coding styles enforcing "void" for all constructors of a > project for example. I would vote Yes on that. >
Isn't this close to what the second vote "Allow void return type on constructors/destructors?" does? My understanding is that a "Yes" on this vote will: 1. Allow you to omit a return type (and therefore return whatever you want) 2. Explicitly add void return type This doesn't do exactly what you ask for (to add any return type) but to me is close enough; as these are meant to be void according to the PHP docs, having it as the only explicit return type makes sense to me. Peter