Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37637 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 71258 invoked from network); 13 May 2008 21:59:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 May 2008 21:59:49 -0000 Authentication-Results: pb1.pair.com smtp.mail=stas@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=stas@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.25.124.162 as permitted sender) X-PHP-List-Original-Sender: stas@zend.com X-Host-Fingerprint: 212.25.124.162 mail.zend.com Windows 2000 SP4, XP SP1 Received: from [212.25.124.162] ([212.25.124.162:8982] helo=mx1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D3/22-56694-35F0A284 for ; Tue, 13 May 2008 17:59:48 -0400 Received: from us-ex1.zend.com ([192.168.16.5]) by mx1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 14 May 2008 01:00:49 +0300 Received: from [192.168.16.217] ([192.168.16.217]) by us-ex1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 13 May 2008 15:00:45 -0700 Message-ID: <482A0F4C.4050607@zend.com> Date: Tue, 13 May 2008 14:59:40 -0700 Organization: Zend Technologies User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 To: Jeremy CC: internals@lists.php.net References: <482A0624.4040003@zend.com> <06.A1.56694.4CC0A284@pb1.pair.com> In-Reply-To: <06.A1.56694.4CC0A284@pb1.pair.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 13 May 2008 22:00:45.0667 (UTC) FILETIME=[CB80AB30:01C8B544] Subject: Re: [PHP-DEV] 5.3 and reflection From: stas@zend.com (Stanislav Malyshev) Hi! > 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"); Right. You can use __NAMESPACE__ compile-time constant to save yourself some typing and maintenance if you are doing it inside namespace declaration. So it'd be: $reflect = new ReflectionClass(__NAMESPACE__."::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? Yes. You can of course get class name and split it by :: and use the parts as you wish, but there's no such separate entity as "namespace" containing classes in the engine, so you can ask only "what class names begin with Foo::Bar::". We could make reflection method that does just that - i.e. lists classes beginning with certain prefix - but we didn't see a need for it yet. If there would be some user demand for it, it might be added later. -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com