Hi Guys / Girls,
We are transitioning our framework to use the namespaces which are
available in php 5.3.

I found an explanation of the resolution rules here :
http://www.sitepoint.com/blogs/2009/07/14/php-namespaces-import-alias-resolution/
( also listed below)

and I was wondering what the performance implications of the different
stages of name resolution are. For example for the code in the
framework it's self would it be preferable to use a \Foo\Bar style
fully qualified class names in order for the resolution to be done at
compile time?

Thanks in advance
Andrew


1. Calls to fully-qualified functions, classes or constants are
resolved at compile-time.

2. Unqualified and qualified names are translated according to the
import rules, e.g. if the namespace A\B\C is imported as C, a call to
C\D\e() is translated to A\B\C\D\e().

3. Inside a namespace, all qualified names not already translated
according to import rules have the current namespace prepended, e.g.
if a call to C\D\e() is performed within namespace A\B, it is
translated to A\B\C\D\e().

4. Unqualified class names are translated according to current import
rules and the full name is substituted for short imported name, e.g.
if class C in namespace A\B is imported as X, new X() is translated to
new A\B\C().

5. Unqualified function calls within a namespace are resolved at
run-time. For example, if MyFunction() is called within namespace A\B,
PHP first looks for the function \A\B\MyFunction(). If that is not
found, it looks for \MyFunction() in the global space.

6. Calls to unqualified or qualified class names are resolved at
run-time. For example, if we call new C() within namespace A\B, PHP
will look for the class A\B\C. If that is not found, it will attempt
to autoload A\B\C.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to