Re: [RFC] Static return type

From: Date: Wed, 08 Jan 2020 21:11:49 +0000
Subject: Re: [RFC] Static return type
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-108040@lists.php.net to get a copy of this message
> On Jan 8, 2020, at 05:42, Nikita Popov <nikita.ppv@gmail.com> wrote: > > Hi internals, > > I would like to propose the following RFC, which allows using "static" as a > return type: > > https://wiki.php.net/rfc/static_return_type > > While I'm personally not a fan of late static binding, we do support it and > people do use it quite heavily, so I think we should also support it in > return types. > > Regards, > Nikita Yes, please! > For the fluent method example above, many projects will use a @return $this > annotation, rather than @return static. In my own code, I usually use self to mean “return the same instance.” While I know that, in practice, the use of self is identical to using the class name as the return type, it seems natural to designate as practice (among my team) that self always means itself and should never refer to an instance with different identity. -Ben

Attachment: [application/pgp-signature] Message signed with OpenPGP signature.asc
« previous php.internals (#108040) next »