Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:73798 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99570 invoked from network); 25 Apr 2014 14:52:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Apr 2014 14:52:13 -0000 Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.175 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.214.175 mail-ob0-f175.google.com Received: from [209.85.214.175] ([209.85.214.175:64880] helo=mail-ob0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BD/21-24508-C967A535 for ; Fri, 25 Apr 2014 10:52:13 -0400 Received: by mail-ob0-f175.google.com with SMTP id wp4so4330785obc.20 for ; Fri, 25 Apr 2014 07:52:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=BxZXrHhaEFG7THNjX4ao/v/yrgfmdcP2ie87PsyDnqA=; b=iNPCovsbPgBKC9vZSilzlhyLKX7GGTPUbsOjldfQLsGzBPidgFbRYzMdt7MVVm48Kd iAVNrJkaF57HGCETEp/xYZ9DOVToAQZYLMMBx0J5rJSckuA+gy7qxrMD3xx7frhS/kL6 YtlZAliab/YOYS2IsxzsDEdG1okjrMtFV0BPhpHS8m5NiTtgoSpWZW4iI1OAWDMFyD5w DWKiRxDqL0ptr895RAZX2i98wcNxQSZVsAQqBdu62nhFdk7TWqnfwjXiN5WmMYlXdHdD aNYz/WG7u1bjGgF7oOYE5noqWGDpBylQ+SWCXGcFapY4AmdBLf0e3xZGp37ZrMyjO2Ng 9t6g== MIME-Version: 1.0 X-Received: by 10.182.38.199 with SMTP id i7mr1756837obk.68.1398437530308; Fri, 25 Apr 2014 07:52:10 -0700 (PDT) Received: by 10.76.77.100 with HTTP; Fri, 25 Apr 2014 07:52:10 -0700 (PDT) In-Reply-To: References: Date: Fri, 25 Apr 2014 08:52:10 -0600 Message-ID: To: Lazare Inepologlou Cc: internals Content-Type: multipart/alternative; boundary=001a11c32ddc3c16a604f7df1cd5 Subject: Re: [PHP-DEV] [RFC] Return Type Declarations From: morrison.levi@gmail.com (Levi Morrison) --001a11c32ddc3c16a604f7df1cd5 Content-Type: text/plain; charset=UTF-8 On Fri, Apr 25, 2014 at 3:09 AM, Lazare Inepologlou wrote: > Hello, > > 2014-04-24 17:59 GMT+02:00 Levi Morrison : > > 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'. --001a11c32ddc3c16a604f7df1cd5--