Re: [PATCH] Re: [PHP-DEV] namespace examples (solving name resolutionorder issues)
| From: | Stanislav Malyshev | Date: | Fri, 12 Sep 2008 19:24:31 +0000 |
| Subject: | Re: [PATCH] Re: [PHP-DEV] namespace examples (solving name resolutionorder issues) | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-40484@lists.php.net to get a copy of this message | ||
Hi!
The caching is at runtime. Basically, it's in executor_globals, and so
is not linked to any opcode array (I couldn't figure out any other
globally accessible storage location). It works like an associative
array. If file X.php loads XMLReader in namespace namespacename, it
creates this entry:
array(
'X.php\0namespacename::XMLReader' => {class entry for XMLReader}
);
I though a bit about that patch, and I see following problems with it:
1. If you do not use autoloading, you still can get different
resolution, e.g.:
<?php
namespace foo;
$a = new XMLReader;
resolves to ::XMLReader and cached for this file. But suppose some other
file, somewhere, loaded foo::XMLReader prior to that. Then the same code
here would resolve now to foo::XMLReader as before, right?
Isn't it the same scenario you complained about? If so this patch does not solve this for 100% of cases, unless I misunderstand how the patch works.
2. While the caching indeed helps per-file, typical OO application
contains dozens of files, and each file may use dozens of internal classes (my install has 100+ internal classes). Meaning, there is still potential for hundreds of non-cacheable exhaustive autoload searches. This is not a good scenario.
--
Stanislav Malyshev, Zend Software Architect
stas@zend.com http://www.zend.com/
(408)253-8829 MSN: stas@zend.com