summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Zend/zend_API.c36
-rw-r--r--Zend/zend_API.h1
2 files changed, 24 insertions, 13 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index fcfd7dff61..5fac428ac4 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -1146,7 +1146,7 @@ int zend_register_functions(zend_class_entry *scope, zend_function_entry *functi
int error_type;
zend_function *ctor = NULL, *dtor = NULL, *clone = NULL;
char *lowercase_name;
- int fname_len;
+ int fname_len, is_namespace = 0;
zend_namespace *scope_namespace;
if (type==MODULE_PERSISTENT) {
@@ -1162,6 +1162,7 @@ int zend_register_functions(zend_class_entry *scope, zend_function_entry *functi
if(scope) {
scope_namespace = scope->ns;
+ is_namespace = (scope->type == ZEND_INTERNAL_NAMESPACE || scope->type == ZEND_USER_NAMESPACE) ? 1 : 0;
} else {
scope_namespace = EG(active_namespace);
}
@@ -1189,18 +1190,23 @@ int zend_register_functions(zend_class_entry *scope, zend_function_entry *functi
break;
}
if (scope) {
- /*
- * If it's an old-style constructor, store it only if we don't have
- * a constructor already.
- */
- if (!strcmp(ptr->fname, scope->name) && !ctor) {
- ctor = reg_function;
- } else if (!strcmp(ptr->fname, ZEND_CONSTRUCTOR_FUNC_NAME)) {
- ctor = reg_function;
- } else if (!strcmp(ptr->fname, ZEND_DESTRUCTOR_FUNC_NAME)) {
- dtor = reg_function;
- } else if (!strcmp(ptr->fname, ZEND_CLONE_FUNC_NAME)) {
- clone = reg_function;
+ if (is_namespace) {
+ /* if namespace all methods must be "static final" */
+ reg_function->common.fn_flags = ZEND_ACC_FINAL | ZEND_ACC_STATIC;
+ } else {
+ /* if class not namespace then look for ctor, dtor, clone
+ * If it's an old-style constructor, store it only if we don't have
+ * a constructor already.
+ */
+ if (!strcmp(ptr->fname, scope->name) && !ctor) {
+ ctor = reg_function;
+ } else if (!strcmp(ptr->fname, ZEND_CONSTRUCTOR_FUNC_NAME)) {
+ ctor = reg_function;
+ } else if (!strcmp(ptr->fname, ZEND_DESTRUCTOR_FUNC_NAME)) {
+ dtor = reg_function;
+ } else if (!strcmp(ptr->fname, ZEND_CLONE_FUNC_NAME)) {
+ clone = reg_function;
+ }
}
}
ptr++;
@@ -1438,6 +1444,10 @@ ZEND_API zend_namespace *zend_register_internal_namespace(zend_namespace *orig_n
zend_hash_update(&CG(global_namespace).class_table, lowercase_name, ns->name_length+1, &ns, sizeof(zend_namespace *), NULL);
free(lowercase_name);
+ if (ns->builtin_functions) {
+ zend_register_functions(ns, ns->builtin_functions, &ns->function_table, MODULE_PERSISTENT TSRMLS_CC);
+ }
+
return ns;
}
diff --git a/Zend/zend_API.h b/Zend/zend_API.h
index 5fa9b44624..d8ebb20ac8 100644
--- a/Zend/zend_API.h
+++ b/Zend/zend_API.h
@@ -106,6 +106,7 @@ BEGIN_EXTERN_C()
#define INIT_NAMESPACE(ns_container, ns_name) INIT_CLASS_ENTRY(ns_container, ns_name, NULL)
+#define INIT_NAMESPACE_WITH_FUNCS(ns_container, ns_name, functions) INIT_CLASS_ENTRY(ns_container, ns_name, functions)
int zend_next_free_module(void);