Re: namespace separator and whining
| From: | Steph Fox | Date: | Tue, 04 Nov 2008 18:01:51 +0000 |
| Subject: | Re: namespace separator and whining | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-41656@lists.php.net to get a copy of this message | ||
Hi Stefan,
For clarity... Current behaviour: 1) check for namespaced\classname 2) check for internal classname 3) try to autoload namespaced\classname 4) fail Proposed (Stas, Greg): 1) check for namespaced\classname 2) try to autoload namespaced\classname 3) fail What I'm suggesting is a configurable switch between that proposed order and: 1) check for namespaced\classname 2) try to autoload namespaced\classname 3) check for internal classname 4) failDev writes a script, uses autoload, overrides global class.Distributed to user, that has ns.lookup=On as you propose, user borks his install, lacks the file containing the class, gets the global class -> obscure error messages because of nonexisting methods in places unrelated to the place where the actual error happened. Not really a good idea, IMO.This is what happens now, right. So what's different?With the proposed change -- failing at "step 3", it doesn't. It fails at the time that you try to create the instance, saying the class was not found, which is actually the case.
Failing there is the best option. It's not like you have to prefix every single occurence, you just have to say at the top of the file "When I say Exception, I mean \Exception".I see your point. OK, thanks. - StephThe point is that your dev would have done exactly that, so whether your user has the setting on or off is immaterial. - StephNo, the dev didn't mean \Exception, he meant *his* exception, the one that he has in the current namespace, and any way your setting would not have resulted in any error, because for the dev, autoload worked.