Here's how think the patch works (baring in mind my C is rusty and I'm unfamiliar with the PHP source..)
When you do namespace ns { }, a global is set to the current namespace:
Code:
+void zend_do_begin_namespace(znode *ns_token, znode *ns_name TSRMLS_DC)
+{
+ /* allocate space for the namespace prefix */
+ CG(namespace_prefix) = emalloc(ns_name->u.constant.value.str.len + 2);
+
+ /* get the namespace prefix */
+ strncpy(CG(namespace_prefix), ns_name->u.constant.value.str.val, ns_name->u.constant.value.str.len + 1);
+ strcat(CG(namespace_prefix), ":");
+
+ /* get the lowercased namespace prefix */
+ CG(namespace_prefix_lc) = zend_str_tolower_dup(CG(namespace_prefix), ns_name->u.constant.value.str.len + 1);
+
+ /* save the prefix length */
+ CG(namespace_prefix_len) = ns_name->u.constant.value.str.len + 1;
+}
The global is then used to rename the class if it is set:
Code:
+void zend_prefix_class_name_node(znode *class_name TSRMLS_DC)
+{
+ zend_uint new_length = 0;
+ char *org_class_name = NULL;
+
+ if (CG(namespace_prefix) != NULL) {
+ new_length = CG(namespace_prefix_len) + class_name->u.constant.value.str.len;
+ org_class_name = estrdup(class_name->u.constant.value.str.val);
+
+ STR_REALLOC(class_name->u.constant.value.str.val, new_length + 1);
+
+ /* get the full class name */
+ strncpy(class_name->u.constant.value.str.val, CG(namespace_prefix), CG(namespace_prefix_len) + 1);
+ strcat(class_name->u.constant.value.str.val, org_class_name);
+
+ /* get the new string length */
+ class_name->u.constant.value.str.len = new_length;
+
+ efree(org_class_name);
+ }
+}
So, "yes".
Regards,
Douglas
Bookmarks