diff options
Diffstat (limited to 'ext/reflection')
35 files changed, 382 insertions, 418 deletions
diff --git a/ext/reflection/CREDITS b/ext/reflection/CREDITS index 84be988802..84be988802 100755..100644 --- a/ext/reflection/CREDITS +++ b/ext/reflection/CREDITS diff --git a/ext/reflection/config.m4 b/ext/reflection/config.m4 index daab409c32..daab409c32 100755..100644 --- a/ext/reflection/config.m4 +++ b/ext/reflection/config.m4 diff --git a/ext/reflection/config.w32 b/ext/reflection/config.w32 index 508696d033..508696d033 100755..100644 --- a/ext/reflection/config.w32 +++ b/ext/reflection/config.w32 diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 748f5b3f08..8114625e68 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -75,38 +75,37 @@ PHPAPI zend_class_entry *reflection_extension_ptr; PHPAPI zend_class_entry *reflection_zend_extension_ptr; /* Exception throwing macro */ -#define _DO_THROW(msg) \ - zend_throw_exception(reflection_exception_ptr, msg, 0); \ - return; \ - -#define RETURN_ON_EXCEPTION \ - if (EG(exception) && EG(exception)->ce == reflection_exception_ptr) { \ - return; \ - } - -#define GET_REFLECTION_OBJECT() \ - intern = Z_REFLECTION_P(getThis()); \ - if (intern->ptr == NULL) { \ - RETURN_ON_EXCEPTION \ - zend_throw_error(NULL, "Internal error: Failed to retrieve the reflection object"); \ - return; \ - } \ +#define _DO_THROW(msg) \ + zend_throw_exception(reflection_exception_ptr, msg, 0); \ + return; + +#define GET_REFLECTION_OBJECT() do { \ + intern = Z_REFLECTION_P(getThis()); \ + if (intern->ptr == NULL) { \ + if (EG(exception) && EG(exception)->ce == reflection_exception_ptr) { \ + return; \ + } \ + zend_throw_error(NULL, "Internal error: Failed to retrieve the reflection object"); \ + return; \ + } \ +} while (0) -#define GET_REFLECTION_OBJECT_PTR(target) \ - GET_REFLECTION_OBJECT() \ - target = intern->ptr; \ +#define GET_REFLECTION_OBJECT_PTR(target) do { \ + GET_REFLECTION_OBJECT(); \ + target = intern->ptr; \ +} while (0) /* Class constants */ -#define REGISTER_REFLECTION_CLASS_CONST_LONG(class_name, const_name, value) \ +#define REGISTER_REFLECTION_CLASS_CONST_LONG(class_name, const_name, value) \ zend_declare_class_constant_long(reflection_ ## class_name ## _ptr, const_name, sizeof(const_name)-1, (zend_long)value); /* {{{ Object structure */ /* Struct for properties */ typedef struct _property_reference { - zend_class_entry *ce; zend_property_info prop; zend_string *unmangled_name; + zend_bool dynamic; } property_reference; /* Struct for parameters */ @@ -119,8 +118,7 @@ typedef struct _parameter_reference { /* Struct for type hints */ typedef struct _type_reference { - struct _zend_arg_info *arg_info; - zend_function *fptr; + zend_type type; } type_reference; typedef enum { @@ -135,7 +133,6 @@ typedef enum { /* Struct for reflection objects */ typedef struct { - zval dummy; /* holder for the second property */ zval obj; void *ptr; zend_class_entry *ce; @@ -153,6 +150,11 @@ static inline reflection_object *reflection_object_from_obj(zend_object *obj) { static zend_object_handlers reflection_object_handlers; +static inline zend_bool is_closure_invoke(zend_class_entry *ce, zend_string *lcname) { + return ce == zend_ce_closure + && zend_string_equals_literal(lcname, ZEND_INVOKE_FUNC_NAME); +} + static zval *_default_load_name(zval *object) /* {{{ */ { return zend_hash_find_ex_ind(Z_OBJPROP_P(object), ZSTR_KNOWN(ZEND_STR_NAME), 1); @@ -203,7 +205,6 @@ static void reflection_free_objects_storage(zend_object *object) /* {{{ */ reflection_object *intern = reflection_object_from_obj(object); parameter_reference *reference; property_reference *prop_reference; - type_reference *typ_reference; if (intern->ptr) { switch (intern->ref_type) { @@ -213,8 +214,6 @@ static void reflection_free_objects_storage(zend_object *object) /* {{{ */ efree(intern->ptr); break; case REF_TYPE_TYPE: - typ_reference = (type_reference*)intern->ptr; - _free_function(typ_reference->fptr); efree(intern->ptr); break; case REF_TYPE_FUNCTION: @@ -266,7 +265,7 @@ static zval *reflection_instantiate(zend_class_entry *pce, zval *object) /* {{{ static void _const_string(smart_str *str, char *name, zval *value, char *indent); static void _function_string(smart_str *str, zend_function *fptr, zend_class_entry *scope, char* indent); -static void _property_string(smart_str *str, zend_property_info *prop, const char *prop_name, char* indent); +static void _property_string(smart_str *str, zend_property_info *prop, const char *prop_name, char* indent, zend_bool dynamic); static void _class_const_string(smart_str *str, char *name, zend_class_constant *c, char* indent); static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char *indent); static void _extension_string(smart_str *str, zend_module_entry *module, char *indent); @@ -324,6 +323,7 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char if (ce->num_interfaces) { uint32_t i; + ZEND_ASSERT(ce->ce_flags & ZEND_ACC_LINKED); if (ce->ce_flags & ZEND_ACC_INTERFACE) { smart_str_append_printf(str, " extends %s", ZSTR_VAL(ce->interfaces[0]->name)); } else { @@ -365,7 +365,7 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char zend_property_info *prop; ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop) { - if(prop->flags & ZEND_ACC_SHADOW) { + if ((prop->flags & ZEND_ACC_PRIVATE) && prop->ce != ce) { count_shadow_props++; } else if (prop->flags & ZEND_ACC_STATIC) { count_static_props++; @@ -379,8 +379,8 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char zend_property_info *prop; ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop) { - if ((prop->flags & ZEND_ACC_STATIC) && !(prop->flags & ZEND_ACC_SHADOW)) { - _property_string(str, prop, NULL, ZSTR_VAL(sub_indent)); + if ((prop->flags & ZEND_ACC_STATIC) && (!(prop->flags & ZEND_ACC_PRIVATE) || prop->ce == ce)) { + _property_string(str, prop, NULL, ZSTR_VAL(sub_indent), 0); } } ZEND_HASH_FOREACH_END(); } @@ -426,14 +426,15 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char zend_property_info *prop; ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop) { - if (!(prop->flags & (ZEND_ACC_STATIC|ZEND_ACC_SHADOW))) { - _property_string(str, prop, NULL, ZSTR_VAL(sub_indent)); + if (!(prop->flags & ZEND_ACC_STATIC) + && (!(prop->flags & ZEND_ACC_PRIVATE) || prop->ce == ce)) { + _property_string(str, prop, NULL, ZSTR_VAL(sub_indent), 0); } } ZEND_HASH_FOREACH_END(); } smart_str_append_printf(str, "%s }\n", indent); - if (obj && Z_TYPE_P(obj) == IS_OBJECT && Z_OBJ_HT_P(obj)->get_properties) { + if (obj && Z_TYPE_P(obj) == IS_OBJECT) { HashTable *properties = Z_OBJ_HT_P(obj)->get_properties(obj); zend_string *prop_name; smart_str prop_str = {0}; @@ -444,7 +445,7 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char if (prop_name && ZSTR_LEN(prop_name) && ZSTR_VAL(prop_name)[0]) { /* skip all private and protected properties */ if (!zend_hash_exists(&ce->properties_info, prop_name)) { count++; - _property_string(&prop_str, NULL, ZSTR_VAL(prop_name), ZSTR_VAL(sub_indent)); + _property_string(&prop_str, NULL, ZSTR_VAL(prop_name), ZSTR_VAL(sub_indent), 0); } } } ZEND_HASH_FOREACH_END(); @@ -471,15 +472,14 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char size_t len = ZSTR_LEN(mptr->common.function_name); /* Do not display old-style inherited constructors */ - if ((mptr->common.fn_flags & ZEND_ACC_CTOR) == 0 + if (mptr->common.scope->constructor != mptr || mptr->common.scope == ce || !key || zend_binary_strcasecmp(ZSTR_VAL(key), ZSTR_LEN(key), ZSTR_VAL(mptr->common.function_name), len) == 0) { zend_function *closure; /* see if this is a closure */ - if (ce == zend_ce_closure && obj && (len == sizeof(ZEND_INVOKE_FUNC_NAME)-1) - && memcmp(ZSTR_VAL(mptr->common.function_name), ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0 + if (obj && is_closure_invoke(ce, mptr->common.function_name) && (closure = zend_get_closure_invoke_method(Z_OBJ_P(obj))) != NULL) { mptr = closure; @@ -743,10 +743,10 @@ static void _function_string(smart_str *str, zend_function *fptr, zend_class_ent if (fptr->common.prototype && fptr->common.prototype->common.scope) { smart_str_append_printf(str, ", prototype %s", ZSTR_VAL(fptr->common.prototype->common.scope->name)); } - if (fptr->common.fn_flags & ZEND_ACC_CTOR) { + if (fptr->common.scope && fptr->common.scope->constructor == fptr) { smart_str_appends(str, ", ctor"); } - if (fptr->common.fn_flags & ZEND_ACC_DTOR) { + if (fptr->common.scope && fptr->common.scope->destructor == fptr) { smart_str_appends(str, ", dtor"); } smart_str_appends(str, "> "); @@ -821,14 +821,14 @@ static void _function_string(smart_str *str, zend_function *fptr, zend_class_ent /* }}} */ /* {{{ _property_string */ -static void _property_string(smart_str *str, zend_property_info *prop, const char *prop_name, char* indent) +static void _property_string(smart_str *str, zend_property_info *prop, const char *prop_name, char* indent, zend_bool dynamic) { smart_str_append_printf(str, "%sProperty [ ", indent); if (!prop) { smart_str_append_printf(str, "<dynamic> public $%s", prop_name); } else { if (!(prop->flags & ZEND_ACC_STATIC)) { - if (prop->flags & ZEND_ACC_IMPLICIT_PUBLIC) { + if (dynamic) { smart_str_appends(str, "<implicit> "); } else { smart_str_appends(str, "<default> "); @@ -861,12 +861,8 @@ static void _property_string(smart_str *str, zend_property_info *prop, const cha } /* }}} */ -static int _extension_ini_string(zval *el, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ +static void _extension_ini_string(zend_ini_entry *ini_entry, smart_str *str, char *indent, int number) /* {{{ */ { - zend_ini_entry *ini_entry = (zend_ini_entry*)Z_PTR_P(el); - smart_str *str = va_arg(args, smart_str *); - char *indent = va_arg(args, char *); - int number = va_arg(args, int); char *comma = ""; if (number == ini_entry->module_number) { @@ -894,43 +890,19 @@ static int _extension_ini_string(zval *el, int num_args, va_list args, zend_hash } smart_str_append_printf(str, " %s}\n", indent); } - return ZEND_HASH_APPLY_KEEP; } /* }}} */ -static int _extension_class_string(zval *el, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ +static void _extension_class_string(zend_class_entry *ce, zend_string *key, smart_str *str, char *indent, zend_module_entry *module, int *num_classes) /* {{{ */ { - zend_class_entry *ce = (zend_class_entry*)Z_PTR_P(el); - smart_str *str = va_arg(args, smart_str *); - char *indent = va_arg(args, char *); - struct _zend_module_entry *module = va_arg(args, struct _zend_module_entry*); - int *num_classes = va_arg(args, int*); - - if ((ce->type == ZEND_INTERNAL_CLASS) && ce->info.internal.module && !strcasecmp(ce->info.internal.module->name, module->name)) { + if (ce->type == ZEND_INTERNAL_CLASS && ce->info.internal.module && !strcasecmp(ce->info.internal.module->name, module->name)) { /* dump class if it is not an alias */ - if (!zend_binary_strcasecmp(ZSTR_VAL(ce->name), ZSTR_LEN(ce->name), ZSTR_VAL(hash_key->key), ZSTR_LEN(hash_key->key))) { + if (zend_string_equals_ci(ce->name, key)) { smart_str_append_printf(str, "\n"); _class_string(str, ce, NULL, indent); (*num_classes)++; } } - return ZEND_HASH_APPLY_KEEP; -} -/* }}} */ - -static int _extension_const_string(zval *el, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ -{ - zend_constant *constant = (zend_constant*)Z_PTR_P(el); - smart_str *str = va_arg(args, smart_str *); - char *indent = va_arg(args, char *); - struct _zend_module_entry *module = va_arg(args, struct _zend_module_entry*); - int *num_classes = va_arg(args, int*); - - if (ZEND_CONSTANT_MODULE_NUMBER(constant) == module->module_number) { - _const_string(str, ZSTR_VAL(constant->name), &constant->value, indent); - (*num_classes)++; - } - return ZEND_HASH_APPLY_KEEP; } /* }}} */ @@ -984,7 +956,10 @@ static void _extension_string(smart_str *str, zend_module_entry *module, char *i { smart_str str_ini = {0}; - zend_hash_apply_with_arguments(EG(ini_directives), (apply_func_args_t) _extension_ini_string, 3, &str_ini, indent, module->module_number); + zend_ini_entry *ini_entry; + ZEND_HASH_FOREACH_PTR(EG(ini_directives), ini_entry) { + _extension_ini_string(ini_entry, &str_ini, indent, module->module_number); + } ZEND_HASH_FOREACH_END(); if (smart_str_get_len(&str_ini) > 0) { smart_str_append_printf(str, "\n - INI {\n"); smart_str_append_smart_str(str, &str_ini); @@ -995,9 +970,16 @@ static void _extension_string(smart_str *str, zend_module_entry *module, char *i { smart_str str_constants = {0}; + zend_constant *constant; int num_constants = 0; - zend_hash_apply_with_arguments(EG(zend_constants), (apply_func_args_t) _extension_const_string, 4, &str_constants, indent, module, &num_constants); + ZEND_HASH_FOREACH_PTR(EG(zend_constants), constant) { + if (ZEND_CONSTANT_MODULE_NUMBER(constant) == module->module_number) { + _const_string(&str_constants, ZSTR_VAL(constant->name), &constant->value, indent); + num_constants++; + } + } ZEND_HASH_FOREACH_END(); + if (num_constants) { smart_str_append_printf(str, "\n - Constants [%d] {\n", num_constants); smart_str_append_smart_str(str, &str_constants); @@ -1028,9 +1010,13 @@ static void _extension_string(smart_str *str, zend_module_entry *module, char *i { zend_string *sub_indent = strpprintf(0, "%s ", indent); smart_str str_classes = {0}; + zend_string *key; + zend_class_entry *ce; int num_classes = 0; - zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t) _extension_class_string, 4, &str_classes, ZSTR_VAL(sub_indent), module, &num_classes); + ZEND_HASH_FOREACH_STR_KEY_PTR(EG(class_table), key, ce) { + _extension_class_string(ce, key, &str_classes, ZSTR_VAL(sub_indent), module, &num_classes); + } ZEND_HASH_FOREACH_END(); if (num_classes) { smart_str_append_printf(str, "\n - Classes [%d] {", num_classes); smart_str_append_smart_str(str, &str_classes); @@ -1158,7 +1144,7 @@ static void reflection_parameter_factory(zend_function *fptr, zval *closure_obje /* }}} */ /* {{{ reflection_type_factory */ -static void reflection_type_factory(zend_function *fptr, zval *closure_object, struct _zend_arg_info *arg_info, zval *object) +static void reflection_type_factory(zend_type type, zval *object) { reflection_object *intern; type_reference *reference; @@ -1166,15 +1152,9 @@ static void reflection_type_factory(zend_function *fptr, zval *closure_object, s reflection_instantiate(reflection_named_type_ptr, object); intern = Z_REFLECTION_P(object); reference = (type_reference*) emalloc(sizeof(type_reference)); - reference->arg_info = arg_info; - reference->fptr = fptr; + reference->type = type; intern->ptr = reference; intern->ref_type = REF_TYPE_TYPE; - intern->ce = fptr->common.scope; - if (closure_object) { - Z_ADDREF_P(closure_object); - ZVAL_COPY_VALUE(&intern->obj, closure_object); - } } /* }}} */ @@ -1224,7 +1204,7 @@ static void reflection_method_factory(zend_class_entry *ce, zend_function *metho /* }}} */ /* {{{ reflection_property_factory */ -static void reflection_property_factory(zend_class_entry *ce, zend_string *name, zend_property_info *prop, zval *object) +static void reflection_property_factory(zend_class_entry *ce, zend_string *name, zend_property_info *prop, zval *object, zend_bool dynamic) { reflection_object *intern; zval propname; @@ -1241,7 +1221,7 @@ static void reflection_property_factory(zend_class_entry *ce, zend_string *name, tmp_ce = tmp_ce->parent; } - if (tmp_info && !(tmp_info->flags & ZEND_ACC_SHADOW)) { /* found something and it's not a parent's private */ + if (tmp_info && (!(tmp_info->flags & ZEND_ACC_PRIVATE) || tmp_info->ce == tmp_ce)) { /* found something and it's not a parent's private */ prop = tmp_info; } else { /* not found, use initial value */ ce = store_ce; @@ -1254,9 +1234,9 @@ static void reflection_property_factory(zend_class_entry *ce, zend_string *name, reflection_instantiate(reflection_property_ptr, object); intern = Z_REFLECTION_P(object); reference = (property_reference*) emalloc(sizeof(property_reference)); - reference->ce = ce; reference->prop = *prop; reference->unmangled_name = zend_string_copy(name); + reference->dynamic = dynamic; intern->ptr = reference; intern->ref_type = REF_TYPE_PROPERTY; intern->ce = ce; @@ -1269,7 +1249,7 @@ static void reflection_property_factory(zend_class_entry *ce, zend_string *name, static void reflection_property_factory_str(zend_class_entry *ce, const char *name_str, size_t name_len, zend_property_info *prop, zval *object) { zend_string *name = zend_string_init(name_str, name_len, 0); - reflection_property_factory(ce, name, prop, object); + reflection_property_factory(ce, name, prop, object, 0); zend_string_release(name); } @@ -1493,9 +1473,6 @@ ZEND_METHOD(reflection, getModifierNames) if (modifiers & ZEND_ACC_FINAL) { add_next_index_stringl(return_value, "final", sizeof("final")-1); } - if (modifiers & ZEND_ACC_IMPLICIT_PUBLIC) { - add_next_index_stringl(return_value, "public", sizeof("public")-1); - } /* These are mutually exclusive */ switch (modifiers & ZEND_ACC_PPP_MASK) { @@ -2281,30 +2258,26 @@ ZEND_METHOD(reflection_parameter, __construct) /* First, find the function */ switch (Z_TYPE_P(reference)) { - case IS_STRING: { - size_t lcname_len; - char *lcname; - - lcname_len = Z_STRLEN_P(reference); - lcname = zend_str_tolower_dup(Z_STRVAL_P(reference), lcname_len); - if ((fptr = zend_hash_str_find_ptr(EG(function_table), lcname, lcname_len)) == NULL) { - efree(lcname); + case IS_STRING: + { + zend_string *lcname = zend_string_tolower(Z_STR_P(reference)); + fptr = zend_hash_find_ptr(EG(function_table), lcname); + zend_string_release(lcname); + if (!fptr) { zend_throw_exception_ex(reflection_exception_ptr, 0, "Function %s() does not exist", Z_STRVAL_P(reference)); return; } - efree(lcname); + ce = fptr->common.scope; } - ce = fptr->common.scope; break; case IS_ARRAY: { zval *classref; zval *method; - size_t lcname_len; - char *lcname; + zend_string *lcname; - if (((classref =zend_hash_index_find(Z_ARRVAL_P(reference), 0)) == NULL) + if (((classref = zend_hash_index_find(Z_ARRVAL_P(reference), 0)) == NULL) || ((method = zend_hash_index_find(Z_ARRVAL_P(reference), 1)) == NULL)) { _DO_THROW("Expected array($object, $method) or array($classname, $method)"); @@ -2323,22 +2296,19 @@ ZEND_METHOD(reflection_parameter, __construct) } convert_to_string_ex(method); - lcname_len = Z_STRLEN_P(method); - lcname = zend_str_tolower_dup(Z_STRVAL_P(method), lcname_len); - if (ce == zend_ce_closure && Z_TYPE_P(classref) == IS_OBJECT - && (lcname_len == sizeof(ZEND_INVOKE_FUNC_NAME)-1) - && memcmp(lcname, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0 + lcname = zend_string_tolower(Z_STR_P(method)); + if (Z_TYPE_P(classref) == IS_OBJECT && is_closure_invoke(ce, lcname) && (fptr = zend_get_closure_invoke_method(Z_OBJ_P(classref))) != NULL) { /* nothing to do. don't set is_closure since is the invoke handler, not the closure itself */ - } else if ((fptr = zend_hash_str_find_ptr(&ce->function_table, lcname, lcname_len)) == NULL) { - efree(lcname); + } else if ((fptr = zend_hash_find_ptr(&ce->function_table, lcname)) == NULL) { + zend_string_release(lcname); zend_throw_exception_ex(reflection_exception_ptr, 0, "Method %s::%s() does not exist", ZSTR_VAL(ce->name), Z_STRVAL_P(method)); return; } - efree(lcname); + zend_string_release(lcname); } break; @@ -2349,7 +2319,7 @@ ZEND_METHOD(reflection_parameter, __construct) fptr = (zend_function *)zend_get_closure_method_def(reference); Z_ADDREF_P(reference); is_closure = 1; - } else if ((fptr = zend_hash_str_find_ptr(&ce->function_table, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME))) == NULL) { + } else if ((fptr = zend_hash_find_ptr(&ce->function_table, ZSTR_KNOWN(ZEND_STR_MAGIC_INVOKE))) == NULL) { zend_throw_exception_ex(reflection_exception_ptr, 0, "Method %s::%s() does not exist", ZSTR_VAL(ce->name), ZEND_INVOKE_FUNC_NAME); return; @@ -2611,7 +2581,7 @@ ZEND_METHOD(reflection_parameter, getType) if (!ZEND_TYPE_IS_SET(param->arg_info->type)) { RETURN_NULL(); } - reflection_type_factory(_copy_function(param->fptr), Z_ISUNDEF(intern->obj)? NULL : &intern->obj, param->arg_info, return_value); + reflection_type_factory(param->arg_info->type, return_value); } /* }}} */ @@ -2869,7 +2839,7 @@ ZEND_METHOD(reflection_type, allowsNull) } GET_REFLECTION_OBJECT_PTR(param); - RETVAL_BOOL(ZEND_TYPE_ALLOW_NULL(param->arg_info->type)); + RETVAL_BOOL(ZEND_TYPE_ALLOW_NULL(param->type)); } /* }}} */ @@ -2885,16 +2855,16 @@ ZEND_METHOD(reflection_type, isBuiltin) } GET_REFLECTION_OBJECT_PTR(param); - RETVAL_BOOL(ZEND_TYPE_IS_CODE(param->arg_info->type)); + RETVAL_BOOL(ZEND_TYPE_IS_CODE(param->type)); } /* }}} */ /* {{{ reflection_type_name */ static zend_string *reflection_type_name(type_reference *param) { - if (ZEND_TYPE_IS_CLASS(param->arg_info->type)) { - return zend_string_copy(ZEND_TYPE_NAME(param->arg_info->type)); + if (ZEND_TYPE_IS_CLASS(param->type)) { + return zend_string_copy(ZEND_TYPE_NAME(param->type)); } else { - char *name = zend_get_type_by_const(ZEND_TYPE_CODE(param->arg_info->type)); + char *name = zend_get_type_by_const(ZEND_TYPE_CODE(param->type)); return zend_string_init(name, strlen(name), 0); } } @@ -3398,7 +3368,7 @@ ZEND_METHOD(reflection_function, getReturnType) RETURN_NULL(); } - reflection_type_factory(_copy_function(fptr), Z_ISUNDEF(intern->obj)? NULL : &intern->obj, &fptr->common.arg_info[-1], return_value); + reflection_type_factory(fptr->common.arg_info[-1].type, return_value); } /* }}} */ @@ -3416,7 +3386,7 @@ ZEND_METHOD(reflection_method, isConstructor) /* we need to check if the ctor is the ctor of the class level we we * looking at since we might be looking at an inherited old style ctor * defined in base class. */ - RETURN_BOOL(mptr->common.fn_flags & ZEND_ACC_CTOR && intern->ce->constructor && intern->ce->constructor->common.scope == mptr->common.scope); + RETURN_BOOL(intern->ce->constructor == mptr); } /* }}} */ @@ -3431,7 +3401,7 @@ ZEND_METHOD(reflection_method, isDestructor) return; } GET_REFLECTION_OBJECT_PTR(mptr); - RETURN_BOOL(mptr->common.fn_flags & ZEND_ACC_DTOR); + RETURN_BOOL(intern->ce->destructor == mptr); } /* }}} */ @@ -3441,7 +3411,7 @@ ZEND_METHOD(reflection_method, getModifiers) { reflection_object *intern; zend_function *mptr; - uint32_t keep_flags = ZEND_ACC_PPP_MASK | ZEND_ACC_IMPLICIT_PUBLIC + uint32_t keep_flags = ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC | ZEND_ACC_ABSTRACT | ZEND_ACC_FINAL; if (zend_parse_parameters_none() == FAILURE) { @@ -3611,7 +3581,7 @@ static void _class_constant_check_flag(INTERNAL_FUNCTION_PARAMETERS, int mask) / Returns whether this constant is public */ ZEND_METHOD(reflection_class_constant, isPublic) { - _class_constant_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_PUBLIC | ZEND_ACC_IMPLICIT_PUBLIC); + _class_constant_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_PUBLIC); } /* }}} */ @@ -3771,9 +3741,7 @@ static void add_class_vars(zend_class_entry *ce, int statics, zval *return_value zend_string *key; ZEND_HASH_FOREACH_STR_KEY_PTR(&ce->properties_info, key, prop_info) { - if (((prop_info->flags & ZEND_ACC_SHADOW) && - prop_info->ce != ce) || - ((prop_info->flags & ZEND_ACC_PROTECTED) && + if (((prop_info->flags & ZEND_ACC_PROTECTED) && !zend_check_protected(prop_info->ce, ce)) || ((prop_info->flags & ZEND_ACC_PRIVATE) && prop_info->ce != ce)) { @@ -4083,24 +4051,16 @@ ZEND_METHOD(reflection_class, hasMethod) { reflection_object *intern; zend_class_entry *ce; - char *name, *lc_name; - size_t name_len; + zend_string *name, *lc_name; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name, &name_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &name) == FAILURE) { return; } GET_REFLECTION_OBJECT_PTR(ce); - lc_name = zend_str_tolower_dup(name, name_len); - if ((ce == zend_ce_closure && (name_len == sizeof(ZEND_INVOKE_FUNC_NAME)-1) - && memcmp(lc_name, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0) - || zend_hash_str_exists(&ce->function_table, lc_name, name_len)) { - efree(lc_name); - RETURN_TRUE; - } else { - efree(lc_name); - RETURN_FALSE; - } + lc_name = zend_string_tolower(name); + RETVAL_BOOL(zend_hash_exists(&ce->function_table, lc_name) || is_closure_invoke(ce, lc_name)); + zend_string_release(lc_name); } /* }}} */ @@ -4112,40 +4072,33 @@ ZEND_METHOD(reflection_class, getMethod) zend_class_entry *ce; zend_function *mptr; zval obj_tmp; - char *name, *lc_name; - size_t name_len; + zend_string *name, *lc_name; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name, &name_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &name) == FAILURE) { return; } GET_REFLECTION_OBJECT_PTR(ce); - lc_name = zend_str_tolower_dup(name, name_len); - if (ce == zend_ce_closure && !Z_ISUNDEF(intern->obj) && (name_len == sizeof(ZEND_INVOKE_FUNC_NAME)-1) - && memcmp(lc_name, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0 + lc_name = zend_string_tolower(name); + if (!Z_ISUNDEF(intern->obj) && is_closure_invoke(ce, lc_name) && (mptr = zend_get_closure_invoke_method(Z_OBJ(intern->obj))) != NULL) { /* don't assign closure_object since we only reflect the invoke handler method and not the closure definition itself */ reflection_method_factory(ce, mptr, NULL, return_value); - efree(lc_name); - } else if (ce == zend_ce_closure && Z_ISUNDEF(intern->obj) && (name_len == sizeof(ZEND_INVOKE_FUNC_NAME)-1) - && memcmp(lc_name, ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0 + } else if (Z_ISUNDEF(intern->obj) && is_closure_invoke(ce, lc_name) && object_init_ex(&obj_tmp, ce) == SUCCESS && (mptr = zend_get_closure_invoke_method(Z_OBJ(obj_tmp))) != NULL) { /* don't assign closure_object since we only reflect the invoke handler method and not the closure definition itself */ reflection_method_factory(ce, mptr, NULL, return_value); zval_ptr_dtor(&obj_tmp); - efree(lc_name); - } else if ((mptr = zend_hash_str_find_ptr(&ce->function_table, lc_name, name_len)) != NULL) { + } else if ((mptr = zend_hash_find_ptr(&ce->function_table, lc_name)) != NULL) { reflection_method_factory(ce, mptr, NULL, return_value); - efree(lc_name); } else { - efree(lc_name); zend_throw_exception_ex(reflection_exception_ptr, 0, - "Method %s does not exist", name); - return; + "Method %s does not exist", ZSTR_VAL(name)); } + zend_string_release(lc_name); } /* }}} */ @@ -4153,11 +4106,9 @@ ZEND_METHOD(reflection_class, getMethod) static void _addmethod(zend_function *mptr, zend_class_entry *ce, zval *retval, zend_long filter, zval *obj) { zval method; - size_t len = ZSTR_LEN(mptr->common.function_name); zend_function *closure; if (mptr->common.fn_flags & filter) { - if (ce == zend_ce_closure && obj && (len == sizeof(ZEND_INVOKE_FUNC_NAME)-1) - && memcmp(ZSTR_VAL(mptr->common.function_name), ZEND_INVOKE_FUNC_NAME, sizeof(ZEND_INVOKE_FUNC_NAME)-1) == 0 + if (obj && is_closure_invoke(ce, mptr->common.function_name) && (closure = zend_get_closure_invoke_method(Z_OBJ_P(obj))) != NULL) { mptr = closure; @@ -4171,26 +4122,13 @@ static void _addmethod(zend_function *mptr, zend_class_entry *ce, zval *retval, } /* }}} */ -/* {{{ _addmethod */ -static int _addmethod_va(zval *el, int num_args, va_list args, zend_hash_key *hash_key) -{ - zend_function *mptr = (zend_function*)Z_PTR_P(el); - zend_class_entry *ce = *va_arg(args, zend_class_entry**); - zval *retval = va_arg(args, zval*); - long filter = va_arg(args, long); - zval *obj = va_arg(args, zval *); - - _addmethod(mptr, ce, retval, filter, obj); - return ZEND_HASH_APPLY_KEEP; -} -/* }}} */ - /* {{{ proto public ReflectionMethod[] ReflectionClass::getMethods([long $filter]) Returns an array of this class' methods */ ZEND_METHOD(reflection_class, getMethods) { reflection_object *intern; zend_class_entry *ce; + zend_function *mptr; zend_long filter = ZEND_ACC_PPP_MASK | ZEND_ACC_ABSTRACT | ZEND_ACC_FINAL | ZEND_ACC_STATIC; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &filter) == FAILURE) { @@ -4200,7 +4138,10 @@ ZEND_METHOD(reflection_class, getMethods) GET_REFLECTION_OBJECT_PTR(ce); array_init(return_value); - zend_hash_apply_with_arguments(&ce->function_table, (apply_func_args_t) _addmethod_va, 4, &ce, return_value, filter, intern->obj); + ZEND_HASH_FOREACH_PTR(&ce->function_table, mptr) { + _addmethod(mptr, ce, return_value, filter, &intern->obj); + } ZEND_HASH_FOREACH_END(); + if (Z_TYPE(intern->obj) != IS_UNDEF && instanceof_function(ce, zend_ce_closure)) { zend_function *closure = zend_get_closure_invoke_method(Z_OBJ(intern->obj)); if (closure) { @@ -4227,7 +4168,7 @@ ZEND_METHOD(reflection_class, hasProperty) GET_REFLECTION_OBJECT_PTR(ce); if ((property_info = zend_hash_find_ptr(&ce->properties_info, name)) != NULL) { - if (property_info->flags & ZEND_ACC_SHADOW) { + if ((property_info->flags & ZEND_ACC_PRIVATE) && property_info->ce != ce) { RETURN_FALSE; } RETURN_TRUE; @@ -4262,20 +4203,20 @@ ZEND_METHOD(reflection_class, getProperty) GET_REFLECTION_OBJECT_PTR(ce); if ((property_info = zend_hash_find_ptr(&ce->properties_info, name)) != NULL) { - if ((property_info->flags & ZEND_ACC_SHADOW) == 0) { - reflection_property_factory(ce, name, property_info, return_value); + if (!(property_info->flags & ZEND_ACC_PRIVATE) || property_info->ce == ce) { + reflection_property_factory(ce, name, property_info, return_value, 0); return; } } else if (Z_TYPE(intern->obj) != IS_UNDEF) { /* Check for dynamic properties */ if (zend_hash_exists(Z_OBJ_HT(intern->obj)->get_properties(&intern->obj), name)) { zend_property_info property_info_tmp; - property_info_tmp.flags = ZEND_ACC_IMPLICIT_PUBLIC; + property_info_tmp.flags = ZEND_ACC_PUBLIC; property_info_tmp.name = name; property_info_tmp.doc_comment = NULL; property_info_tmp.ce = ce; - reflection_property_factory(ce, name, &property_info_tmp, return_value); + reflection_property_factory(ce, name, &property_info_tmp, return_value, 1); return; } } @@ -4304,7 +4245,10 @@ ZEND_METHOD(reflection_class, getProperty) } ce = ce2; - if ((property_info = zend_hash_str_find_ptr(&ce->properties_info, str_name, str_name_len)) != NULL && (property_info->flags & ZEND_ACC_SHADOW) == 0) { + property_info = zend_hash_str_find_ptr(&ce->properties_info, str_name, str_name_len); + if (property_info != NULL + && (!(property_info->flags & ZEND_ACC_PRIVATE) + || property_info->ce == ce)) { reflection_property_factory_str(ce, str_name, str_name_len, property_info, return_value); return; } @@ -4315,59 +4259,45 @@ ZEND_METHOD(reflection_class, getProperty) /* }}} */ /* {{{ _addproperty */ -static int _addproperty(zval *el, int num_args, va_list args, zend_hash_key *hash_key) +static void _addproperty(zend_property_info *pptr, zend_string *key, zend_class_entry *ce, zval *retval, long filter) { - zval property; - zend_property_info *pptr = (zend_property_info*)Z_PTR_P(el); - zend_class_entry *ce = *va_arg(args, zend_class_entry**); - zval *retval = va_arg(args, zval*); - long filter = va_arg(args, long); - - if (pptr->flags & ZEND_ACC_SHADOW) { - return 0; + if ((pptr->flags & ZEND_ACC_PRIVATE) && pptr->ce != ce) { + return; } if (pptr->flags & filter) { - const char *class_name, *prop_name; - size_t prop_name_len; - zend_unmangle_property_name_ex(pptr->name, &class_name, &prop_name, &prop_name_len); - reflection_property_factory_str(ce, prop_name, prop_name_len, pptr, &property); + zval property; + reflection_property_factory(ce, key, pptr, &property, 0); add_next_index_zval(retval, &property); } - return 0; } /* }}} */ /* {{{ _adddynproperty */ -static int _adddynproperty(zval *ptr, int num_args, va_list args, zend_hash_key *hash_key) +static void _adddynproperty(zval *ptr, zend_string *key, zend_class_entry *ce, zval *retval) { + zend_property_info property_info; zval property; - zend_class_entry *ce = *va_arg(args, zend_class_entry**); - zval *retval = va_arg(args, zval*); /* under some circumstances, the properties hash table may contain numeric - * properties (e.g. when casting from array). This is a WONT FIX bug, at + * properties (e.g. when casting from array). This is a WON'T FIX bug, at * least for the moment. Ignore these */ - if (hash_key->key == NULL) { - return 0; + if (key == NULL) { + return; } - if (ZSTR_VAL(hash_key->key)[0] == '\0') { - return 0; /* non public cannot be dynamic */ + /* Not a dynamic property */ + if (Z_TYPE_P(ptr) == IS_INDIRECT) { + return; } - if (zend_get_property_info(ce, hash_key->key, 1) == NULL) { - zend_property_info property_info; - - property_info.doc_comment = NULL; - property_info.flags = ZEND_ACC_IMPLICIT_PUBLIC; - property_info.name = hash_key->key; - property_info.ce = ce; - property_info.offset = -1; - reflection_property_factory(ce, hash_key->key, &property_info, &property); - add_next_index_zval(retval, &property); - } - return 0; + property_info.doc_comment = NULL; + property_info.flags = ZEND_ACC_PUBLIC; + property_info.name = key; + property_info.ce = ce; + property_info.offset = -1; + reflection_property_factory(ce, key, &property_info, &property, 1); + add_next_index_zval(retval, &property); } /* }}} */ @@ -4377,6 +4307,8 @@ ZEND_METHOD(reflection_class, getProperties) { reflection_object *intern; zend_class_entry *ce; + zend_string *key; + zend_property_info *prop_info; zend_long filter = ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &filter) == FAILURE) { @@ -4386,11 +4318,16 @@ ZEND_METHOD(reflection_class, getProperties) GET_REFLECTION_OBJECT_PTR(ce); array_init(return_value); - zend_hash_apply_with_arguments(&ce->properties_info, (apply_func_args_t) _addproperty, 3, &ce, return_value, filter); + ZEND_HASH_FOREACH_STR_KEY_PTR(&ce->properties_info, key, prop_info) { + _addproperty(prop_info, key, ce, return_value, filter); + } ZEND_HASH_FOREACH_END(); - if (Z_TYPE(intern->obj) != IS_UNDEF && (filter & ZEND_ACC_PUBLIC) != 0 && Z_OBJ_HT(intern->obj)->get_properties) { + if (Z_TYPE(intern->obj) != IS_UNDEF && (filter & ZEND_ACC_PUBLIC) != 0) { HashTable *properties = Z_OBJ_HT(intern->obj)->get_properties(&intern->obj); - zend_hash_apply_with_arguments(properties, (apply_func_args_t) _adddynproperty, 2, &ce, return_value); + zval *prop; + ZEND_HASH_FOREACH_STR_KEY_VAL(properties, key, prop) { + _adddynproperty(prop, key, ce, return_value); + } ZEND_HASH_FOREACH_END(); } } /* }}} */ @@ -4837,6 +4774,7 @@ ZEND_METHOD(reflection_class, getInterfaces) if (ce->num_interfaces) { uint32_t i; + ZEND_ASSERT(ce->ce_flags & ZEND_ACC_LINKED); array_init(return_value); for (i=0; i < ce->num_interfaces; i++) { zval interface; @@ -4868,6 +4806,7 @@ ZEND_METHOD(reflection_class, getInterfaceNames) return; } + ZEND_ASSERT(ce->ce_flags & ZEND_ACC_LINKED); array_init(return_value); for (i=0; i < ce->num_interfaces; i++) { @@ -4898,8 +4837,13 @@ ZEND_METHOD(reflection_class, getTraits) for (i=0; i < ce->num_traits; i++) { zval trait; - zend_reflection_class_factory(ce->traits[i], &trait); - zend_hash_update(Z_ARRVAL_P(return_value), ce->traits[i]->name, &trait); + zend_class_entry *trait_ce; + + trait_ce = zend_fetch_class_by_name(ce->trait_names[i].name, + ce->trait_names[i].lc_name, ZEND_FETCH_CLASS_TRAIT); + ZEND_ASSERT(trait_ce); + zend_reflection_class_factory(trait_ce, &trait); + zend_hash_update(Z_ARRVAL_P(return_value), ce->trait_names[i].name, &trait); } } /* }}} */ @@ -4925,7 +4869,7 @@ ZEND_METHOD(reflection_class, getTraitNames) array_init(return_value); for (i=0; i < ce->num_traits; i++) { - add_next_index_str(return_value, zend_string_copy(ce->traits[i]->name)); + add_next_index_str(return_value, zend_string_copy(ce->trait_names[i].name)); } } /* }}} */ @@ -5278,9 +5222,12 @@ ZEND_METHOD(reflection_property, __construct) /* returns out of this function */ } - if ((property_info = zend_hash_find_ptr(&ce->properties_info, name)) == NULL || (property_info->flags & ZEND_ACC_SHADOW)) { + property_info = zend_hash_find_ptr(&ce->properties_info, name); + if (property_info == NULL + || ((property_info->flags & ZEND_ACC_PRIVATE) + && property_info->ce != ce)) { /* Check for dynamic properties */ - if (property_info == NULL && Z_TYPE_P(classname) == IS_OBJECT && Z_OBJ_HT_P(classname)->get_properties) { + if (property_info == NULL && Z_TYPE_P(classname) == IS_OBJECT) { if (zend_hash_exists(Z_OBJ_HT_P(classname)->get_properties(classname), name)) { dynam_prop = 1; } @@ -5315,14 +5262,15 @@ ZEND_METHOD(reflection_property, __construct) reference = (property_reference*) emalloc(sizeof(property_reference)); if (dynam_prop) { - reference->prop.flags = ZEND_ACC_IMPLICIT_PUBLIC; + reference->prop.flags = ZEND_ACC_PUBLIC; reference->prop.name = name; reference->prop.doc_comment = NULL; reference->prop.ce = ce; + reference->dynamic = 1; } else { reference->prop = *property_info; + reference->dynamic = 0; } - reference->ce = ce; reference->unmangled_name = zend_string_copy(name); intern->ptr = reference; intern->ref_type = REF_TYPE_PROPERTY; @@ -5343,7 +5291,7 @@ ZEND_METHOD(reflection_property, __toString) return; } GET_REFLECTION_OBJECT_PTR(ref); - _property_string(&str, &ref->prop, ZSTR_VAL(ref->unmangled_name), ""); + _property_string(&str, &ref->prop, ZSTR_VAL(ref->unmangled_name), "", ref->dynamic); RETURN_STR(smart_str_extract(&str)); } /* }}} */ @@ -5376,7 +5324,7 @@ static void _property_check_flag(INTERNAL_FUNCTION_PARAMETERS, int mask) /* {{{ Returns whether this property is public */ ZEND_METHOD(reflection_property, isPublic) { - _property_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_PUBLIC | ZEND_ACC_IMPLICIT_PUBLIC); + _property_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_PUBLIC); } /* }}} */ @@ -5408,7 +5356,14 @@ ZEND_METHOD(reflection_property, isStatic) Returns whether this property is default (declared at compilation time). */ ZEND_METHOD(reflection_property, isDefault) { - _property_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ~ZEND_ACC_IMPLICIT_PUBLIC); + reflection_object *intern; + property_reference *ref; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(ref); + RETURN_BOOL(!ref->dynamic); } /* }}} */ @@ -5418,7 +5373,7 @@ ZEND_METHOD(reflection_property, getModifiers) { reflection_object *intern; property_reference *ref; - uint32_t keep_flags = ZEND_ACC_PPP_MASK | ZEND_ACC_IMPLICIT_PUBLIC | ZEND_ACC_STATIC; + uint32_t keep_flags = ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC; if (zend_parse_parameters_none() == FAILURE) { return; @@ -5440,7 +5395,7 @@ ZEND_METHOD(reflection_property, getValue) GET_REFLECTION_OBJECT_PTR(ref); - if (!(ref->prop.flags & (ZEND_ACC_PUBLIC | ZEND_ACC_IMPLICIT_PUBLIC)) && intern->ignore_visibility == 0) { + if (!(ref->prop.flags & ZEND_ACC_PUBLIC) && intern->ignore_visibility == 0) { name = _default_load_name(getThis()); zend_throw_exception_ex(reflection_exception_ptr, 0, "Cannot access non-public member %s::$%s", ZSTR_VAL(intern->ce->name), Z_STRVAL_P(name)); @@ -5448,7 +5403,7 @@ ZEND_METHOD(reflection_property, getValue) } if (ref->prop.flags & ZEND_ACC_STATIC) { - member_p = zend_read_static_property_ex(ref->ce, ref->unmangled_name, 0); + member_p = zend_read_static_property_ex(intern->ce, ref->unmangled_name, 0); if (member_p) { ZVAL_COPY_DEREF(return_value, member_p); } @@ -5464,7 +5419,7 @@ ZEND_METHOD(reflection_property, getValue) /* Returns from this function */ } - member_p = zend_read_property_ex(ref->ce, object, ref->unmangled_name, 0, &rv); + member_p = zend_read_property_ex(intern->ce, object, ref->unmangled_name, 0, &rv); if (member_p != &rv) { ZVAL_COPY_DEREF(return_value, member_p); } else { @@ -5503,13 +5458,13 @@ ZEND_METHOD(reflection_property, setValue) } } - zend_update_static_property_ex(ref->ce, ref->unmangled_name, value); + zend_update_static_property_ex(intern->ce, ref->unmangled_name, value); } else { if (zend_parse_parameters(ZEND_NUM_ARGS(), "oz", &object, &value) == FAILURE) { return; } - zend_update_property_ex(ref->ce, object, ref->unmangled_name, value); + zend_update_property_ex(intern->ce, object, ref->unmangled_name, value); } } /* }}} */ @@ -5528,9 +5483,9 @@ ZEND_METHOD(reflection_property, getDeclaringClass) } GET_REFLECTION_OBJECT_PTR(ref); - ce = tmp_ce = ref->ce; + ce = tmp_ce = intern->ce; while (tmp_ce && (tmp_info = zend_hash_find_ptr(&tmp_ce->properties_info, ref->unmangled_name)) != NULL) { - if (tmp_info->flags & ZEND_ACC_PRIVATE || tmp_info->flags & ZEND_ACC_SHADOW) { + if (tmp_info->flags & ZEND_ACC_PRIVATE) { /* it's a private property, so it can't be inherited */ break; } @@ -5699,27 +5654,13 @@ ZEND_METHOD(reflection_extension, getFunctions) } /* }}} */ -static int _addconstant(zval *el, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ -{ - zval const_val; - zend_constant *constant = (zend_constant*)Z_PTR_P(el); - zval *retval = va_arg(args, zval*); - int number = va_arg(args, int); - - if (number == ZEND_CONSTANT_MODULE_NUMBER(constant)) { - ZVAL_COPY_OR_DUP(&const_val, &constant->value); - zend_hash_update(Z_ARRVAL_P(retval), constant->name, &const_val); - } - return 0; -} -/* }}} */ - /* {{{ proto public array ReflectionExtension::getConstants() Returns an associative array containing this extension's constants and their values */ ZEND_METHOD(reflection_extension, getConstants) { reflection_object *intern; zend_module_entry *module; + zend_constant *constant; if (zend_parse_parameters_none() == FAILURE) { return; @@ -5727,28 +5668,28 @@ ZEND_METHOD(reflection_extension, getConstants) GET_REFLECTION_OBJECT_PTR(module); array_init(return_value); - zend_hash_apply_with_arguments(EG(zend_constants), (apply_func_args_t) _addconstant, 2, return_value, module->module_number); + ZEND_HASH_FOREACH_PTR(EG(zend_constants), constant) { + if (module->module_number == ZEND_CONSTANT_MODULE_NUMBER(constant)) { + zval const_val; + ZVAL_COPY_OR_DUP(&const_val, &constant->value); + zend_hash_update(Z_ARRVAL_P(return_value), constant->name, &const_val); + } + } ZEND_HASH_FOREACH_END(); } /* }}} */ /* {{{ _addinientry */ -static int _addinientry(zval *el, int num_args, va_list args, zend_hash_key *hash_key) +static void _addinientry(zend_ini_entry *ini_entry, zval *retval, int number) { - zend_ini_entry *ini_entry = (zend_ini_entry*)Z_PTR_P(el); - zval *retval = va_arg(args, zval*); - int number = va_arg(args, int); - if (number == ini_entry->module_number) { + zval zv; if (ini_entry->value) { - zval zv; - ZVAL_STR_COPY(&zv, ini_entry->value); - zend_symtable_update(Z_ARRVAL_P(retval), ini_entry->name, &zv); } else { - zend_symtable_update(Z_ARRVAL_P(retval), ini_entry->name, &EG(uninitialized_zval)); + ZVAL_NULL(&zv); } + zend_symtable_update(Z_ARRVAL_P(retval), ini_entry->name, &zv); } - return ZEND_HASH_APPLY_KEEP; } /* }}} */ @@ -5758,6 +5699,7 @@ ZEND_METHOD(reflection_extension, getINIEntries) { reflection_object *intern; zend_module_entry *module; + zend_ini_entry *ini_entry; if (zend_parse_parameters_none() == FAILURE) { return; @@ -5765,36 +5707,33 @@ ZEND_METHOD(reflection_extension, getINIEntries) GET_REFLECTION_OBJECT_PTR(module); array_init(return_value); - zend_hash_apply_with_arguments(EG(ini_directives), (apply_func_args_t) _addinientry, 2, return_value, module->module_number); + ZEND_HASH_FOREACH_PTR(EG(ini_directives), ini_entry) { + _addinientry(ini_entry, return_value, module->module_number); + } ZEND_HASH_FOREACH_END(); } /* }}} */ /* {{{ add_extension_class */ -static int add_extension_class(zval *zv, int num_args, va_list args, zend_hash_key *hash_key) +static void add_extension_class(zend_class_entry *ce, zend_string *key, zval *class_array, zend_module_entry *module, zend_bool add_reflection_class) { - zend_class_entry *ce = Z_PTR_P(zv); - zval *class_array = va_arg(args, zval*), zclass; - struct _zend_module_entry *module = va_arg(args, struct _zend_module_entry*); - int add_reflection_class = va_arg(args, int); - - if ((ce->type == ZEND_INTERNAL_CLASS) && ce->info.internal.module && !strcasecmp(ce->info.internal.module->name, module->name)) { + if (ce->type == ZEND_INTERNAL_CLASS && ce->info.internal.module && !strcasecmp(ce->info.internal.module->name, module->name)) { zend_string *name; - if (zend_binary_strcasecmp(ZSTR_VAL(ce->name), ZSTR_LEN(ce->name), ZSTR_VAL(hash_key->key), ZSTR_LEN(hash_key->key))) { - /* This is an class alias, use alias name */ - name = hash_key->key; + if (!zend_string_equals_ci(ce->name, key)) { + /* This is a class alias, use alias name */ + name = key; } else { /* Use class name */ name = ce->name; } if (add_reflection_class) { + zval zclass; zend_reflection_class_factory(ce, &zclass); zend_hash_update(Z_ARRVAL_P(class_array), name, &zclass); } else { add_next_index_str(class_array, zend_string_copy(name)); } } - return ZEND_HASH_APPLY_KEEP; } /* }}} */ @@ -5804,6 +5743,8 @@ ZEND_METHOD(reflection_extension, getClasses) { reflection_object *intern; zend_module_entry *module; + zend_string *key; + zend_class_entry *ce; if (zend_parse_parameters_none() == FAILURE) { return; @@ -5811,7 +5752,9 @@ ZEND_METHOD(reflection_extension, getClasses) GET_REFLECTION_OBJECT_PTR(module); array_init(return_value); - zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t) add_extension_class, 3, return_value, module, 1); + ZEND_HASH_FOREACH_STR_KEY_PTR(EG(class_table), key, ce) { + add_extension_class(ce, key, return_value, module, 1); + } ZEND_HASH_FOREACH_END(); } /* }}} */ @@ -5821,6 +5764,8 @@ ZEND_METHOD(reflection_extension, getClassNames) { reflection_object *intern; zend_module_entry *module; + zend_string *key; + zend_class_entry *ce; if (zend_parse_parameters_none() == FAILURE) { return; @@ -5828,7 +5773,9 @@ ZEND_METHOD(reflection_extension, getClassNames) GET_REFLECTION_OBJECT_PTR(module); array_init(return_value); - zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t) add_extension_class, 3, return_value, module, 0); + ZEND_HASH_FOREACH_STR_KEY_PTR(EG(class_table), key, ce) { + add_extension_class(ce, key, return_value, module, 0); + } ZEND_HASH_FOREACH_END(); } /* }}} */ @@ -6600,6 +6547,12 @@ static void _reflection_write_property(zval *object, zval *member, zval *value, } /* }}} */ +static void reflection_init_class_handlers(zend_class_entry *ce) { + ce->create_object = reflection_objects_new; + ce->serialize = zend_class_serialize_deny; + ce->unserialize = zend_class_unserialize_deny; +} + PHP_MINIT_FUNCTION(reflection) /* {{{ */ { zend_class_entry _reflection_entry; @@ -6621,38 +6574,38 @@ PHP_MINIT_FUNCTION(reflection) /* {{{ */ reflector_ptr = zend_register_internal_interface(&_reflection_entry); INIT_CLASS_ENTRY(_reflection_entry, "ReflectionFunctionAbstract", reflection_function_abstract_functions); - _reflection_entry.create_object = reflection_objects_new; + reflection_init_class_handlers(&_reflection_entry); reflection_function_abstract_ptr = zend_register_internal_class(&_reflection_entry); zend_class_implements(reflection_function_abstract_ptr, 1, reflector_ptr); zend_declare_property_string(reflection_function_abstract_ptr, "name", sizeof("name")-1, "", ZEND_ACC_ABSTRACT); INIT_CLASS_ENTRY(_reflection_entry, "ReflectionFunction", reflection_function_functions); - _reflection_entry.create_object = reflection_objects_new; + reflection_init_class_handlers(&_reflection_entry); reflection_function_ptr = zend_register_internal_class_ex(&_reflection_entry, reflection_function_abstract_ptr); zend_declare_property_string(reflection_function_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC); REGISTER_REFLECTION_CLASS_CONST_LONG(function, "IS_DEPRECATED", ZEND_ACC_DEPRECATED); INIT_CLASS_ENTRY(_reflection_entry, "ReflectionGenerator", reflection_generator_functions); - _reflection_entry.create_object = reflection_objects_new; + reflection_init_class_handlers(&_reflection_entry); reflection_generator_ptr = zend_register_internal_class(&_reflection_entry); INIT_CLASS_ENTRY(_reflection_entry, "ReflectionParameter", reflection_parameter_functions); - _reflection_entry.create_object = reflection_objects_new; + reflection_init_class_handlers(&_reflection_entry); reflection_parameter_ptr = zend_register_internal_class(&_reflection_entry); zend_class_implements(reflection_parameter_ptr, 1, reflector_ptr); zend_declare_property_string(reflection_parameter_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC); INIT_CLASS_ENTRY(_reflection_entry, "ReflectionType", reflection_type_functions); - _reflection_entry.create_object = reflection_objects_new; + reflection_init_class_handlers(&_reflection_entry); reflection_type_ptr = zend_register_internal_class(&_reflection_entry); INIT_CLASS_ENTRY(_reflection_entry, "ReflectionNamedType", reflection_named_type_functions); - _reflection_entry.create_object = reflection_objects_new; + reflection_init_class_handlers(&_reflection_entry); reflection_named_type_ptr = zend_register_internal_class_ex(&_reflection_entry, reflection_type_ptr); INIT_CLASS_ENTRY(_reflection_entry, "ReflectionMethod", reflection_method_functions); - _reflection_entry.create_object = reflection_objects_new; + reflection_init_class_handlers(&_reflection_entry); reflection_method_ptr = zend_register_internal_class_ex(&_reflection_entry, reflection_function_abstract_ptr); zend_declare_property_string(reflection_method_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC); zend_declare_property_string(reflection_method_ptr, "class", sizeof("class")-1, "", ZEND_ACC_PUBLIC); @@ -6665,7 +6618,7 @@ PHP_MINIT_FUNCTION(reflection) /* {{{ */ REGISTER_REFLECTION_CLASS_CONST_LONG(method, "IS_FINAL", ZEND_ACC_FINAL); INIT_CLASS_ENTRY(_reflection_entry, "ReflectionClass", reflection_class_functions); - _reflection_entry.create_object = reflection_objects_new; + reflection_init_class_handlers(&_reflection_entry); reflection_class_ptr = zend_register_internal_class(&_reflection_entry); zend_class_implements(reflection_class_ptr, 1, reflector_ptr); zend_declare_property_string(reflection_class_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC); @@ -6675,18 +6628,18 @@ PHP_MINIT_FUNCTION(reflection) /* {{{ */ REGISTER_REFLECTION_CLASS_CONST_LONG(class, "IS_FINAL", ZEND_ACC_FINAL); INIT_CLASS_ENTRY(_reflection_entry, "ReflectionObject", reflection_object_functions); - _reflection_entry.create_object = reflection_objects_new; + reflection_init_class_handlers(&_reflection_entry); reflection_object_ptr = zend_register_internal_class_ex(&_reflection_entry, reflection_class_ptr); INIT_CLASS_ENTRY(_reflection_entry, "ReflectionProperty", reflection_property_functions); - _reflection_entry.create_object = reflection_objects_new; + reflection_init_class_handlers(&_reflection_entry); reflection_property_ptr = zend_register_internal_class(&_reflection_entry); zend_class_implements(reflection_property_ptr, 1, reflector_ptr); zend_declare_property_string(reflection_property_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC); zend_declare_property_string(reflection_property_ptr, "class", sizeof("class")-1, "", ZEND_ACC_PUBLIC); INIT_CLASS_ENTRY(_reflection_entry, "ReflectionClassConstant", reflection_class_constant_functions); - _reflection_entry.create_object = reflection_objects_new; + reflection_init_class_handlers(&_reflection_entry); reflection_class_constant_ptr = zend_register_internal_class(&_reflection_entry); zend_class_implements(reflection_class_constant_ptr, 1, reflector_ptr); zend_declare_property_string(reflection_class_constant_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC); @@ -6698,13 +6651,13 @@ PHP_MINIT_FUNCTION(reflection) /* {{{ */ REGISTER_REFLECTION_CLASS_CONST_LONG(property, "IS_PRIVATE", ZEND_ACC_PRIVATE); INIT_CLASS_ENTRY(_reflection_entry, "ReflectionExtension", reflection_extension_functions); - _reflection_entry.create_object = reflection_objects_new; + reflection_init_class_handlers(&_reflection_entry); reflection_extension_ptr = zend_register_internal_class(&_reflection_entry); zend_class_implements(reflection_extension_ptr, 1, reflector_ptr); zend_declare_property_string(reflection_extension_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC); INIT_CLASS_ENTRY(_reflection_entry, "ReflectionZendExtension", reflection_zend_extension_functions); - _reflection_entry.create_object = reflection_objects_new; + reflection_init_class_handlers(&_reflection_entry); reflection_zend_extension_ptr = zend_register_internal_class(&_reflection_entry); zend_class_implements(reflection_zend_extension_ptr, 1, reflector_ptr); zend_declare_property_string(reflection_zend_extension_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC); diff --git a/ext/reflection/tests/ReflectionClassConstant_basic1.phpt b/ext/reflection/tests/ReflectionClassConstant_basic1.phpt index 548d64e1bf..78510d0b35 100644 --- a/ext/reflection/tests/ReflectionClassConstant_basic1.phpt +++ b/ext/reflection/tests/ReflectionClassConstant_basic1.phpt @@ -73,7 +73,7 @@ bool(false) isProtected(): bool(false) getModifiers(): -int(256) +int(1) getDeclaringClass(): object(ReflectionClass)#3 (1) { ["name"]=> @@ -107,7 +107,7 @@ bool(false) isProtected(): bool(true) getModifiers(): -int(512) +int(2) getDeclaringClass(): object(ReflectionClass)#3 (1) { ["name"]=> @@ -141,7 +141,7 @@ bool(true) isProtected(): bool(false) getModifiers(): -int(1024) +int(4) getDeclaringClass(): object(ReflectionClass)#3 (1) { ["name"]=> @@ -175,7 +175,7 @@ bool(true) isProtected(): bool(false) getModifiers(): -int(1024) +int(4) getDeclaringClass(): object(ReflectionClass)#3 (1) { ["name"]=> diff --git a/ext/reflection/tests/ReflectionClass_FileInfo_basic.phpt b/ext/reflection/tests/ReflectionClass_FileInfo_basic.phpt index 28769da707..05565efae3 100644 --- a/ext/reflection/tests/ReflectionClass_FileInfo_basic.phpt +++ b/ext/reflection/tests/ReflectionClass_FileInfo_basic.phpt @@ -14,7 +14,7 @@ var_dump($rc->getStartLine()); //Get the line number at the end of the definition of class C var_dump($rc->getEndLine()); -//Same tests as above but stdclass is internal - so all results should be false. +//Same tests as above but stdclass is internal - so all results should be false. $rc = new ReflectionClass("stdClass"); var_dump($rc->getFileName()); var_dump($rc->getStartLine()); diff --git a/ext/reflection/tests/ReflectionClass_getDocComment_001.phpt b/ext/reflection/tests/ReflectionClass_getDocComment_001.phpt index 31e0e8e58b..8edc6a93a6 100644 --- a/ext/reflection/tests/ReflectionClass_getDocComment_001.phpt +++ b/ext/reflection/tests/ReflectionClass_getDocComment_001.phpt @@ -11,8 +11,8 @@ opcache.save_comments=1 My -Doc - * Comment +Doc + * Comment for A * */ @@ -63,8 +63,8 @@ string(%d) "/** My -Doc - * Comment +Doc + * Comment for A * */" diff --git a/ext/reflection/tests/ReflectionClass_getInterfaces_002.phpt b/ext/reflection/tests/ReflectionClass_getInterfaces_002.phpt index 8fa08869da..998bd4bea6 100644 --- a/ext/reflection/tests/ReflectionClass_getInterfaces_002.phpt +++ b/ext/reflection/tests/ReflectionClass_getInterfaces_002.phpt @@ -25,24 +25,24 @@ Array [name] => I6 ) - [I2] => ReflectionClass Object + [I4] => ReflectionClass Object ( - [name] => I2 + [name] => I4 ) - [I1] => ReflectionClass Object + [I3] => ReflectionClass Object ( - [name] => I1 + [name] => I3 ) - [I4] => ReflectionClass Object + [I2] => ReflectionClass Object ( - [name] => I4 + [name] => I2 ) - [I3] => ReflectionClass Object + [I1] => ReflectionClass Object ( - [name] => I3 + [name] => I1 ) [I5] => ReflectionClass Object @@ -50,4 +50,4 @@ Array [name] => I5 ) -)
\ No newline at end of file +) diff --git a/ext/reflection/tests/ReflectionClass_getMethods_003.phpt b/ext/reflection/tests/ReflectionClass_getMethods_003.phpt index 885bd908f1..b08fcaa4d4 100644 --- a/ext/reflection/tests/ReflectionClass_getMethods_003.phpt +++ b/ext/reflection/tests/ReflectionClass_getMethods_003.phpt @@ -17,9 +17,9 @@ class C { } $rc = new ReflectionClass("C"); -$StaticFlag = 0x01; -$pubFlag = 0x100; -$privFlag = 0x400; +$StaticFlag = ReflectionMethod::IS_STATIC; +$pubFlag = ReflectionMethod::IS_PUBLIC; +$privFlag = ReflectionMethod::IS_PRIVATE; echo "No methods:"; var_dump($rc->getMethods(0)); diff --git a/ext/reflection/tests/ReflectionClass_getModifiers_basic.phpt b/ext/reflection/tests/ReflectionClass_getModifiers_basic.phpt index f77bbacda7..ffe8876133 100644 --- a/ext/reflection/tests/ReflectionClass_getModifiers_basic.phpt +++ b/ext/reflection/tests/ReflectionClass_getModifiers_basic.phpt @@ -29,8 +29,8 @@ dump_modifiers('g'); ?> --EXPECT-- int(0) +int(64) int(32) -int(4) int(0) int(0) int(0) diff --git a/ext/reflection/tests/ReflectionClass_getProperties_003.phpt b/ext/reflection/tests/ReflectionClass_getProperties_003.phpt index ac16a68349..229e828056 100644 --- a/ext/reflection/tests/ReflectionClass_getProperties_003.phpt +++ b/ext/reflection/tests/ReflectionClass_getProperties_003.phpt @@ -17,9 +17,9 @@ class C { } $rc = new ReflectionClass("C"); -$StaticFlag = 0x01; -$pubFlag = 0x100; -$privFlag = 0x400; +$StaticFlag = ReflectionProperty::IS_STATIC; +$pubFlag = ReflectionProperty::IS_PUBLIC; +$privFlag = ReflectionProperty::IS_PRIVATE; echo "No properties:"; var_dump($rc->getProperties(0)); diff --git a/ext/reflection/tests/ReflectionClass_hasMethod_001.phpt b/ext/reflection/tests/ReflectionClass_hasMethod_001.phpt index b9eb013522..79009d3bdb 100644 --- a/ext/reflection/tests/ReflectionClass_hasMethod_001.phpt +++ b/ext/reflection/tests/ReflectionClass_hasMethod_001.phpt @@ -7,14 +7,14 @@ Steve Seear <stevseea@php.net> <?php class pubf { public function f() {} - static public function s() {} + static public function s() {} } class subpubf extends pubf { } class protf { protected function f() {} - static protected function s() {} + static protected function s() {} } class subprotf extends protf { } @@ -26,7 +26,7 @@ class privf { class subprivf extends privf { } -$classes = array("pubf", "subpubf", "protf", "subprotf", +$classes = array("pubf", "subpubf", "protf", "subprotf", "privf", "subprivf"); foreach($classes as $class) { echo "Reflecting on class $class: \n"; diff --git a/ext/reflection/tests/ReflectionClass_isInternal_basic.phpt b/ext/reflection/tests/ReflectionClass_isInternal_basic.phpt index 9c656a38b6..7d7e61335d 100644 --- a/ext/reflection/tests/ReflectionClass_isInternal_basic.phpt +++ b/ext/reflection/tests/ReflectionClass_isInternal_basic.phpt @@ -11,7 +11,7 @@ $r3 = new ReflectionClass("ReflectionProperty"); $r4 = new ReflectionClass("Exception"); $r5 = new ReflectionClass("C"); -var_dump($r1->isInternal(), $r2->isInternal(), $r3->isInternal(), +var_dump($r1->isInternal(), $r2->isInternal(), $r3->isInternal(), $r4->isInternal(), $r5->isInternal()); ?> --EXPECT-- diff --git a/ext/reflection/tests/ReflectionClass_isUserDefined_basic.phpt b/ext/reflection/tests/ReflectionClass_isUserDefined_basic.phpt index e9537c1e8a..5babb546ae 100644 --- a/ext/reflection/tests/ReflectionClass_isUserDefined_basic.phpt +++ b/ext/reflection/tests/ReflectionClass_isUserDefined_basic.phpt @@ -11,7 +11,7 @@ $r3 = new ReflectionClass("ReflectionProperty"); $r4 = new ReflectionClass("Exception"); $r5 = new ReflectionClass("C"); -var_dump($r1->isUserDefined(), $r2->isUserDefined(), $r3->isUserDefined(), +var_dump($r1->isUserDefined(), $r2->isUserDefined(), $r3->isUserDefined(), $r4->isUserDefined(), $r5->isUserDefined()); ?> --EXPECT-- diff --git a/ext/reflection/tests/ReflectionClass_modifiers_001.phpt b/ext/reflection/tests/ReflectionClass_modifiers_001.phpt index d82519e4f4..1370228f04 100644 --- a/ext/reflection/tests/ReflectionClass_modifiers_001.phpt +++ b/ext/reflection/tests/ReflectionClass_modifiers_001.phpt @@ -25,7 +25,7 @@ foreach ($classes as $class) { bool(false) bool(false) bool(true) -int(32) +int(64) bool(false) bool(false) bool(false) @@ -37,7 +37,7 @@ int(0) bool(true) bool(false) bool(false) -int(4) +int(32) bool(false) bool(true) bool(false) diff --git a/ext/reflection/tests/ReflectionClass_toString_001.phpt b/ext/reflection/tests/ReflectionClass_toString_001.phpt index cafdd2e37c..e97af14110 100644 --- a/ext/reflection/tests/ReflectionClass_toString_001.phpt +++ b/ext/reflection/tests/ReflectionClass_toString_001.phpt @@ -13,8 +13,8 @@ Class [ <internal:Reflection> class ReflectionClass implements Reflector ] { - Constants [3] { Constant [ public int IS_IMPLICIT_ABSTRACT ] { 16 } - Constant [ public int IS_EXPLICIT_ABSTRACT ] { 32 } - Constant [ public int IS_FINAL ] { 4 } + Constant [ public int IS_EXPLICIT_ABSTRACT ] { 64 } + Constant [ public int IS_FINAL ] { 32 } } - Static properties [0] { diff --git a/ext/reflection/tests/ReflectionFunction_getClosure_basic.phpt b/ext/reflection/tests/ReflectionFunction_getClosure_basic.phpt index 4c76959aec..2b7927e7ac 100644 --- a/ext/reflection/tests/ReflectionFunction_getClosure_basic.phpt +++ b/ext/reflection/tests/ReflectionFunction_getClosure_basic.phpt @@ -1,9 +1,9 @@ --TEST-- -Test ReflectionFunction::getClosure() function : basic functionality +Test ReflectionFunction::getClosure() function : basic functionality --FILE-- <?php /* Prototype : public mixed ReflectionFunction::getClosure() - * Description: Returns a dynamically created closure for the function + * Description: Returns a dynamically created closure for the function * Source code: ext/reflection/php_reflection.c * Alias to functions: */ diff --git a/ext/reflection/tests/ReflectionMethod_getClosure_basic.phpt b/ext/reflection/tests/ReflectionMethod_getClosure_basic.phpt index bf1bcf3603..f0a414d56b 100644 --- a/ext/reflection/tests/ReflectionMethod_getClosure_basic.phpt +++ b/ext/reflection/tests/ReflectionMethod_getClosure_basic.phpt @@ -1,9 +1,9 @@ --TEST-- -Test ReflectionMethod::getClosure() function : basic functionality +Test ReflectionMethod::getClosure() function : basic functionality --FILE-- <?php /* Prototype : public mixed ReflectionFunction::getClosure() - * Description: Returns a dynamically created closure for the method + * Description: Returns a dynamically created closure for the method * Source code: ext/reflection/php_reflection.c * Alias to functions: */ diff --git a/ext/reflection/tests/ReflectionMethod_getDocComment_basic.phpt b/ext/reflection/tests/ReflectionMethod_getDocComment_basic.phpt index 2544b0e7ec..e011f259b2 100644 --- a/ext/reflection/tests/ReflectionMethod_getDocComment_basic.phpt +++ b/ext/reflection/tests/ReflectionMethod_getDocComment_basic.phpt @@ -44,7 +44,7 @@ class B extends A { private function privf() {} - /** My Doc Comment for B::protStatf + /** My Doc Comment for B::protStatf @@ -100,7 +100,7 @@ string(%d) "/** * ---> Doc comment for B::protStatf(): -string(%d) "/** My Doc Comment for B::protStatf +string(%d) "/** My Doc Comment for B::protStatf diff --git a/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt b/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt index 55aea10763..d1a19c7116 100644 --- a/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt +++ b/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt @@ -87,151 +87,151 @@ printf("0x%08x\n", $a->getModifiers()); ?> --EXPECTF-- Modifiers for method TestClass::foo(): -0x00000100 +0x00000001 Modifiers for method TestClass::stat(): -0x00000101 +0x00000011 Modifiers for method TestClass::priv(): -0x00000400 +0x00000004 Modifiers for method TestClass::prot(): -0x00000200 +0x00000002 Modifiers for method TestClass::fin(): -0x00000104 +0x00000021 Modifiers for method TestClass::__destruct(): -0x00000100 +0x00000001 Modifiers for method TestClass::__call(): -0x00000100 +0x00000001 Modifiers for method TestClass::__clone(): -0x00000100 +0x00000001 Modifiers for method TestClass::__get(): -0x00000100 +0x00000001 Modifiers for method TestClass::__set(): -0x00000100 +0x00000001 Modifiers for method TestClass::__unset(): -0x00000100 +0x00000001 Modifiers for method TestClass::__isset(): -0x00000100 +0x00000001 Modifiers for method TestClass::__tostring(): -0x00000100 +0x00000001 Modifiers for method TestClass::__sleep(): -0x00000100 +0x00000001 Modifiers for method TestClass::__wakeup(): -0x00000100 +0x00000001 Modifiers for method TestClass::__set_state(): -0x00000100 +0x00000001 Modifiers for method TestClass::__autoload(): -0x00000100 +0x00000001 Modifiers for method TestClass::foo(): -0x00000100 +0x00000001 Modifiers for method TestClass::stat(): -0x00000101 +0x00000011 Modifiers for method TestClass::priv(): -0x00000400 +0x00000004 Modifiers for method TestClass::prot(): -0x00000200 +0x00000002 Modifiers for method TestClass::fin(): -0x00000104 +0x00000021 Modifiers for method TestClass::__destruct(): -0x00000100 +0x00000001 Modifiers for method TestClass::__call(): -0x00000100 +0x00000001 Modifiers for method TestClass::__clone(): -0x00000100 +0x00000001 Modifiers for method TestClass::__get(): -0x00000100 +0x00000001 Modifiers for method TestClass::__set(): -0x00000100 +0x00000001 Modifiers for method TestClass::__unset(): -0x00000100 +0x00000001 Modifiers for method TestClass::__isset(): -0x00000100 +0x00000001 Modifiers for method TestClass::__tostring(): -0x00000100 +0x00000001 Modifiers for method TestClass::__sleep(): -0x00000100 +0x00000001 Modifiers for method TestClass::__wakeup(): -0x00000100 +0x00000001 Modifiers for method TestClass::__set_state(): -0x00000100 +0x00000001 Modifiers for method TestClass::__autoload(): -0x00000100 +0x00000001 Modifiers for method TestInterface::int(): -0x00000102 +0x00000041 Modifiers for method TestInterface::__clone(): -0x00000102 +0x00000041 Modifiers for method AbstractClass::foo(): -0x00000102 +0x00000041 Wrong number of params: @@ -239,4 +239,4 @@ Wrong number of params: Warning: ReflectionMethod::getModifiers() expects exactly 0 parameters, 1 given in %s on line %d ReflectionMethod::getModifiers() modifiers: -0x00000100 +0x00000001 diff --git a/ext/reflection/tests/ReflectionObject_FileInfo_error.phpt b/ext/reflection/tests/ReflectionObject_FileInfo_error.phpt index 70ad24297d..623ba7b480 100644 --- a/ext/reflection/tests/ReflectionObject_FileInfo_error.phpt +++ b/ext/reflection/tests/ReflectionObject_FileInfo_error.phpt @@ -1,5 +1,5 @@ --TEST-- -ReflectionObject::getFileName(), ReflectionObject::getStartLine(), ReflectionObject::getEndLine() -invalid aparams +ReflectionObject::getFileName(), ReflectionObject::getStartLine(), ReflectionObject::getEndLine() -invalid aparams --FILE-- <?php Class C { } diff --git a/ext/reflection/tests/ReflectionObject_export_basic3.phpt b/ext/reflection/tests/ReflectionObject_export_basic3.phpt index dfd3f2e803..7c1da34c93 100644 --- a/ext/reflection/tests/ReflectionObject_export_basic3.phpt +++ b/ext/reflection/tests/ReflectionObject_export_basic3.phpt @@ -1,5 +1,5 @@ --TEST-- -ReflectionObject::export() - ensure dynamic property with same name as inherited private property is shown. +ReflectionObject::export() - ensure dynamic property with same name as inherited private property is shown. --FILE-- <?php class C { diff --git a/ext/reflection/tests/ReflectionObject_getConstants_basic.phpt b/ext/reflection/tests/ReflectionObject_getConstants_basic.phpt index 0ecbde7991..8a56c9f64e 100644 --- a/ext/reflection/tests/ReflectionObject_getConstants_basic.phpt +++ b/ext/reflection/tests/ReflectionObject_getConstants_basic.phpt @@ -1,5 +1,5 @@ --TEST-- -ReflectionObject::getConstants() - basic function test +ReflectionObject::getConstants() - basic function test --FILE-- <?php class C { diff --git a/ext/reflection/tests/ReflectionObject_isInstantiable_variation.phpt b/ext/reflection/tests/ReflectionObject_isInstantiable_variation.phpt index 675bbdde8d..167b6b0ff3 100644 --- a/ext/reflection/tests/ReflectionObject_isInstantiable_variation.phpt +++ b/ext/reflection/tests/ReflectionObject_isInstantiable_variation.phpt @@ -57,7 +57,7 @@ $reflectionObjects = array( publicCtorNew::reflectionObjectFactory(), protectedCtorNew::reflectionObjectFactory(), privateCtorNew::reflectionObjectFactory(), - publicCtorOld::reflectionObjectFactory(), + publicCtorOld::reflectionObjectFactory(), protectedCtorOld::reflectionObjectFactory(), privateCtorOld::reflectionObjectFactory() ); diff --git a/ext/reflection/tests/ReflectionObject_isInternal_basic.phpt b/ext/reflection/tests/ReflectionObject_isInternal_basic.phpt index 234b8eb27e..60a95dc886 100644 --- a/ext/reflection/tests/ReflectionObject_isInternal_basic.phpt +++ b/ext/reflection/tests/ReflectionObject_isInternal_basic.phpt @@ -11,7 +11,7 @@ $r3 = new ReflectionObject(new ReflectionProperty('Exception', 'message')); $r4 = new ReflectionObject(new Exception); $r5 = new ReflectionObject(new C); -var_dump($r1->isInternal(), $r2->isInternal(), $r3->isInternal(), +var_dump($r1->isInternal(), $r2->isInternal(), $r3->isInternal(), $r4->isInternal(), $r5->isInternal()); ?> diff --git a/ext/reflection/tests/ReflectionObject_isUserDefined_basic.phpt b/ext/reflection/tests/ReflectionObject_isUserDefined_basic.phpt index 1a9dea3aba..390df504db 100644 --- a/ext/reflection/tests/ReflectionObject_isUserDefined_basic.phpt +++ b/ext/reflection/tests/ReflectionObject_isUserDefined_basic.phpt @@ -11,7 +11,7 @@ $r3 = new ReflectionObject(new ReflectionProperty('Exception', 'message')); $r4 = new ReflectionObject(new Exception); $r5 = new ReflectionObject(new C); -var_dump($r1->isUserDefined(), $r2->isUserDefined(), $r3->isUserDefined(), +var_dump($r1->isUserDefined(), $r2->isUserDefined(), $r3->isUserDefined(), $r4->isUserDefined(), $r5->isUserDefined()); ?> diff --git a/ext/reflection/tests/ReflectionProperty_basic2.phpt b/ext/reflection/tests/ReflectionProperty_basic2.phpt index 0491073ace..09495f744b 100644 --- a/ext/reflection/tests/ReflectionProperty_basic2.phpt +++ b/ext/reflection/tests/ReflectionProperty_basic2.phpt @@ -43,7 +43,7 @@ Reflecting on property TestClass::pub isDefault(): bool(true) getModifiers(): -int(256) +int(1) getDeclaringClass(): object(ReflectionClass)#%d (1) { ["name"]=> @@ -59,7 +59,7 @@ Reflecting on property TestClass::stat isDefault(): bool(true) getModifiers(): -int(257) +int(17) getDeclaringClass(): object(ReflectionClass)#%d (1) { ["name"]=> @@ -75,7 +75,7 @@ Reflecting on property TestClass::prot isDefault(): bool(true) getModifiers(): -int(512) +int(2) getDeclaringClass(): object(ReflectionClass)#%d (1) { ["name"]=> @@ -93,7 +93,7 @@ Reflecting on property TestClass::priv isDefault(): bool(true) getModifiers(): -int(1024) +int(4) getDeclaringClass(): object(ReflectionClass)#%d (1) { ["name"]=> diff --git a/ext/reflection/tests/ReflectionProperty_getModifiers.001.phpt b/ext/reflection/tests/ReflectionProperty_getModifiers.001.phpt index 6d7ddbe834..e2ff294261 100644 --- a/ext/reflection/tests/ReflectionProperty_getModifiers.001.phpt +++ b/ext/reflection/tests/ReflectionProperty_getModifiers.001.phpt @@ -23,7 +23,7 @@ class TestClass public $pub; static public $stat = "static property"; /** - * This property has a comment. + * This property has a comment. */ protected $prot = 4; private $priv = "keepOut"; @@ -40,27 +40,27 @@ reflectProperty("TestClass", "priv"); Reflecting on property TestClass::pub getModifiers(): -int(256) +int(1) ********************************** ********************************** Reflecting on property TestClass::stat getModifiers(): -int(257) +int(17) ********************************** ********************************** Reflecting on property TestClass::prot getModifiers(): -int(512) +int(2) ********************************** ********************************** Reflecting on property TestClass::priv getModifiers(): -int(1024) +int(4) ********************************** diff --git a/ext/reflection/tests/ReflectionProperty_getModifiers_basic.phpt b/ext/reflection/tests/ReflectionProperty_getModifiers_basic.phpt index 4c99444e30..6856569d3e 100644 --- a/ext/reflection/tests/ReflectionProperty_getModifiers_basic.phpt +++ b/ext/reflection/tests/ReflectionProperty_getModifiers_basic.phpt @@ -32,15 +32,15 @@ for ($i = 1;$i <= 6;$i++) { ?> --EXPECT-- -C::a1: int(256) -D::a1: int(256) -C::a2: int(512) -D::a2: int(512) -C::a3: int(1024) -D::a3: int(1024) -C::a4: int(257) -D::a4: int(257) -C::a5: int(513) -D::a5: int(513) -C::a6: int(1025) -D::a6: int(1025) +C::a1: int(1) +D::a1: int(1) +C::a2: int(2) +D::a2: int(2) +C::a3: int(4) +D::a3: int(4) +C::a4: int(17) +D::a4: int(17) +C::a5: int(18) +D::a5: int(18) +C::a6: int(20) +D::a6: int(20) diff --git a/ext/reflection/tests/bug42976.phpt b/ext/reflection/tests/bug42976.phpt index 0b147aa811..7edf06474c 100644 --- a/ext/reflection/tests/bug42976.phpt +++ b/ext/reflection/tests/bug42976.phpt @@ -18,7 +18,7 @@ $x = "x.original"; $rc->newInstance($x); // causes crash var_dump($x); $x = "x.original"; -$rc->newInstanceArgs(array($x)); // causes crash +$rc->newInstanceArgs(array($x)); // causes crash var_dump($x); echo "Done\n"; diff --git a/ext/reflection/tests/bug49719.phpt b/ext/reflection/tests/bug49719.phpt index f55334c951..6211b6b543 100644 --- a/ext/reflection/tests/bug49719.phpt +++ b/ext/reflection/tests/bug49719.phpt @@ -36,7 +36,7 @@ $prop->setAccessible(true); var_dump($prop->getValue(new b2)); ?> ---EXPECTF-- +--EXPECT-- bool(false) bool(false) bool(false) diff --git a/ext/reflection/tests/bug61388.phpt b/ext/reflection/tests/bug61388.phpt index 3d6dc83fa0..b9fe6bfaaa 100644 --- a/ext/reflection/tests/bug61388.phpt +++ b/ext/reflection/tests/bug61388.phpt @@ -14,12 +14,6 @@ print_r($reflObj->getProperties(ReflectionProperty::IS_PUBLIC)); --EXPECT-- Array ( - [0] => ReflectionProperty Object - ( - [name] => test - [class] => ArrayObject - ) - ) Array ( diff --git a/ext/reflection/tests/bug66430.phpt b/ext/reflection/tests/bug66430.phpt index 921e2c99d8..6e35a0389e 100644 --- a/ext/reflection/tests/bug66430.phpt +++ b/ext/reflection/tests/bug66430.phpt @@ -5,7 +5,7 @@ Bug #66430: ReflectionFunction::invoke does not invoke closure with object scope class Alpha { public $message = "Valid representation"; - + public function bravo() { return $this->message; } diff --git a/ext/reflection/tests/bug76737.phpt b/ext/reflection/tests/bug76737.phpt new file mode 100644 index 0000000000..716b40e76a --- /dev/null +++ b/ext/reflection/tests/bug76737.phpt @@ -0,0 +1,33 @@ +--TEST-- +Bug #76737: Unserialized reflection objects are broken, they shouldn't be serializable +--FILE-- +<?php + +try { + $r = new ReflectionClass('stdClass'); + var_dump(serialize($r)); +} catch (Exception $e) { + echo $e->getMessage(), "\n"; +} +try { + $s = 'C:15:"ReflectionClass":0:{}'; + var_dump(unserialize($s)); +} catch (Exception $e) { + echo $e->getMessage(), "\n"; +} +try { + $s = 'O:15:"ReflectionClass":0:{}'; + var_dump(unserialize($s)); +} catch (Exception $e) { + echo $e->getMessage(), "\n"; +} + +?> +--EXPECTF-- +Serialization of 'ReflectionClass' is not allowed +Unserialization of 'ReflectionClass' is not allowed + +Warning: Erroneous data format for unserializing 'ReflectionClass' in %s on line %d + +Notice: unserialize(): Error at offset 26 of 27 bytes in %s on line %d +bool(false) diff --git a/ext/reflection/tests/exception.inc b/ext/reflection/tests/exception.inc deleted file mode 100644 index da3fceaac7..0000000000 --- a/ext/reflection/tests/exception.inc +++ /dev/null @@ -1,16 +0,0 @@ -<?php -class ReflectionExceptionEx extends ReflectionException { - function MyException($_errno, $_errmsg) { - $this->errno = $_errno; - $this->errmsg = $_errmsg; - } - - function getErrno() { - return $this->errno; - } - - function getErrmsg() { - return $this->errmsg; - } -} -?> |
