Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85073 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 69126 invoked from network); 16 Mar 2015 16:33:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Mar 2015 16:33:26 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@beccati.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=php@beccati.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain beccati.com designates 176.9.114.167 as permitted sender) X-PHP-List-Original-Sender: php@beccati.com X-Host-Fingerprint: 176.9.114.167 spritz.beccati.com Received: from [176.9.114.167] ([176.9.114.167:49146] helo=mail.beccati.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E2/A5-34940-4D507055 for ; Mon, 16 Mar 2015 11:33:25 -0500 Received: (qmail 3680 invoked from network); 16 Mar 2015 16:33:20 -0000 Received: from home.beccati.com (HELO ?192.168.1.202?) (88.149.176.119) by mail.beccati.com with SMTP; 16 Mar 2015 16:33:20 -0000 Message-ID: <550705C9.3010403@beccati.com> Date: Mon, 16 Mar 2015 17:33:13 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: "internals@lists.php.net" References: <54CC8E81.3020104@beccati.com> <746466D2-F3DB-4561-8C78-8685CC8F7EE7@ajf.me> <54DFAEC6.2050903@beccati.com> <54E066B0.1040501@beccati.com> In-Reply-To: <54E066B0.1040501@beccati.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC][DISCUSSION] ReflectionParameter::getClassName() From: php@beccati.com (Matteo Beccati) Hi everyone, I know it's late for the RFC party, but it looks like some form of STH is going to land in PHP7. Without reflection support, which is also missing from return types as far as I know. That's why I'm resuming this thread, as I still think this is the best approach. Many do not like ReflectionTypeAnnotation, but that's a trivial change, if we can agree that the behaviour is correct. Cheers On 15/02/2015 10:28, Matteo Beccati wrote: > Hi, > > On 14/02/2015 21:23, Matteo Beccati wrote: >> On 14/02/2015 16:34, Philip Sturgeon wrote: >>> On Sat, Jan 31, 2015 at 8:27 PM, Andrea Faulds wrote: >>>> I think the more important issue is the conflict with the >>>> ReflectionTypeAnnotation RFC, which proposes something similar to >>>> what was originally part of the Return Types RFC: >>>> >>>> https://wiki.php.net/rfc/reflectionparameter.typehint >> >> That's the "reflection support" I was talking about! I knew there was >> something, but I just couldn't find it in the RFCs themself. >> >> I've been playing a little bit with Sara's work (as you might have >> noticed if you follow php-cvs - sorry again!) and got it working with >> the scalar type hints branch: >> >> https://github.com/mbeccati/php-src/tree/scalar_hints_with_reflection >> >> It's still missing the scalar part and possibly an easy way to get the >> class name as Phil suggests. > > Thanks to my cats waking me up too early on a sunday morning, I've > rebased Sara's patch to current master and updated it to support return > types: > > https://github.com/mbeccati/php-src/commits/reflection.typehint > > The new methods are: > > * ReflectionFunctionAbstract::hasReturnTypeAnnotation() > * ReflectionFunctionAbstract::getReturnTypeAnnotation() > * ReflectionTypeAnnotation::isInstance() > > The latter should fulfil Phil's getClassName() purpose, albeit it's much > more verbose: > > function get_name (ReflectionParameter $rp) { > if ($rp->hasTypeAnnotation()) { > $ra = $rp->getTypeAnnotation(); > if ($ra->isInstance()) { > return (string) $ra; > } > } > } > > I've also added scalar support in: > > https://github.com/mbeccati/php-src/commits/scalar_hints_with_reflection > > which has: > > * ReflectionTypeAnnotation::isScalar() > > I believe that both isInstance/isScalar would probably apply to > ReflectionParameter too, unless the "old way" is supposed to be deprecated. > > @Phil I apologise it I hijacked your RFC, but I think that having just > ReflectionParameter::getClassName() falls a bit short IMHO, especially > with return types. > > @Andrea, @Sara I hope you don't mind ;) > > > Cheers -- Matteo Beccati Development & Consulting - http://www.beccati.com/