mirror of
https://github.com/php/php-src.git
synced 2024-12-01 13:54:10 +08:00
Allow functions in internal namespaces (for example factories)
This commit is contained in:
parent
a6d0c66a16
commit
29a3586f7b
@ -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,7 +1190,11 @@ int zend_register_functions(zend_class_entry *scope, zend_function_entry *functi
|
||||
break;
|
||||
}
|
||||
if (scope) {
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
@ -1203,6 +1208,7 @@ int zend_register_functions(zend_class_entry *scope, zend_function_entry *functi
|
||||
clone = reg_function;
|
||||
}
|
||||
}
|
||||
}
|
||||
ptr++;
|
||||
count++;
|
||||
free_alloca(lowercase_name);
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user