Re: [RFC] Return Type Declarations
| From: | Lazare Inepologlou | Date: | Fri, 25 Apr 2014 09:09:08 +0000 |
| Subject: | Re: [RFC] Return Type Declarations | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-73794@lists.php.net to get a copy of this message | ||
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;
}
}
Lazare INEPOLOGLOU
Ingénieur Logiciel