I don't understand what are you going to demonstrate with this example.
Did you try to run it?
It produces error as expected.

DOMDocument() in your example is a user-space class that is not related to internal ext/dom class. If you like to use internal class that is overriden in namespace you can use ::DomDocument instead.

The "use DomDocument as test;" is useless from my point of view.
You always may override internal classes in namespaces.

Thanks. Dmitry.

Derick Rethans wrote:
On Tue, 4 Dec 2007, Gregory Beaver wrote:

However, in the global scope (no namespace) it would fail.  This is a
bug that is easily fixed.  use should allow re-aliasing of global
classes, and I could provide a very easy fix.

No, use should not allow this. Take the following example:

<?php
namespace blah;
use DomDocument as test;

class DOMDocument { }

$dom = new DOMDocument; // $dom->loadXML('<books><book><title>blah</title></book></books>');
$s = simplexml_import_dom($dom);

echo $s->book[0]->title; // blah
?>

Besides this being a *big* WTF factor (why is my internal class suddendly doing something else?) simplexml will horrible fail in this case.

Derick


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to