Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37636 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 67860 invoked from network); 13 May 2008 21:48:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 May 2008 21:48:54 -0000 X-Host-Fingerprint: 64.58.161.125 wsip-64-58-161-125.oc.oc.cox.net Received: from [64.58.161.125] ([64.58.161.125:28736] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 06/A1-56694-4CC0A284 for ; Tue, 13 May 2008 17:48:53 -0400 Message-ID: <06.A1.56694.4CC0A284@pb1.pair.com> To: internals@lists.php.net Date: Tue, 13 May 2008 14:50:44 -0700 User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 References: <482A0624.4040003@zend.com> In-Reply-To: <482A0624.4040003@zend.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 64.58.161.125 Subject: Re: [PHP-DEV] 5.3 and reflection From: jeremy@pinacol.com (Jeremy) Stanislav Malyshev wrote: > Hi! > >> I'm installing a recent snap of 5.3 on my dev server. The app I'm >> working on makes heavy use of reflection. How has reflection changed >> in 5.3 to address namespaces? What resolution rules apply when >> creating a > > Namespaces should not have big influence on reflection, since namespace > is just the logical partitioning of the class name - i.e. if the class > name is Foo::Bar::Baz, you can say that Foo::Bar is the namespace, but > for reflection you still use full class name. > >> ReflectionClass? If I try to create a ReflectionClass for a class >> that is outside the current namespace, what will happen? > > You should be able to use any class name with ReflectionClass. Since > namespaces are compile-time only, at runtime there's no such thing as > "current namespace". > Thanks for your response. Just to clarify, - Class names are translated at compile time to include the namespace. This composite is now considered to be the class name by the engine, and the class name alone (i.e. "Baz") is no longer meaningful. - Therefore, to reflect a class at runtime, the namespace must be included. To continue your example, if I tried to do this: $reflect = new ReflectionClass("Baz"); it would not work, regardless of the namespace of the file that statement appears in. I must instead do this: $reflect = new ReflectionClass("Foo::Bar::Baz"); Furthermore, there will never be a way to reflect a namespace, since the concept of namespacing is essentially lost by the time the reflection code would be executed. Is this accurate? Thanks, Jeremy