Re: [RFC] Return Type Declarations
| From: | Will Fitch | Date: | Fri, 25 Apr 2014 14:59:55 +0000 |
| Subject: | Re: [RFC] Return Type Declarations | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-73799@lists.php.net to get a copy of this message | ||
On Fri, Apr 25, 2014, at 07:52 AM, Levi Morrison wrote:
> On Fri, Apr 25, 2014 at 3:09 AM, Lazare Inepologlou
> <linepogl@gmail.com>wrote:
>
> > Hello,
> >
> > 2014-04-24 17:59 GMT+02:00 Levi Morrison <levim@php.net>:
> >
> > My dear Internals friends,
> >>
> >> I have spent the last month drafting an RFC that allows return types:
> >> https://wiki.php.net/rfc/returntypehinting
> >>
> >> Notable items:
> >> - Differences from past RFCs are summarized in the RFC:
> >>
> >> https://wiki.php.net/rfc/returntypehinting#differences_from_past_rfcs
> >> - The patch includes basic opcache and reflection support. It also has
> >> phpt tests.
> >> - Informal performance tests indicate that the patch did not fubar
> >> performance; if desired a more detailed test can be conducted before
> >> voting.
> >> - This RFC does not add, modify, or remove keywords at all; this notably
> >> excludes type-hints for scalars. Supporting scalar type declarations is
> >> outside the scope of this RFC; if you are interested in supporting scalar
> >> type declarations please discuss it elsewhere.
> >>
> >> As a friendly reminder, everyone on this list is interested in developing
> >> a
> >> better PHP and the definitions of 'better' vary from person to person.
> >> Please be civil and constructive while discussing this RFC. Thank you!
> >>
> >> Some thanks, regardless if the RFC is accepted:
> >> - For providing a patch: Joe Watkins.
> >> - For helping me iterate on RFC drafts: Bob Wienand, Nikita Popov and
> >> Anthony Ferrara
> >> - For previous RFCs on this topic: Felipe Pena and Will Fitch. I gleaned
> >> valuable knowledge from your proposals and the discussion around them.
> >>
> >
> >
> > This is a nice and well thought proposal.
> >
> > I would like to suggest the addition of the "self" and "static" pseudo
> > types. Most IDEs support this through @return syntax:
> >
> > class Foo {
> > /** @return static */
> > public function SetBar( $bar ) {
> > // ...
> > return $this;
> > }
> > }
> >
> > With the new syntax, the above could be transformed into this:
> >
> > class Foo {
> > public function SetBar( $bar ) : static {
> > // ...
> > return $this;
> > }
> > }
> >
>
> As the patch currently stands you can use the type-hint 'self'.
How will this patch work with LSB?