Re: Autoloading with namespaces in 5.3.0

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, May 30, 2009 at 1:51 PM, Eddie Drapkin <oorza2k5@xxxxxxxxx> wrote:

> Hey, I'm looking to start playing with 5.3.0, and thus by extension,
> namespaces.  One of the things that I definitely need support for is
> autoloading, and the docs aren't exactly explicit in some (obvious to me)
> cases.
>
> I have an autoloading class that internally handles file-not-found errors
> and the like and a set of methods that get registered via
> spl_autoload_register.  I'm wondering if there's any way that the
> autoloader
> - which won't exist inside a namespace - can handle classes with the same
> name in several different namespaces.  Say, for example, I have three
> directories foo/, bar/, and baz/ and each of those corresponds to a
> same-named namespace, and each also has a class named ExampleClass.  If I
> try to instantate a foo\ExampleClass, does the classname get set in the
> autoloader method as "ExampleClass" or "foo\ExampleClass"?  If the former,
> is there any way to determine the namespace name so I don't accidentally
> autoload bar\ExampleClass or baz\ExampleClass?
>

i seem to remember a while back, someone saying the entire namespace will
now be passed into the __autoload() function, whereas before it was just the
classname.  your autoload logic should be equipped to handle different
classes w/ the same name, in different namespaces.

-nathan

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux