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
[EMAIL PROTECTED]   http://www.zend.com/
(408)253-8829   MSN: [EMAIL PROTECTED]

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to