::Exception, because the class resolution order seems to look like this:

- does the class exist (_already defined_) in the current namespace?
- does the class exist in the global (non-prefixed or "::") namespace?
- then try autoload

That's exactly how it works, with the amendment that only internal classes are considered on step 2.

What I think should happen is:

- does the class exist in the current namespace?
- can the class be autoloaded with the current namespace?
- does the class exist in the global scope
- global autoload

If it worked this way, you couldn't easily use global classes and old applications would be much harder to convert to namespaces. We think that using global Exception is much more frequent than defining your own Exception - and in the latter case you have the choice to name it something that is not the same as existing class, while in the latter case you do not. So we decided to make resolution rules so that it makes easier to work with the most frequent case and makes easier to work with existing code.

The other alternative would be to say that if you want to use a global class inside a namespace you MUST prefix it with ::. I think this is

We consider it not the best choice. Using of global classes is ubiquitous in current applications, always requiring :: would make it very hard to convert them to namespaced code. We think it would require much more work than just having "require_once" in places when you override the internal classes.

reasonable since if you have a namespaced file it's already not going to work with anything before PHP 5.3, and that would remove the two

The problem is not working with PHP before 5.3, the problem is using code that was written before 5.3. We try to make this code as easy as possible to upgrade, and it seems that blocking access to internal classes would not do us much good.
--
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