Re: early class binding revisited
| From: | phpxcache | Date: | Sun, 30 Dec 2007 12:16:07 +0000 |
| Subject: | Re: early class binding revisited | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-34280@lists.php.net to get a copy of this message | ||
> Compiler shouldn't generate different code. Unqualified name is resolved
> at runtime, but code should be the same whatever resolution was made.
> Did you check that different code is indeed generated?
zend_compile.c
===============
if (zend_hash_find(CG(class_table), lcname,
Z_STRLEN(class_name->u.constant)+1, (void**)&pce) == SUCCESS &&
(*pce)->type == ZEND_INTERNAL_CLASS) {
/* There is an internal class with the same name exists.
PHP will need to perform additional cheks at run-time to
determine if we assume class in current namespace or
internal one. */
*fetch_type |= ZEND_FETCH_CLASS_RT_NS_CHECK;
}
it's an optimization and assume that internal class never change
let me guess, if you have php_abc.so which have "internal" (well, 3rd
party) "class abc" not loaded when you encode php files with
ZendEncoder
namespace mynamespace;
var_dump(new abc());
but you do load file for production server, you still get "undefined
class mynamespace::abc" at runtime, internal class abc is never
checked.