Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78719 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33183 invoked from network); 5 Nov 2014 12:45:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Nov 2014 12:45:19 -0000 Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.208 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.208 imap2-3.ox.privateemail.com Received: from [192.64.116.208] ([192.64.116.208:33928] helo=imap2-3.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E7/73-10214-DDB1A545 for ; Wed, 05 Nov 2014 07:45:18 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id 503258C007D; Wed, 5 Nov 2014 07:45:15 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at imap2.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap2.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 7knMjVVSj7SG; Wed, 5 Nov 2014 07:45:15 -0500 (EST) Received: from [137.50.28.211] (oa-res-28-211.wireless.abdn.ac.uk [137.50.28.211]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 2FCC88C007B; Wed, 5 Nov 2014 07:45:12 -0500 (EST) References: Mime-Version: 1.0 (1.0) In-Reply-To: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Message-ID: <5B1B375C-328B-40BD-B715-8EDA158B44CE@ajf.me> Cc: Levi Morrison , internals , Nikita Popov X-Mailer: iPhone Mail (12B411) Date: Wed, 5 Nov 2014 12:45:01 +0000 To: Dmitry Stogov Subject: Re: [PHP-DEV] [RFC][Vote] Return Types From: ajf@ajf.me (Andrea Faulds) > On 5 Nov 2014, at 11:53, Dmitry Stogov wrote: >=20 > Hi Levi, >=20 > The patch is here https://gist.github.com/dstogov/8deb8b17e41c1a5abf88 >=20 > I improved memory consumption and unified return type-hinting error > behavior with existing argument type-hinting. > The main semantic must be unchanged. This sounds good. > I also removed part of Reflection changes. I think we should remove even > more and later introduce similar APIs for both argument and return > type-hinting at once. I'd rather not go through 3 weeks of internals to get in ReflectionType for p= arameters. I'd imagine adding ->getReflectionType for parameters would be fa= irly uncontroversial, can we just do that now? > Working on the patch I found few problems. >=20 > 1) Return type-hinting for generators in existing state is useless. We may= > use it for checking "yield" value instead of "returned" or just disable it= > for now. I don't think it's useless. You can require a function to be a generator. Is= that bad? If we added generics in future, we could then type the yielded type, e.g. Ge= nerator maybe? > 2) "Covariant" return type check is really problematic. It delays class > binding to run-time, and requires all classes, used in hints, to be loaded= . The former sounds like a problem, but doesn't inheritance require these clas= ses to be loaded anyway? Do we always load the class in the hint? We could perhaps only do it for inh= eritance checks? > I would prefer to simplify this by using "Invariant" return types (similar= > to arguments) and checking just class names (without their loading). This is problematic, it'd stop classes from changing return types to subclas= ses in inheritance, which would make them less useful. -- Andrea Faulds http://ajf.me/=