Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60387 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 69873 invoked from network); 1 May 2012 13:07:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 May 2012 13:07:37 -0000 Authentication-Results: pb1.pair.com header.from=reeze.xia@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=reeze.xia@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.42 as permitted sender) X-PHP-List-Original-Sender: reeze.xia@gmail.com X-Host-Fingerprint: 209.85.216.42 mail-qa0-f42.google.com Received: from [209.85.216.42] ([209.85.216.42:45364] helo=mail-qa0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0F/84-38165-310EF9F4 for ; Tue, 01 May 2012 09:07:31 -0400 Received: by qafi31 with SMTP id i31so1531673qaf.8 for ; Tue, 01 May 2012 06:07:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=G9LBjOQ3X8431fZOebe+Bg/v/XpYEElGq3R00Oge6ro=; b=Kb0Hr9Ird6Q2qfJlwxNIPwtI/Mfsz3FANuSZGcHhr26a3H0c+ozmUvxdxlukcg6SIv +8yDyCiss1DNcwsUttd2h2gPqmHLqWMgUbsZ8pfYaE4YfjIjoUeQUyDCyMT9tdCnxRRv /pKjYFpdnl6cT80V/rTNQM92xguCfPNIc87B0BenoMZ9B7695sKDeBwPezKUDXE2zCNW kJYPPCteBX9BFek9Om+KWJE52QzzZFhzfDpfPrsFQkhW9AMXoqRWngeDKukfboQVYV2g m2CkKQF+l4iCzaFR/qjuEt8MeUiH95kBpy4GB40ZLM2w8UX/VQLvUfruU+UDa2B9R+a9 zzEg== Received: by 10.229.137.149 with SMTP id w21mr6370752qct.27.1335877647571; Tue, 01 May 2012 06:07:27 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.236.206 with HTTP; Tue, 1 May 2012 06:07:07 -0700 (PDT) In-Reply-To: References: <3B7600EC10A34F89AA8195C7A83089C0@gmail.com> Date: Tue, 1 May 2012 21:07:07 +0800 Message-ID: To: Laruence Cc: "internals@lists.php.net" , tony2001@php.net, danko@very.lv, stas@php.net, dmitry@php.net, nikic@php.net, felipe@php.net Content-Type: multipart/alternative; boundary=00235452f834a59bf804bef94063 Subject: Re: Bug/Req:#61422顛 enble Type Hint autoloading From: reeze.xia@gmail.com (reeze) --00235452f834a59bf804bef94063 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi, Laruence: I mean pass a wrong class object to a function/method. if the type hinted Class didn't loaded, we could try to load it. (if it's the right class, nothing happened), eg. function func(NotFoundClass $a) {} maybe we could pass another class instance. $a =3D new DemoClass(); func($a); It would be useful for class_alias like Bug#61422 requested. It's a little narrow feature usage scenario=EF=BC=8Cbut it gives a way to h= andle it. so I think It might be useful=E3=80=82 if failed to autoload it raise E_CATCHABLE_FATAL, loaded class will simple released if user catch the E_CATABLE_FATAL, loaded class will be useful, since it will be used later. if loaded success everyone is happy. On 1 May 2012 20:25, Laruence wrote: > On Tue, May 1, 2012 at 8:03 PM, reeze wrote: > > Hi internals: > > danko reported this bug#61422: Lack of autoload on type hinting breaks > > class_alias=E3=80=82 > > now parmeter type hint DID NOT trying to autoload. I think allow it > > autoloading could be helpful. > > > > BUGS&Commit for quick refer: > > - https://bugs.php.net/bug.php?id=3D61422 > > - https://bugs.php.net/bug.php?id=3D39003 > > - http://svn.php.net/viewvc?view=3Drevision&revision=3D220906 > > > > PROPOSAL(FR)=EF=BC=9A > > **I'm asking if we can enable type hint autoloading?** > > > > I did some homework: > > - Before FIX for #39003, parameter type hint will try to autoload the > hint > > class if not found. > > after this fix it will not. in bug#39003: the final result wa= s > DOC > > Problem, seems we all agreed > > that it SHOULD autoloading. > > - But in > > revision: http://svn.php.net/viewvc?view=3Drevision&revision=3D220906 I= t was > > **FIXED** > > I try to search RFC about typehint, I didn't find anything > about > > it. It was commited really long time ago > > almost 6 years ago, it would be very nice if Antony > Dovgal still > > remember it;) > > > > REASON=EF=BC=9A > > Here is my reason to ask whether we can enable it: > > > > 1. Autoload will only happened when function/method calling. so does an= y > > other autoloading, > > I mean it wouldn't hurt performance. > > 2. Class will be used for sure, so trying to autoload it is reasonable: > > - If we need check certain Class, then we have to use the class = in > > function/method. > > - most of time it already loaded*, so autoloading happened rarel= y. > > 3. If pass the wrong type and the hinted class not found this gives > > autoloader a change to handle it > > like the #61422's test script did. we can do something if not found= . > > since we use the class in > > function/method, autoload the class is reasonable. most of the time > we > > would not use the *FEATURE*, > > but it could make it more flexible. > > > > PATCH: > > > > 1. change zend_verify_arg_class_kind to autoload class > > 2. if class can't load, zend_fetch_class silently return (No fatal here= ) > to > > give zend_verify_arg_class_kind a chance > > to report previous catchable_fatal_error eg=EF=BC=9A > > Catchable fatal error: Argument 1 passed to func() must be an instance = of > > AX, integer given=E3=80=82 > > > > a simple patch attached request for comment. > > > > Finally, What do you guys think about it? > Hi: > thanks for writing this, but I was a little confused, please > correct me if I mis-understand you. > > if you pass a right instance of class to a function , how can that > class not be loaded already? > > for example: > function foo(Foo_Bar $a) { > } > > how can you pass a Foo_Bar instance to function foo without > Foo_Bar class already defined? > > > thanks > > > > > > Thanks. > > Best, > > -- > > reeze | simpie.com > > > > -- > Laruence Xinchen Hui > http://www.laruence.com/ > --=20 http://reeze.cn --00235452f834a59bf804bef94063--