Re: PHP 5.3 Autoload+Namespaces+Functions incorret (atleast wierd) behaviour.

From: Date: Mon, 03 Mar 2008 11:40:52 +0000
Subject: Re: PHP 5.3 Autoload+Namespaces+Functions incorret (atleast wierd) behaviour.
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-35912@lists.php.net to get a copy of this message
Hi Fredrik, On Fri, 2008-02-29 at 16:02 +0100, "=?ISO-8859-1?Q?Fredrik_Holmstr=F6m?=" wrote: > Basicly, the call is this: Demo::Functions::test(); where both Demo > and Functions are namespaces, and test() is a function inside the > Demo::Functions namespace. If you have an autoload handler here and > the file containing the Demo::Function::test()-decleration isn't > loaded, autoload will be called. > > Now everything seems fine, but the problem is that when the autoload > hooks have all fired php looks for the class Demo::Function, because > autoload seems to be interpreting the Demo::Function::test(); call as: > <Namespace>::<Class>::<Function>, when it should be > <Namespace>::<Namespace>::<Function>, and since the Function class > doesn't exist it will trigger a fatal error. autoload was designed for loading classes not functions. Wen resolving Demo::Function::test() and no function having that name is being found it's assumed that Demo is the namespace, function a class name in there and test a static method call. There's no way for the engine to see what else might be meant. So the result is expected and changing it woud mean to do major changes wich just creates new problems. johannes

« previous php.internals (#35912) next »