Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:74110 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 63118 invoked from network); 9 May 2014 21:32:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 May 2014 21:32:16 -0000 Authentication-Results: pb1.pair.com header.from=jwatzman@fb.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=prvs=020629dd0a=jwatzman@fb.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain fb.com designates 67.231.145.42 as permitted sender) X-PHP-List-Original-Sender: prvs=020629dd0a=jwatzman@fb.com X-Host-Fingerprint: 67.231.145.42 mx0a-00082601.pphosted.com Linux 2.5 (sometimes 2.4) (4) Received: from [67.231.145.42] ([67.231.145.42:1790] helo=mx0a-00082601.pphosted.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FE/E1-46741-E594D635 for ; Fri, 09 May 2014 17:32:15 -0400 Received: from pps.filterd (m0044012 [127.0.0.1]) by mx0a-00082601.pphosted.com (8.14.5/8.14.5) with SMTP id s49LQe9R003119; Fri, 9 May 2014 14:32:11 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=facebook; bh=+7vx4aHNTWwF4Lpw8oV+8n5IBfFWx5SanmDgjftgKtI=; b=HC0rDHONrRv6NjQfBFoSnq3EMnJa79EDw5X0AjfUpDVXflXXQGW87VhJ1BZhkC9dyvNp E9T69OBZLb6LkTm0prSRY6ek5Ny5CsMXW5DFUwfm7rIDTvH7D4wrb1acGE5L3rgRZxKB LH4G3OrjdeuexrgoVC1Yrw8iSosfALFSGqw= Received: from mail.thefacebook.com (mailwest.thefacebook.com [173.252.71.148]) by mx0a-00082601.pphosted.com with ESMTP id 1krmeqmkc1-2 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=OK); Fri, 09 May 2014 14:32:10 -0700 Received: from PRN-MBX02-2.TheFacebook.com ([169.254.5.125]) by PRN-CHUB06.TheFacebook.com ([fe80::f073:2a60:c133:4d69%12]) with mapi id 14.03.0174.001; Fri, 9 May 2014 14:32:08 -0700 To: Stas Malyshev , Levi Morrison CC: internals Thread-Topic: [PHP-DEV] [RFC] Return Type Declarations pre-vote follow-up Thread-Index: AQHPa5iwbRN8uH8IdkWOuZ8Vefj2F5s5InuAgAAU3YCAAAMQgA== Date: Fri, 9 May 2014 21:32:07 +0000 Message-ID: References: <90B71511-4FB4-4916-9AC0-E3DD0D328C37@fb.com> <536D46C5.7040302@sugarcrm.com> In-Reply-To: <536D46C5.7040302@sugarcrm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [192.168.16.4] Content-Type: text/plain; charset="us-ascii" Content-ID: <851825B04892224784DF22CC04CFADBF@fb.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.11.96,1.0.14,0.0.0000 definitions=2014-05-09_08:2014-05-09,2014-05-09,1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 kscore.is_bulkscore=1.08870218396007e-08 kscore.compositescore=0 circleOfTrustscore=5.83964963933017 compositescore=0.999741511802045 urlsuspect_oldscore=0.999741511802045 suspectscore=0 recipient_domain_to_sender_totalscore=0 phishscore=0 bulkscore=0 kscore.is_spamscore=0 recipient_to_sender_totalscore=0 recipient_domain_to_sender_domain_totalscore=1889 rbsscore=0.999741511802045 spamscore=0 recipient_to_sender_domain_totalscore=5 urlsuspectscore=0.9 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=7.0.1-1402240000 definitions=main-1405090280 X-FB-Internal: deliver Subject: Re: [PHP-DEV] [RFC] Return Type Declarations pre-vote follow-up From: jwatzman@fb.com (Josh Watzman) > I'm not sure it is a good idea. This means having this code: > class FooGetter { > function getFoo(): Foo { return new Foo(); } > } >=20 > I can extend it as: > class TwoFaceFooGetter extends FooGetter { > function getFoo() { return rand()%2?new Bar():new Foo(); } > } >=20 > and every function getting FooGetter and expecting getFoo() to return > Foo is now broken since instead it could just get Bar(). Since the type > return specification is meant, as far as I understand, exactly to avoid > cases like that, I don't see it as a good idea. I understand, and this is the same argument LeviM has been making. (We just= discussed on IRC in #hhvm extensively.) Our view is that this code was *already* wrong. The type annotations don't = make it more or less wrong. What they do let you do is enforce, once the an= notation is in place, that it's correct moving forward for the places that = are annotated. (And if you want to go fix up and annotate TwoFaceFooGetter,= go do that! Or if you don't right now, don't!) Doing it this way also mean= s that you don't have to convert your entire hierarchy all at once -- gradu= al conversion of existing code was an important feature when we were adding= the Hack type system onto PHP. > The type 'self' is not late bound, unlike 'static' and exists in the lang= uage elsewhere; I am not introducing a new keyword 'self' in this RFC. We discussed this on IRC and came to consensus that "self" is just fine, th= ough not necessarily terribly useful if you think further than just enforci= ng the return type, to how that information might be propagated and used at= the callsite -- for example by the Hack static typechecker, or even by a h= uman. The type "static" tends to be what you want. But this isn't a huge de= al -- "self" as proposed isn't *wrong*. > All we did was copy the existing structure in Parameter type hints; this = was done for consistency. Is there any particular reason Hack/HHVM chose to= do something entirely different for return types in regards to reflection?= I don't particularly like the way type information is handled in Reflectio= n anyway. I don't know much about this or feel strongly one way or the other, just pl= aying messenger. Josh Watzman