diff options
Diffstat (limited to 'ext/reflection')
30 files changed, 903 insertions, 1115 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index db7056e03b..badbf8eb88 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -42,6 +42,7 @@ #include "zend_generators.h" #include "zend_extensions.h" #include "zend_builtin_functions.h" +#include "zend_smart_str.h" #define reflection_update_property(object, name, value) do { \ zval member; \ @@ -69,23 +70,6 @@ PHPAPI zend_class_entry *reflection_class_constant_ptr; PHPAPI zend_class_entry *reflection_extension_ptr; PHPAPI zend_class_entry *reflection_zend_extension_ptr; -#if MBO_0 -ZEND_BEGIN_MODULE_GLOBALS(reflection) - int dummy; -ZEND_END_MODULE_GLOBALS(reflection) - -#ifdef ZTS -# define REFLECTION_G(v) \ - ZEND_TSRMG(reflection_globals_id, zend_reflection_globals*, v) -extern int reflection_globals_id; -#else -# define REFLECTION_G(v) (reflection_globals.v) -extern zend_reflection_globals reflectionglobals; -#endif - -ZEND_DECLARE_MODULE_GLOBALS(reflection) -#endif /* MBO_0 */ - /* Method macros */ #define METHOD_NOTSTATIC(ce) \ @@ -120,75 +104,6 @@ ZEND_DECLARE_MODULE_GLOBALS(reflection) #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); -/* {{{ Smart string functions */ -typedef struct _string { - zend_string *buf; - size_t alloced; -} string; - -static void string_init(string *str) -{ - str->buf= zend_string_alloc(1024, 0); - str->alloced = 1024; - ZSTR_VAL(str->buf)[0] = '\0'; - ZSTR_LEN(str->buf) = 0; -} - -static string *string_printf(string *str, const char *format, ...) -{ - size_t len; - va_list arg; - char *s_tmp; - - va_start(arg, format); - len = zend_vspprintf(&s_tmp, 0, format, arg); - if (len) { - register size_t nlen = (ZSTR_LEN(str->buf) + 1 + len + (1024 - 1)) & ~(1024 - 1); - if (str->alloced < nlen) { - size_t old_len = ZSTR_LEN(str->buf); - str->alloced = nlen; - str->buf = zend_string_extend(str->buf, str->alloced, 0); - ZSTR_LEN(str->buf) = old_len; - } - memcpy(ZSTR_VAL(str->buf) + ZSTR_LEN(str->buf), s_tmp, len + 1); - ZSTR_LEN(str->buf) += len; - } - efree(s_tmp); - va_end(arg); - return str; -} - -static string *string_write(string *str, char *buf, size_t len) -{ - register size_t nlen = (ZSTR_LEN(str->buf) + 1 + len + (1024 - 1)) & ~(1024 - 1); - if (str->alloced < nlen) { - size_t old_len = ZSTR_LEN(str->buf); - str->alloced = nlen; - str->buf = zend_string_extend(str->buf, str->alloced, 0); - ZSTR_LEN(str->buf) = old_len; - } - memcpy(ZSTR_VAL(str->buf) + ZSTR_LEN(str->buf), buf, len); - ZSTR_LEN(str->buf) += len; - ZSTR_VAL(str->buf)[ZSTR_LEN(str->buf)] = '\0'; - return str; -} - -static string *string_append(string *str, string *append) -{ - if (ZSTR_LEN(append->buf) > 0) { - string_write(str, ZSTR_VAL(append->buf), ZSTR_LEN(append->buf)); - } - return str; -} - -static void string_free(string *str) -{ - zend_string_release(str->buf); - str->alloced = 0; - str->buf = NULL; -} -/* }}} */ - /* {{{ Object structure */ /* Struct for properties */ @@ -200,7 +115,7 @@ typedef struct _property_reference { /* Struct for parameters */ typedef struct _parameter_reference { uint32_t offset; - uint32_t required; + zend_bool required; struct _zend_arg_info *arg_info; zend_function *fptr; } parameter_reference; @@ -378,31 +293,28 @@ static zval *reflection_instantiate(zend_class_entry *pce, zval *object) /* {{{ } /* }}} */ -static void _const_string(string *str, char *name, zval *value, char *indent); -static void _function_string(string *str, zend_function *fptr, zend_class_entry *scope, char* indent); -static void _property_string(string *str, zend_property_info *prop, char *prop_name, char* indent); -static void _class_const_string(string *str, char *name, zend_class_constant *c, char* indent); -static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *indent); -static void _extension_string(string *str, zend_module_entry *module, char *indent); -static void _zend_extension_string(string *str, zend_extension *extension, char *indent); +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, char *prop_name, char* indent); +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); +static void _zend_extension_string(smart_str *str, zend_extension *extension, char *indent); /* {{{ _class_string */ -static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *indent) +static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char *indent) { int count, count_static_props = 0, count_static_funcs = 0, count_shadow_props = 0; - string sub_indent; - - string_init(&sub_indent); - string_printf(&sub_indent, "%s ", indent); + zend_string *sub_indent = strpprintf(0, "%s ", indent); /* TBD: Repair indenting of doc comment (or is this to be done in the parser?) */ if (ce->type == ZEND_USER_CLASS && ce->info.user.doc_comment) { - string_printf(str, "%s%s", indent, ZSTR_VAL(ce->info.user.doc_comment)); - string_write(str, "\n", 1); + smart_str_append_printf(str, "%s%s", indent, ZSTR_VAL(ce->info.user.doc_comment)); + smart_str_appendc(str, '\n'); } if (obj && Z_TYPE_P(obj) == IS_OBJECT) { - string_printf(str, "%sObject of class [ ", indent); + smart_str_append_printf(str, "%sObject of class [ ", indent); } else { char *kind = "Class"; if (ce->ce_flags & ZEND_ACC_INTERFACE) { @@ -410,70 +322,70 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in } else if (ce->ce_flags & ZEND_ACC_TRAIT) { kind = "Trait"; } - string_printf(str, "%s%s [ ", indent, kind); + smart_str_append_printf(str, "%s%s [ ", indent, kind); } - string_printf(str, (ce->type == ZEND_USER_CLASS) ? "<user" : "<internal"); + smart_str_append_printf(str, (ce->type == ZEND_USER_CLASS) ? "<user" : "<internal"); if (ce->type == ZEND_INTERNAL_CLASS && ce->info.internal.module) { - string_printf(str, ":%s", ce->info.internal.module->name); + smart_str_append_printf(str, ":%s", ce->info.internal.module->name); } - string_printf(str, "> "); + smart_str_append_printf(str, "> "); if (ce->get_iterator != NULL) { - string_printf(str, "<iterateable> "); + smart_str_append_printf(str, "<iterateable> "); } if (ce->ce_flags & ZEND_ACC_INTERFACE) { - string_printf(str, "interface "); + smart_str_append_printf(str, "interface "); } else if (ce->ce_flags & ZEND_ACC_TRAIT) { - string_printf(str, "trait "); + smart_str_append_printf(str, "trait "); } else { if (ce->ce_flags & (ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) { - string_printf(str, "abstract "); + smart_str_append_printf(str, "abstract "); } if (ce->ce_flags & ZEND_ACC_FINAL) { - string_printf(str, "final "); + smart_str_append_printf(str, "final "); } - string_printf(str, "class "); + smart_str_append_printf(str, "class "); } - string_printf(str, "%s", ZSTR_VAL(ce->name)); + smart_str_append_printf(str, "%s", ZSTR_VAL(ce->name)); if (ce->parent) { - string_printf(str, " extends %s", ZSTR_VAL(ce->parent->name)); + smart_str_append_printf(str, " extends %s", ZSTR_VAL(ce->parent->name)); } if (ce->num_interfaces) { uint32_t i; if (ce->ce_flags & ZEND_ACC_INTERFACE) { - string_printf(str, " extends %s", ZSTR_VAL(ce->interfaces[0]->name)); + smart_str_append_printf(str, " extends %s", ZSTR_VAL(ce->interfaces[0]->name)); } else { - string_printf(str, " implements %s", ZSTR_VAL(ce->interfaces[0]->name)); + smart_str_append_printf(str, " implements %s", ZSTR_VAL(ce->interfaces[0]->name)); } for (i = 1; i < ce->num_interfaces; ++i) { - string_printf(str, ", %s", ZSTR_VAL(ce->interfaces[i]->name)); + smart_str_append_printf(str, ", %s", ZSTR_VAL(ce->interfaces[i]->name)); } } - string_printf(str, " ] {\n"); + smart_str_append_printf(str, " ] {\n"); /* The information where a class is declared is only available for user classes */ if (ce->type == ZEND_USER_CLASS) { - string_printf(str, "%s @@ %s %d-%d\n", indent, ZSTR_VAL(ce->info.user.filename), + smart_str_append_printf(str, "%s @@ %s %d-%d\n", indent, ZSTR_VAL(ce->info.user.filename), ce->info.user.line_start, ce->info.user.line_end); } /* Constants */ - string_printf(str, "\n"); + smart_str_append_printf(str, "\n"); count = zend_hash_num_elements(&ce->constants_table); - string_printf(str, "%s - Constants [%d] {\n", indent, count); + smart_str_append_printf(str, "%s - Constants [%d] {\n", indent, count); if (count > 0) { zend_string *key; zend_class_constant *c; ZEND_HASH_FOREACH_STR_KEY_PTR(&ce->constants_table, key, c) { - _class_const_string(str, ZSTR_VAL(key), c, ZSTR_VAL(sub_indent.buf)); + _class_const_string(str, ZSTR_VAL(key), c, ZSTR_VAL(sub_indent)); if (UNEXPECTED(EG(exception))) { return; } } ZEND_HASH_FOREACH_END(); } - string_printf(str, "%s }\n", indent); + smart_str_append_printf(str, "%s }\n", indent); /* Static properties */ /* counting static properties */ @@ -491,17 +403,17 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in } /* static properties */ - string_printf(str, "\n%s - Static properties [%d] {\n", indent, count_static_props); + smart_str_append_printf(str, "\n%s - Static properties [%d] {\n", indent, count_static_props); if (count_static_props > 0) { 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.buf)); + _property_string(str, prop, NULL, ZSTR_VAL(sub_indent)); } } ZEND_HASH_FOREACH_END(); } - string_printf(str, "%s }\n", indent); + smart_str_append_printf(str, "%s }\n", indent); /* Static methods */ /* counting static methods */ @@ -519,7 +431,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in } /* static methods */ - string_printf(str, "\n%s - Static methods [%d] {", indent, count_static_funcs); + smart_str_append_printf(str, "\n%s - Static methods [%d] {", indent, count_static_funcs); if (count_static_funcs > 0) { zend_function *mptr; @@ -527,52 +439,50 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in if (mptr->common.fn_flags & ZEND_ACC_STATIC && ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce)) { - string_printf(str, "\n"); - _function_string(str, mptr, ce, ZSTR_VAL(sub_indent.buf)); + smart_str_append_printf(str, "\n"); + _function_string(str, mptr, ce, ZSTR_VAL(sub_indent)); } } ZEND_HASH_FOREACH_END(); } else { - string_printf(str, "\n"); + smart_str_append_printf(str, "\n"); } - string_printf(str, "%s }\n", indent); + smart_str_append_printf(str, "%s }\n", indent); /* Default/Implicit properties */ count = zend_hash_num_elements(&ce->properties_info) - count_static_props - count_shadow_props; - string_printf(str, "\n%s - Properties [%d] {\n", indent, count); + smart_str_append_printf(str, "\n%s - Properties [%d] {\n", indent, count); if (count > 0) { 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.buf)); + _property_string(str, prop, NULL, ZSTR_VAL(sub_indent)); } } ZEND_HASH_FOREACH_END(); } - string_printf(str, "%s }\n", indent); + smart_str_append_printf(str, "%s }\n", indent); if (obj && Z_TYPE_P(obj) == IS_OBJECT && Z_OBJ_HT_P(obj)->get_properties) { - string dyn; HashTable *properties = Z_OBJ_HT_P(obj)->get_properties(obj); zend_string *prop_name; + smart_str prop_str = {0}; - string_init(&dyn); count = 0; - if (properties && zend_hash_num_elements(properties)) { ZEND_HASH_FOREACH_STR_KEY(properties, prop_name) { 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(&dyn, NULL, ZSTR_VAL(prop_name), ZSTR_VAL(sub_indent.buf)); + _property_string(&prop_str, NULL, ZSTR_VAL(prop_name), ZSTR_VAL(sub_indent)); } } } ZEND_HASH_FOREACH_END(); } - string_printf(str, "\n%s - Dynamic properties [%d] {\n", indent, count); - string_append(str, &dyn); - string_printf(str, "%s }\n", indent); - string_free(&dyn); + smart_str_append_printf(str, "\n%s - Dynamic properties [%d] {\n", indent, count); + smart_str_append_smart_str(str, &prop_str); + smart_str_append_printf(str, "%s }\n", indent); + smart_str_free(&prop_str); } /* Non static methods */ @@ -580,11 +490,9 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in if (count > 0) { zend_function *mptr; zend_string *key; - string dyn; + smart_str method_str = {0}; count = 0; - string_init(&dyn); - ZEND_HASH_FOREACH_STR_KEY_PTR(&ce->function_table, key, mptr) { if ((mptr->common.fn_flags & ZEND_ACC_STATIC) == 0 && ((mptr->common.fn_flags & ZEND_ACC_PRIVATE) == 0 || mptr->common.scope == ce)) @@ -607,40 +515,40 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in } else { closure = NULL; } - string_printf(&dyn, "\n"); - _function_string(&dyn, mptr, ce, ZSTR_VAL(sub_indent.buf)); + smart_str_appendc(&method_str, '\n'); + _function_string(&method_str, mptr, ce, ZSTR_VAL(sub_indent)); count++; _free_function(closure); } } } ZEND_HASH_FOREACH_END(); - string_printf(str, "\n%s - Methods [%d] {", indent, count); + smart_str_append_printf(str, "\n%s - Methods [%d] {", indent, count); + smart_str_append_smart_str(str, &method_str); if (!count) { - string_printf(str, "\n"); + smart_str_append_printf(str, "\n"); } - string_append(str, &dyn); - string_free(&dyn); + smart_str_free(&method_str); } else { - string_printf(str, "\n%s - Methods [0] {\n", indent); + smart_str_append_printf(str, "\n%s - Methods [0] {\n", indent); } - string_printf(str, "%s }\n", indent); + smart_str_append_printf(str, "%s }\n", indent); - string_printf(str, "%s}\n", indent); - string_free(&sub_indent); + smart_str_append_printf(str, "%s}\n", indent); + zend_string_release(sub_indent); } /* }}} */ /* {{{ _const_string */ -static void _const_string(string *str, char *name, zval *value, char *indent) +static void _const_string(smart_str *str, char *name, zval *value, char *indent) { char *type = zend_zval_type_name(value); if (Z_TYPE_P(value) == IS_ARRAY) { - string_printf(str, "%s Constant [ %s %s ] { Array }\n", + smart_str_append_printf(str, "%s Constant [ %s %s ] { Array }\n", indent, type, name); } else { zend_string *value_str = zval_get_string(value); - string_printf(str, "%s Constant [ %s %s ] { %s }\n", + smart_str_append_printf(str, "%s Constant [ %s %s ] { %s }\n", indent, type, name, ZSTR_VAL(value_str)); zend_string_release(value_str); } @@ -648,7 +556,7 @@ static void _const_string(string *str, char *name, zval *value, char *indent) /* }}} */ /* {{{ _class_const_string */ -static void _class_const_string(string *str, char *name, zend_class_constant *c, char *indent) +static void _class_const_string(smart_str *str, char *name, zend_class_constant *c, char *indent) { char *visibility = zend_visibility_string(Z_ACCESS_FLAGS(c->value)); char *type; @@ -657,12 +565,12 @@ static void _class_const_string(string *str, char *name, zend_class_constant *c, type = zend_zval_type_name(&c->value); if (Z_TYPE(c->value) == IS_ARRAY) { - string_printf(str, "%sConstant [ %s %s %s ] { Array }\n", + smart_str_append_printf(str, "%sConstant [ %s %s %s ] { Array }\n", indent, visibility, type, name); } else { zend_string *value_str = zval_get_string(&c->value); - string_printf(str, "%sConstant [ %s %s %s ] { %s }\n", + smart_str_append_printf(str, "%sConstant [ %s %s %s ] { %s }\n", indent, visibility, type, name, ZSTR_VAL(value_str)); zend_string_release(value_str); @@ -690,87 +598,84 @@ static zend_op* _get_recv_op(zend_op_array *op_array, uint32_t offset) /* }}} */ /* {{{ _parameter_string */ -static void _parameter_string(string *str, zend_function *fptr, struct _zend_arg_info *arg_info, uint32_t offset, uint32_t required, char* indent) +static void _parameter_string(smart_str *str, zend_function *fptr, struct _zend_arg_info *arg_info, uint32_t offset, zend_bool required, char* indent) { - string_printf(str, "Parameter #%d [ ", offset); - if (offset >= required) { - string_printf(str, "<optional> "); + smart_str_append_printf(str, "Parameter #%d [ ", offset); + if (!required) { + smart_str_append_printf(str, "<optional> "); } else { - string_printf(str, "<required> "); + smart_str_append_printf(str, "<required> "); } - if (arg_info->class_name) { - string_printf(str, "%s ", - (fptr->type == ZEND_INTERNAL_FUNCTION && - !(fptr->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) ? - ((zend_internal_arg_info*)arg_info)->class_name : - ZSTR_VAL(arg_info->class_name)); - if (arg_info->allow_null) { - string_printf(str, "or NULL "); + if (ZEND_TYPE_IS_CLASS(arg_info->type)) { + smart_str_append_printf(str, "%s ", + ZSTR_VAL(ZEND_TYPE_NAME(arg_info->type))); + if (ZEND_TYPE_ALLOW_NULL(arg_info->type)) { + smart_str_append_printf(str, "or NULL "); } - } else if (arg_info->type_hint) { - string_printf(str, "%s ", zend_get_type_by_const(arg_info->type_hint)); - if (arg_info->allow_null) { - string_printf(str, "or NULL "); + } else if (ZEND_TYPE_IS_CODE(arg_info->type)) { + smart_str_append_printf(str, "%s ", zend_get_type_by_const(ZEND_TYPE_CODE(arg_info->type))); + if (ZEND_TYPE_ALLOW_NULL(arg_info->type)) { + smart_str_append_printf(str, "or NULL "); } } if (arg_info->pass_by_reference) { - string_write(str, "&", sizeof("&")-1); + smart_str_appendc(str, '&'); } if (arg_info->is_variadic) { - string_write(str, "...", sizeof("...")-1); + smart_str_appends(str, "..."); } if (arg_info->name) { - string_printf(str, "$%s", + smart_str_append_printf(str, "$%s", (fptr->type == ZEND_INTERNAL_FUNCTION && !(fptr->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) ? ((zend_internal_arg_info*)arg_info)->name : ZSTR_VAL(arg_info->name)); } else { - string_printf(str, "$param%d", offset); + smart_str_append_printf(str, "$param%d", offset); } - if (fptr->type == ZEND_USER_FUNCTION && offset >= required) { + if (fptr->type == ZEND_USER_FUNCTION && !required) { zend_op *precv = _get_recv_op((zend_op_array*)fptr, offset); if (precv && precv->opcode == ZEND_RECV_INIT && precv->op2_type != IS_UNUSED) { zval zv; - string_write(str, " = ", sizeof(" = ")-1); + smart_str_appends(str, " = "); ZVAL_DUP(&zv, RT_CONSTANT(&fptr->op_array, precv->op2)); if (UNEXPECTED(zval_update_constant_ex(&zv, fptr->common.scope) == FAILURE)) { zval_ptr_dtor(&zv); return; } if (Z_TYPE(zv) == IS_TRUE) { - string_write(str, "true", sizeof("true")-1); + smart_str_appends(str, "true"); } else if (Z_TYPE(zv) == IS_FALSE) { - string_write(str, "false", sizeof("false")-1); + smart_str_appends(str, "false"); } else if (Z_TYPE(zv) == IS_NULL) { - string_write(str, "NULL", sizeof("NULL")-1); + smart_str_appends(str, "NULL"); } else if (Z_TYPE(zv) == IS_STRING) { - string_write(str, "'", sizeof("'")-1); - string_write(str, Z_STRVAL(zv), MIN(Z_STRLEN(zv), 15)); + smart_str_appendc(str, '\''); + smart_str_appendl(str, Z_STRVAL(zv), MIN(Z_STRLEN(zv), 15)); if (Z_STRLEN(zv) > 15) { - string_write(str, "...", sizeof("...")-1); + smart_str_appends(str, "..."); } - string_write(str, "'", sizeof("'")-1); + smart_str_appendc(str, '\''); } else if (Z_TYPE(zv) == IS_ARRAY) { - string_write(str, "Array", sizeof("Array")-1); + smart_str_appends(str, "Array"); } else { zend_string *zv_str = zval_get_string(&zv); - string_write(str, ZSTR_VAL(zv_str), ZSTR_LEN(zv_str)); + smart_str_append(str, zv_str); zend_string_release(zv_str); } zval_ptr_dtor(&zv); } } - string_write(str, " ]", sizeof(" ]")-1); + smart_str_appends(str, " ]"); } /* }}} */ /* {{{ _function_parameter_string */ -static void _function_parameter_string(string *str, zend_function *fptr, char* indent) +static void _function_parameter_string(smart_str *str, zend_function *fptr, char* indent) { struct _zend_arg_info *arg_info = fptr->common.arg_info; - uint32_t i, num_args, required = fptr->common.required_num_args; + uint32_t i, num_args, num_required = fptr->common.required_num_args; if (!arg_info) { return; @@ -780,20 +685,20 @@ static void _function_parameter_string(string *str, zend_function *fptr, char* i if (fptr->common.fn_flags & ZEND_ACC_VARIADIC) { num_args++; } - string_printf(str, "\n"); - string_printf(str, "%s- Parameters [%d] {\n", indent, num_args); + smart_str_appendc(str, '\n'); + smart_str_append_printf(str, "%s- Parameters [%d] {\n", indent, num_args); for (i = 0; i < num_args; i++) { - string_printf(str, "%s ", indent); - _parameter_string(str, fptr, arg_info, i, required, indent); - string_write(str, "\n", sizeof("\n")-1); + smart_str_append_printf(str, "%s ", indent); + _parameter_string(str, fptr, arg_info, i, i < num_required, indent); + smart_str_appendc(str, '\n'); arg_info++; } - string_printf(str, "%s}\n", indent); + smart_str_append_printf(str, "%s}\n", indent); } /* }}} */ /* {{{ _function_closure_string */ -static void _function_closure_string(string *str, zend_function *fptr, char* indent) +static void _function_closure_string(smart_str *str, zend_function *fptr, char* indent) { uint32_t i, count; zend_string *key; @@ -810,20 +715,20 @@ static void _function_closure_string(string *str, zend_function *fptr, char* ind return; } - string_printf(str, "\n"); - string_printf(str, "%s- Bound Variables [%d] {\n", indent, zend_hash_num_elements(static_variables)); + smart_str_append_printf(str, "\n"); + smart_str_append_printf(str, "%s- Bound Variables [%d] {\n", indent, zend_hash_num_elements(static_variables)); i = 0; ZEND_HASH_FOREACH_STR_KEY(static_variables, key) { - string_printf(str, "%s Variable #%d [ $%s ]\n", indent, i++, ZSTR_VAL(key)); + smart_str_append_printf(str, "%s Variable #%d [ $%s ]\n", indent, i++, ZSTR_VAL(key)); } ZEND_HASH_FOREACH_END(); - string_printf(str, "%s}\n", indent); + smart_str_append_printf(str, "%s}\n", indent); } /* }}} */ /* {{{ _function_string */ -static void _function_string(string *str, zend_function *fptr, zend_class_entry *scope, char* indent) +static void _function_string(smart_str *str, zend_function *fptr, zend_class_entry *scope, char* indent) { - string param_indent; + smart_str param_indent = {0}; zend_function *overwrites; zend_string *lc_name; size_t lc_name_len; @@ -833,190 +738,187 @@ static void _function_string(string *str, zend_function *fptr, zend_class_entry * swallowed, leading to an unaligned comment. */ if (fptr->type == ZEND_USER_FUNCTION && fptr->op_array.doc_comment) { - string_printf(str, "%s%s\n", indent, ZSTR_VAL(fptr->op_array.doc_comment)); + smart_str_append_printf(str, "%s%s\n", indent, ZSTR_VAL(fptr->op_array.doc_comment)); } - string_write(str, indent, strlen(indent)); - string_printf(str, fptr->common.fn_flags & ZEND_ACC_CLOSURE ? "Closure [ " : (fptr->common.scope ? "Method [ " : "Function [ ")); - string_printf(str, (fptr->type == ZEND_USER_FUNCTION) ? "<user" : "<internal"); + smart_str_appendl(str, indent, strlen(indent)); + smart_str_append_printf(str, fptr->common.fn_flags & ZEND_ACC_CLOSURE ? "Closure [ " : (fptr->common.scope ? "Method [ " : "Function [ ")); + smart_str_append_printf(str, (fptr->type == ZEND_USER_FUNCTION) ? "<user" : "<internal"); if (fptr->common.fn_flags & ZEND_ACC_DEPRECATED) { - string_printf(str, ", deprecated"); + smart_str_appends(str, ", deprecated"); } if (fptr->type == ZEND_INTERNAL_FUNCTION && ((zend_internal_function*)fptr)->module) { - string_printf(str, ":%s", ((zend_internal_function*)fptr)->module->name); + smart_str_append_printf(str, ":%s", ((zend_internal_function*)fptr)->module->name); } if (scope && fptr->common.scope) { if (fptr->common.scope != scope) { - string_printf(str, ", inherits %s", ZSTR_VAL(fptr->common.scope->name)); + smart_str_append_printf(str, ", inherits %s", ZSTR_VAL(fptr->common.scope->name)); } else if (fptr->common.scope->parent) { lc_name_len = ZSTR_LEN(fptr->common.function_name); lc_name = zend_string_alloc(lc_name_len, 0); zend_str_tolower_copy(ZSTR_VAL(lc_name), ZSTR_VAL(fptr->common.function_name), lc_name_len); if ((overwrites = zend_hash_find_ptr(&fptr->common.scope->parent->function_table, lc_name)) != NULL) { if (fptr->common.scope != overwrites->common.scope) { - string_printf(str, ", overwrites %s", ZSTR_VAL(overwrites->common.scope->name)); + smart_str_append_printf(str, ", overwrites %s", ZSTR_VAL(overwrites->common.scope->name)); } } efree(lc_name); } } if (fptr->common.prototype && fptr->common.prototype->common.scope) { - string_printf(str, ", prototype %s", ZSTR_VAL(fptr->common.prototype->common.scope->name)); + smart_str_append_printf(str, ", prototype %s", ZSTR_VAL(fptr->common.prototype->common.scope->name)); } if (fptr->common.fn_flags & ZEND_ACC_CTOR) { - string_printf(str, ", ctor"); + smart_str_appends(str, ", ctor"); } if (fptr->common.fn_flags & ZEND_ACC_DTOR) { - string_printf(str, ", dtor"); + smart_str_appends(str, ", dtor"); } - string_printf(str, "> "); + smart_str_appends(str, "> "); if (fptr->common.fn_flags & ZEND_ACC_ABSTRACT) { - string_printf(str, "abstract "); + smart_str_appends(str, "abstract "); } if (fptr->common.fn_flags & ZEND_ACC_FINAL) { - string_printf(str, "final "); + smart_str_appends(str, "final "); } if (fptr->common.fn_flags & ZEND_ACC_STATIC) { - string_printf(str, "static "); + smart_str_appends(str, "static "); } if (fptr->common.scope) { /* These are mutually exclusive */ switch (fptr->common.fn_flags & ZEND_ACC_PPP_MASK) { case ZEND_ACC_PUBLIC: - string_printf(str, "public "); + smart_str_appends(str, "public "); break; case ZEND_ACC_PRIVATE: - string_printf(str, "private "); + smart_str_appends(str, "private "); break; case ZEND_ACC_PROTECTED: - string_printf(str, "protected "); + smart_str_appends(str, "protected "); break; default: - string_printf(str, "<visibility error> "); + smart_str_appends(str, "<visibility error> "); break; } - string_printf(str, "method "); + smart_str_appends(str, "method "); } else { - string_printf(str, "function "); + smart_str_appends(str, "function "); } if (fptr->op_array.fn_flags & ZEND_ACC_RETURN_REFERENCE) { - string_printf(str, "&"); + smart_str_appendc(str, '&'); } - string_printf(str, "%s ] {\n", ZSTR_VAL(fptr->common.function_name)); + smart_str_append_printf(str, "%s ] {\n", ZSTR_VAL(fptr->common.function_name)); /* The information where a function is declared is only available for user classes */ if (fptr->type == ZEND_USER_FUNCTION) { - string_printf(str, "%s @@ %s %d - %d\n", indent, + smart_str_append_printf(str, "%s @@ %s %d - %d\n", indent, ZSTR_VAL(fptr->op_array.filename), fptr->op_array.line_start, fptr->op_array.line_end); } - string_init(¶m_indent); - string_printf(¶m_indent, "%s ", indent); + smart_str_append_printf(¶m_indent, "%s ", indent); + smart_str_0(¶m_indent); if (fptr->common.fn_flags & ZEND_ACC_CLOSURE) { - _function_closure_string(str, fptr, ZSTR_VAL(param_indent.buf)); + _function_closure_string(str, fptr, ZSTR_VAL(param_indent.s)); } - _function_parameter_string(str, fptr, ZSTR_VAL(param_indent.buf)); - string_free(¶m_indent); + _function_parameter_string(str, fptr, ZSTR_VAL(param_indent.s)); + smart_str_free(¶m_indent); if (fptr->op_array.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) { - string_printf(str, " %s- Return [ ", indent); - if (fptr->common.arg_info[-1].class_name) { - string_printf(str, "%s ", - (fptr->type == ZEND_INTERNAL_FUNCTION && - !(fptr->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) ? - ((zend_internal_arg_info*)(fptr->common.arg_info - 1))->class_name : - ZSTR_VAL(fptr->common.arg_info[-1].class_name)); - if (fptr->common.arg_info[-1].allow_null) { - string_printf(str, "or NULL "); + smart_str_append_printf(str, " %s- Return [ ", indent); + if (ZEND_TYPE_IS_CLASS(fptr->common.arg_info[-1].type)) { + smart_str_append_printf(str, "%s ", + ZSTR_VAL(ZEND_TYPE_NAME(fptr->common.arg_info[-1].type))); + if (ZEND_TYPE_ALLOW_NULL(fptr->common.arg_info[-1].type)) { + smart_str_appends(str, "or NULL "); } - } else if (fptr->common.arg_info[-1].type_hint) { - string_printf(str, "%s ", zend_get_type_by_const(fptr->common.arg_info[-1].type_hint)); - if (fptr->common.arg_info[-1].allow_null) { - string_printf(str, "or NULL "); + } else if (ZEND_TYPE_IS_CODE(fptr->common.arg_info[-1].type)) { + smart_str_append_printf(str, "%s ", zend_get_type_by_const(ZEND_TYPE_CODE(fptr->common.arg_info[-1].type))); + if (ZEND_TYPE_ALLOW_NULL(fptr->common.arg_info[-1].type)) { + smart_str_appends(str, "or NULL "); } } - string_printf(str, "]\n"); + smart_str_appends(str, "]\n"); } - string_printf(str, "%s}\n", indent); + smart_str_append_printf(str, "%s}\n", indent); } /* }}} */ /* {{{ _property_string */ -static void _property_string(string *str, zend_property_info *prop, char *prop_name, char* indent) +static void _property_string(smart_str *str, zend_property_info *prop, char *prop_name, char* indent) { const char *class_name; - string_printf(str, "%sProperty [ ", indent); + smart_str_append_printf(str, "%sProperty [ ", indent); if (!prop) { - string_printf(str, "<dynamic> public $%s", prop_name); + smart_str_append_printf(str, "<dynamic> public $%s", prop_name); } else { if (!(prop->flags & ZEND_ACC_STATIC)) { if (prop->flags & ZEND_ACC_IMPLICIT_PUBLIC) { - string_write(str, "<implicit> ", sizeof("<implicit> ") - 1); + smart_str_appends(str, "<implicit> "); } else { - string_write(str, "<default> ", sizeof("<default> ") - 1); + smart_str_appends(str, "<default> "); } } /* These are mutually exclusive */ switch (prop->flags & ZEND_ACC_PPP_MASK) { case ZEND_ACC_PUBLIC: - string_printf(str, "public "); + smart_str_appends(str, "public "); break; case ZEND_ACC_PRIVATE: - string_printf(str, "private "); + smart_str_appends(str, "private "); break; case ZEND_ACC_PROTECTED: - string_printf(str, "protected "); + smart_str_appends(str, "protected "); break; } if(prop->flags & ZEND_ACC_STATIC) { - string_printf(str, "static "); + smart_str_appends(str, "static "); } zend_unmangle_property_name(prop->name, &class_name, (const char**)&prop_name); - string_printf(str, "$%s", prop_name); + smart_str_append_printf(str, "$%s", prop_name); } - string_printf(str, " ]\n"); + smart_str_appends(str, " ]\n"); } /* }}} */ static int _extension_ini_string(zval *el, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ { zend_ini_entry *ini_entry = (zend_ini_entry*)Z_PTR_P(el); - string *str = va_arg(args, string *); + 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) { - string_printf(str, " %sEntry [ %s <", indent, ZSTR_VAL(ini_entry->name)); + smart_str_append_printf(str, " %sEntry [ %s <", indent, ZSTR_VAL(ini_entry->name)); if (ini_entry->modifiable == ZEND_INI_ALL) { - string_printf(str, "ALL"); + smart_str_appends(str, "ALL"); } else { if (ini_entry->modifiable & ZEND_INI_USER) { - string_printf(str, "USER"); + smart_str_appends(str, "USER"); comma = ","; } if (ini_entry->modifiable & ZEND_INI_PERDIR) { - string_printf(str, "%sPERDIR", comma); + smart_str_append_printf(str, "%sPERDIR", comma); comma = ","; } if (ini_entry->modifiable & ZEND_INI_SYSTEM) { - string_printf(str, "%sSYSTEM", comma); + smart_str_append_printf(str, "%sSYSTEM", comma); } } - string_printf(str, "> ]\n"); - string_printf(str, " %s Current = '%s'\n", indent, ini_entry->value ? ZSTR_VAL(ini_entry->value) : ""); + smart_str_appends(str, "> ]\n"); + smart_str_append_printf(str, " %s Current = '%s'\n", indent, ini_entry->value ? ZSTR_VAL(ini_entry->value) : ""); if (ini_entry->modified) { - string_printf(str, " %s Default = '%s'\n", indent, ini_entry->orig_value ? ZSTR_VAL(ini_entry->orig_value) : ""); + smart_str_append_printf(str, " %s Default = '%s'\n", indent, ini_entry->orig_value ? ZSTR_VAL(ini_entry->orig_value) : ""); } - string_printf(str, " %s}\n", indent); + smart_str_append_printf(str, " %s}\n", indent); } return ZEND_HASH_APPLY_KEEP; } @@ -1025,7 +927,7 @@ static int _extension_ini_string(zval *el, int num_args, va_list args, zend_hash static int _extension_class_string(zval *el, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ { zend_class_entry *ce = (zend_class_entry*)Z_PTR_P(el); - string *str = va_arg(args, string *); + 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*); @@ -1033,7 +935,7 @@ static int _extension_class_string(zval *el, int num_args, va_list args, zend_ha 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))) { - string_printf(str, "\n"); + smart_str_append_printf(str, "\n"); _class_string(str, ce, NULL, indent); (*num_classes)++; } @@ -1045,7 +947,7 @@ static int _extension_class_string(zval *el, int num_args, va_list args, zend_ha 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); - string *str = va_arg(args, string *); + 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*); @@ -1058,78 +960,76 @@ static int _extension_const_string(zval *el, int num_args, va_list args, zend_ha } /* }}} */ -static void _extension_string(string *str, zend_module_entry *module, char *indent) /* {{{ */ +static void _extension_string(smart_str *str, zend_module_entry *module, char *indent) /* {{{ */ { - string_printf(str, "%sExtension [ ", indent); + smart_str_append_printf(str, "%sExtension [ ", indent); if (module->type == MODULE_PERSISTENT) { - string_printf(str, "<persistent>"); + smart_str_appends(str, "<persistent>"); } if (module->type == MODULE_TEMPORARY) { - string_printf(str, "<temporary>" ); + smart_str_appends(str, "<temporary>" ); } - string_printf(str, " extension #%d %s version %s ] {\n", + smart_str_append_printf(str, " extension #%d %s version %s ] {\n", module->module_number, module->name, (module->version == NO_VERSION_YET) ? "<no_version>" : module->version); if (module->deps) { const zend_module_dep* dep = module->deps; - string_printf(str, "\n - Dependencies {\n"); + smart_str_appends(str, "\n - Dependencies {\n"); while(dep->name) { - string_printf(str, "%s Dependency [ %s (", indent, dep->name); + smart_str_append_printf(str, "%s Dependency [ %s (", indent, dep->name); switch(dep->type) { case MODULE_DEP_REQUIRED: - string_write(str, "Required", sizeof("Required") - 1); + smart_str_appends(str, "Required"); break; case MODULE_DEP_CONFLICTS: - string_write(str, "Conflicts", sizeof("Conflicts") - 1); + smart_str_appends(str, "Conflicts"); break; case MODULE_DEP_OPTIONAL: - string_write(str, "Optional", sizeof("Optional") - 1); + smart_str_appends(str, "Optional"); break; default: - string_write(str, "Error", sizeof("Error") - 1); /* shouldn't happen */ + smart_str_appends(str, "Error"); /* shouldn't happen */ break; } if (dep->rel) { - string_printf(str, " %s", dep->rel); + smart_str_append_printf(str, " %s", dep->rel); } if (dep->version) { - string_printf(str, " %s", dep->version); + smart_str_append_printf(str, " %s", dep->version); } - string_write(str, ") ]\n", sizeof(") ]\n") - 1); + smart_str_appends(str, ") ]\n"); dep++; } - string_printf(str, "%s }\n", indent); + smart_str_append_printf(str, "%s }\n", indent); } { - string str_ini; - string_init(&str_ini); + 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); - if (ZSTR_LEN(str_ini.buf) > 0) { - string_printf(str, "\n - INI {\n"); - string_append(str, &str_ini); - string_printf(str, "%s }\n", indent); + if (smart_str_get_len(&str_ini) > 0) { + smart_str_append_printf(str, "\n - INI {\n"); + smart_str_append_smart_str(str, &str_ini); + smart_str_append_printf(str, "%s }\n", indent); } - string_free(&str_ini); + smart_str_free(&str_ini); } { - string str_constants; + smart_str str_constants = {0}; int num_constants = 0; - string_init(&str_constants); zend_hash_apply_with_arguments(EG(zend_constants), (apply_func_args_t) _extension_const_string, 4, &str_constants, indent, module, &num_constants); if (num_constants) { - string_printf(str, "\n - Constants [%d] {\n", num_constants); - string_append(str, &str_constants); - string_printf(str, "%s }\n", indent); + smart_str_append_printf(str, "\n - Constants [%d] {\n", num_constants); + smart_str_append_smart_str(str, &str_constants); + smart_str_append_printf(str, "%s }\n", indent); } - string_free(&str_constants); + smart_str_free(&str_constants); } { @@ -1140,57 +1040,54 @@ static void _extension_string(string *str, zend_module_entry *module, char *inde if (fptr->common.type==ZEND_INTERNAL_FUNCTION && fptr->internal_function.module == module) { if (first) { - string_printf(str, "\n - Functions {\n"); + smart_str_append_printf(str, "\n - Functions {\n"); first = 0; } _function_string(str, fptr, NULL, " "); } } ZEND_HASH_FOREACH_END(); if (!first) { - string_printf(str, "%s }\n", indent); + smart_str_append_printf(str, "%s }\n", indent); } } { - string str_classes; - string sub_indent; + zend_string *sub_indent = strpprintf(0, "%s ", indent); + smart_str str_classes = {0}; int num_classes = 0; - string_init(&sub_indent); - string_printf(&sub_indent, "%s ", indent); - string_init(&str_classes); - zend_hash_apply_with_arguments(EG(class_table), (apply_func_args_t) _extension_class_string, 4, &str_classes, ZSTR_VAL(sub_indent.buf), module, &num_classes); + 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); if (num_classes) { - string_printf(str, "\n - Classes [%d] {", num_classes); - string_append(str, &str_classes); - string_printf(str, "%s }\n", indent); + smart_str_append_printf(str, "\n - Classes [%d] {", num_classes); + smart_str_append_smart_str(str, &str_classes); + smart_str_append_printf(str, "%s }\n", indent); } - string_free(&str_classes); - string_free(&sub_indent); + smart_str_free(&str_classes); + zend_string_release(sub_indent); } - string_printf(str, "%s}\n", indent); + smart_str_append_printf(str, "%s}\n", indent); } /* }}} */ -static void _zend_extension_string(string *str, zend_extension *extension, char *indent) /* {{{ */ +static void _zend_extension_string(smart_str *str, zend_extension *extension, char *indent) /* {{{ */ { - string_printf(str, "%sZend Extension [ %s ", indent, extension->name); + smart_str_append_printf(str, "%sZend Extension [ %s ", indent, extension->name); if (extension->version) { - string_printf(str, "%s ", extension->version); + smart_str_append_printf(str, "%s ", extension->version); } if (extension->copyright) { - string_printf(str, "%s ", extension->copyright); + smart_str_append_printf(str, "%s ", extension->copyright); } if (extension->author) { - string_printf(str, "by %s ", extension->author); + smart_str_append_printf(str, "by %s ", extension->author); } if (extension->URL) { - string_printf(str, "<%s> ", extension->URL); + smart_str_append_printf(str, "<%s> ", extension->URL); } - string_printf(str, "]\n"); + smart_str_appends(str, "]\n"); } /* }}} */ @@ -1252,7 +1149,7 @@ static void reflection_extension_factory(zval *object, const char *name_str) /* }}} */ /* {{{ reflection_parameter_factory */ -static void reflection_parameter_factory(zend_function *fptr, zval *closure_object, struct _zend_arg_info *arg_info, uint32_t offset, uint32_t required, zval *object) +static void reflection_parameter_factory(zend_function *fptr, zval *closure_object, struct _zend_arg_info *arg_info, uint32_t offset, zend_bool required, zval *object) { reflection_object *intern; parameter_reference *reference; @@ -1712,15 +1609,14 @@ ZEND_METHOD(reflection_function, __toString) { reflection_object *intern; zend_function *fptr; - string str; + smart_str str = {0}; if (zend_parse_parameters_none() == FAILURE) { return; } GET_REFLECTION_OBJECT_PTR(fptr); - string_init(&str); _function_string(&str, fptr, intern->ce, ""); - RETURN_NEW_STR(str.buf); + RETURN_STR(smart_str_extract(&str)); } /* }}} */ @@ -2089,7 +1985,7 @@ ZEND_METHOD(reflection_function, returnsReference) /* }}} */ /* {{{ proto public bool ReflectionFunction::getNumberOfParameters() - Gets the number of required parameters */ + Gets the number of parameters */ ZEND_METHOD(reflection_function, getNumberOfParameters) { reflection_object *intern; @@ -2144,7 +2040,14 @@ ZEND_METHOD(reflection_function, getParameters) for (i = 0; i < num_args; i++) { zval parameter; - reflection_parameter_factory(_copy_function(fptr), Z_ISUNDEF(intern->obj)? NULL : &intern->obj, arg_info, i, fptr->common.required_num_args, ¶meter); + reflection_parameter_factory( + _copy_function(fptr), + Z_ISUNDEF(intern->obj) ? NULL : &intern->obj, + arg_info, + i, + i < fptr->common.required_num_args, + ¶meter + ); add_next_index_zval(return_value, ¶meter); arg_info++; @@ -2216,7 +2119,7 @@ ZEND_METHOD(reflection_generator, __construct) ex = ((zend_generator *) Z_OBJ_P(generator))->execute_data; if (!ex) { - zend_throw_exception(NULL, "Cannot create ReflectionGenerator based on a terminated Generator", 0); + _DO_THROW("Cannot create ReflectionGenerator based on a terminated Generator"); return; } @@ -2228,7 +2131,7 @@ ZEND_METHOD(reflection_generator, __construct) #define REFLECTION_CHECK_VALID_GENERATOR(ex) \ if (!ex) { \ - zend_throw_exception(NULL, "Cannot fetch information from a terminated Generator", 0); \ + _DO_THROW("Cannot fetch information from a terminated Generator"); \ return; \ } @@ -2556,7 +2459,7 @@ ZEND_METHOD(reflection_parameter, __construct) ref = (parameter_reference*) emalloc(sizeof(parameter_reference)); ref->arg_info = &arg_info[position]; ref->offset = (uint32_t)position; - ref->required = fptr->common.required_num_args; + ref->required = position < fptr->common.required_num_args; ref->fptr = fptr; /* TODO: copy fptr */ intern->ptr = ref; @@ -2574,15 +2477,14 @@ ZEND_METHOD(reflection_parameter, __toString) { reflection_object *intern; parameter_reference *param; - string str; + smart_str str = {0}; if (zend_parse_parameters_none() == FAILURE) { return; } GET_REFLECTION_OBJECT_PTR(param); - string_init(&str); _parameter_string(&str, param->fptr, param->arg_info, param->offset, param->required, ""); - RETURN_NEW_STR(str.buf); + RETURN_STR(smart_str_extract(&str)); } /* }}} */ @@ -2649,7 +2551,7 @@ ZEND_METHOD(reflection_parameter, getClass) } GET_REFLECTION_OBJECT_PTR(param); - if (param->arg_info->class_name) { + if (ZEND_TYPE_IS_CLASS(param->arg_info->type)) { /* Class name is stored as a string, we might also get "self" or "parent" * - For "self", simply use the function scope. If scope is NULL then * the function is global and thus self does not make any sense @@ -2662,25 +2564,17 @@ ZEND_METHOD(reflection_parameter, getClass) * TODO: Think about moving these checks to the compiler or some sort of * lint-mode. */ - const char *class_name; - size_t class_name_len; + zend_string *class_name; - if (param->fptr->type == ZEND_INTERNAL_FUNCTION && - !(param->fptr->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) { - class_name = ((zend_internal_arg_info*)param->arg_info)->class_name; - class_name_len = strlen(class_name); - } else { - class_name = ZSTR_VAL(param->arg_info->class_name); - class_name_len = ZSTR_LEN(param->arg_info->class_name); - } - if (0 == zend_binary_strcasecmp(class_name, class_name_len, "self", sizeof("self")- 1)) { + class_name = ZEND_TYPE_NAME(param->arg_info->type); + if (0 == zend_binary_strcasecmp(ZSTR_VAL(class_name), ZSTR_LEN(class_name), "self", sizeof("self")- 1)) { ce = param->fptr->common.scope; if (!ce) { zend_throw_exception_ex(reflection_exception_ptr, 0, "Parameter uses 'self' as type hint but function is not a class member!"); return; } - } else if (0 == zend_binary_strcasecmp(class_name, class_name_len, "parent", sizeof("parent")- 1)) { + } else if (0 == zend_binary_strcasecmp(ZSTR_VAL(class_name), ZSTR_LEN(class_name), "parent", sizeof("parent")- 1)) { ce = param->fptr->common.scope; if (!ce) { zend_throw_exception_ex(reflection_exception_ptr, 0, @@ -2694,17 +2588,10 @@ ZEND_METHOD(reflection_parameter, getClass) } ce = ce->parent; } else { - if (param->fptr->type == ZEND_INTERNAL_FUNCTION && - !(param->fptr->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) { - zend_string *name = zend_string_init(class_name, class_name_len, 0); - ce = zend_lookup_class(name); - zend_string_release(name); - } else { - ce = zend_lookup_class(param->arg_info->class_name); - } + ce = zend_lookup_class(class_name); if (!ce) { zend_throw_exception_ex(reflection_exception_ptr, 0, - "Class %s does not exist", class_name); + "Class %s does not exist", ZSTR_VAL(class_name)); return; } } @@ -2725,7 +2612,7 @@ ZEND_METHOD(reflection_parameter, hasType) } GET_REFLECTION_OBJECT_PTR(param); - RETVAL_BOOL(param->arg_info->type_hint != 0); + RETVAL_BOOL(ZEND_TYPE_IS_SET(param->arg_info->type)); } /* }}} */ @@ -2741,11 +2628,7 @@ ZEND_METHOD(reflection_parameter, getType) } GET_REFLECTION_OBJECT_PTR(param); - if (((param->fptr->type == ZEND_INTERNAL_FUNCTION && - !(param->fptr->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) ? - ((zend_internal_arg_info*)param->arg_info)->type_hint : - param->arg_info->type_hint) == 0) - { + 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); @@ -2764,7 +2647,7 @@ ZEND_METHOD(reflection_parameter, isArray) } GET_REFLECTION_OBJECT_PTR(param); - RETVAL_BOOL(param->arg_info->type_hint == IS_ARRAY); + RETVAL_BOOL(ZEND_TYPE_CODE(param->arg_info->type) == IS_ARRAY); } /* }}} */ @@ -2780,7 +2663,7 @@ ZEND_METHOD(reflection_parameter, isCallable) } GET_REFLECTION_OBJECT_PTR(param); - RETVAL_BOOL(param->arg_info->type_hint == IS_CALLABLE); + RETVAL_BOOL(ZEND_TYPE_CODE(param->arg_info->type) == IS_CALLABLE); } /* }}} */ @@ -2796,7 +2679,7 @@ ZEND_METHOD(reflection_parameter, allowsNull) } GET_REFLECTION_OBJECT_PTR(param); - RETVAL_BOOL(param->arg_info->allow_null); + RETVAL_BOOL(ZEND_TYPE_ALLOW_NULL(param->arg_info->type)); } /* }}} */ @@ -2861,7 +2744,7 @@ ZEND_METHOD(reflection_parameter, isOptional) } GET_REFLECTION_OBJECT_PTR(param); - RETVAL_BOOL(param->offset >= param->required); + RETVAL_BOOL(!param->required); } /* }}} */ @@ -2995,7 +2878,7 @@ ZEND_METHOD(reflection_type, allowsNull) } GET_REFLECTION_OBJECT_PTR(param); - RETVAL_BOOL(param->arg_info->allow_null); + RETVAL_BOOL(ZEND_TYPE_ALLOW_NULL(param->arg_info->type)); } /* }}} */ @@ -3011,28 +2894,25 @@ ZEND_METHOD(reflection_type, isBuiltin) } GET_REFLECTION_OBJECT_PTR(param); - RETVAL_BOOL(param->arg_info->type_hint != IS_OBJECT); + RETVAL_BOOL(ZEND_TYPE_IS_CODE(param->arg_info->type)); } /* }}} */ /* {{{ reflection_type_name */ static zend_string *reflection_type_name(type_reference *param) { - switch (param->arg_info->type_hint) { - case IS_ARRAY: return zend_string_init("array", sizeof("array") - 1, 0); - case IS_CALLABLE: return zend_string_init("callable", sizeof("callable") - 1, 0); - case IS_OBJECT: - if (param->fptr->type == ZEND_INTERNAL_FUNCTION && - !(param->fptr->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) { - return zend_string_init(((zend_internal_arg_info*)param->arg_info)->class_name, strlen(((zend_internal_arg_info*)param->arg_info)->class_name), 0); - } - return zend_string_copy(param->arg_info->class_name); - case IS_STRING: return zend_string_init("string", sizeof("string") - 1, 0); + if (ZEND_TYPE_IS_CLASS(param->arg_info->type)) { + return zend_string_copy(ZEND_TYPE_NAME(param->arg_info->type)); + } + switch (ZEND_TYPE_CODE(param->arg_info->type)) { + /* keep this for BC, bool vs boolean, int vs integer */ case _IS_BOOL: return zend_string_init("bool", sizeof("bool") - 1, 0); case IS_LONG: return zend_string_init("int", sizeof("int") - 1, 0); - case IS_DOUBLE: return zend_string_init("float", sizeof("float") - 1, 0); - case IS_VOID: return zend_string_init("void", sizeof("void") - 1, 0); - case IS_ITERABLE: return zend_string_init("iterable", sizeof("iterable") - 1, 0); - EMPTY_SWITCH_DEFAULT_CASE() + /* use zend API for other types */ + default: + { + char *name = zend_get_type_by_const(ZEND_TYPE_CODE(param->arg_info->type)); + return zend_string_init(name, strlen(name), 0); + } } } /* }}} */ @@ -3176,15 +3056,14 @@ ZEND_METHOD(reflection_method, __toString) { reflection_object *intern; zend_function *mptr; - string str; + smart_str str = {0}; if (zend_parse_parameters_none() == FAILURE) { return; } GET_REFLECTION_OBJECT_PTR(mptr); - string_init(&str); _function_string(&str, mptr, intern->ce, ""); - RETURN_NEW_STR(str.buf); + RETURN_STR(smart_str_extract(&str)); } /* }}} */ @@ -3587,13 +3466,15 @@ ZEND_METHOD(reflection_method, getModifiers) { reflection_object *intern; zend_function *mptr; + uint32_t keep_flags = ZEND_ACC_PPP_MASK | ZEND_ACC_IMPLICIT_PUBLIC + | ZEND_ACC_STATIC | ZEND_ACC_ABSTRACT | ZEND_ACC_FINAL; if (zend_parse_parameters_none() == FAILURE) { return; } GET_REFLECTION_OBJECT_PTR(mptr); - RETURN_LONG(mptr->common.fn_flags); + RETURN_LONG((mptr->common.fn_flags & keep_flags)); } /* }}} */ @@ -3715,18 +3596,17 @@ ZEND_METHOD(reflection_class_constant, __toString) { reflection_object *intern; zend_class_constant *ref; - string str; + smart_str str = {0}; zval name; if (zend_parse_parameters_none() == FAILURE) { return; } GET_REFLECTION_OBJECT_PTR(ref); - string_init(&str); _default_get_entry(getThis(), "name", sizeof("name")-1, &name); _class_const_string(&str, Z_STRVAL(name), ref, ""); zval_ptr_dtor(&name); - RETURN_NEW_STR(str.buf); + RETURN_STR(smart_str_extract(&str)); } /* }}} */ @@ -4066,15 +3946,14 @@ ZEND_METHOD(reflection_class, __toString) { reflection_object *intern; zend_class_entry *ce; - string str; + smart_str str = {0}; if (zend_parse_parameters_none() == FAILURE) { return; } GET_REFLECTION_OBJECT_PTR(ce); - string_init(&str); _class_string(&str, ce, &intern->obj, ""); - RETURN_NEW_STR(str.buf); + RETURN_STR(smart_str_extract(&str)); } /* }}} */ @@ -4792,13 +4671,15 @@ ZEND_METHOD(reflection_class, getModifiers) { reflection_object *intern; zend_class_entry *ce; + uint32_t keep_flags = ZEND_ACC_FINAL + | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS | ZEND_ACC_IMPLICIT_ABSTRACT_CLASS; if (zend_parse_parameters_none() == FAILURE) { return; } GET_REFLECTION_OBJECT_PTR(ce); - RETURN_LONG(ce->ce_flags & ~(ZEND_ACC_CONSTANTS_UPDATED|ZEND_ACC_USE_GUARDS|ZEND_ACC_INHERITED)); + RETURN_LONG((ce->ce_flags & keep_flags)); } /* }}} */ @@ -4819,7 +4700,7 @@ ZEND_METHOD(reflection_class, isInstance) } /* }}} */ -/* {{{ proto public stdclass ReflectionClass::newInstance(mixed* args, ...) +/* {{{ proto public stdclass ReflectionClass::newInstance([mixed* args], ...) Returns an instance of this class */ ZEND_METHOD(reflection_class, newInstance) { @@ -5236,9 +5117,9 @@ ZEND_METHOD(reflection_class, implementsInterface) } /* }}} */ -/* {{{ proto public bool ReflectionClass::isIterateable() - Returns whether this class is iterateable (can be used inside foreach) */ -ZEND_METHOD(reflection_class, isIterateable) +/* {{{ proto public bool ReflectionClass::isIterable() + Returns whether this class is iterable (can be used inside foreach) */ +ZEND_METHOD(reflection_class, isIterable) { reflection_object *intern; zend_class_entry *ce; @@ -5250,7 +5131,12 @@ ZEND_METHOD(reflection_class, isIterateable) METHOD_NOTSTATIC(reflection_class_ptr); GET_REFLECTION_OBJECT_PTR(ce); - RETURN_BOOL(ce->get_iterator != NULL); + if (ce->ce_flags & (ZEND_ACC_INTERFACE | ZEND_ACC_IMPLICIT_ABSTRACT_CLASS | + ZEND_ACC_TRAIT | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) { + RETURN_FALSE; + } + + RETURN_BOOL(ce->get_iterator || instanceof_function(ce, zend_ce_traversable)); } /* }}} */ @@ -5499,15 +5385,14 @@ ZEND_METHOD(reflection_property, __toString) { reflection_object *intern; property_reference *ref; - string str; + smart_str str = {0}; if (zend_parse_parameters_none() == FAILURE) { return; } GET_REFLECTION_OBJECT_PTR(ref); - string_init(&str); _property_string(&str, &ref->prop, NULL, ""); - RETURN_NEW_STR(str.buf); + RETURN_STR(smart_str_extract(&str)); } /* }}} */ @@ -5581,13 +5466,14 @@ 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; if (zend_parse_parameters_none() == FAILURE) { return; } GET_REFLECTION_OBJECT_PTR(ref); - RETURN_LONG(ref->prop.flags); + RETURN_LONG((ref->prop.flags & keep_flags)); } /* }}} */ @@ -5835,15 +5721,14 @@ ZEND_METHOD(reflection_extension, __toString) { reflection_object *intern; zend_module_entry *module; - string str; + smart_str str = {0}; if (zend_parse_parameters_none() == FAILURE) { return; } GET_REFLECTION_OBJECT_PTR(module); - string_init(&str); _extension_string(&str, module, ""); - RETURN_NEW_STR(str.buf); + RETURN_STR(smart_str_extract(&str)); } /* }}} */ @@ -6198,15 +6083,14 @@ ZEND_METHOD(reflection_zend_extension, __toString) { reflection_object *intern; zend_extension *extension; - string str; + smart_str str = {0}; if (zend_parse_parameters_none() == FAILURE) { return; } GET_REFLECTION_OBJECT_PTR(extension); - string_init(&str); _zend_extension_string(&str, extension, ""); - RETURN_NEW_STR(str.buf); + RETURN_STR(smart_str_extract(&str)); } /* }}} */ @@ -6520,8 +6404,8 @@ ZEND_BEGIN_ARG_INFO(arginfo_reflection_class_isInstance, 0) ZEND_ARG_INFO(0, object) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO(arginfo_reflection_class_newInstance, 0) - ZEND_ARG_INFO(0, args) +ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_class_newInstance, 0, 0, 0) + ZEND_ARG_VARIADIC_INFO(0, args) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO(arginfo_reflection_class_newInstanceWithoutConstructor, 0) @@ -6586,7 +6470,8 @@ static const zend_function_entry reflection_class_functions[] = { ZEND_ME(reflection_class, getStaticPropertyValue, arginfo_reflection_class_getStaticPropertyValue, 0) ZEND_ME(reflection_class, setStaticPropertyValue, arginfo_reflection_class_setStaticPropertyValue, 0) ZEND_ME(reflection_class, getDefaultProperties, arginfo_reflection__void, 0) - ZEND_ME(reflection_class, isIterateable, arginfo_reflection__void, 0) + ZEND_ME(reflection_class, isIterable, arginfo_reflection__void, 0) + ZEND_MALIAS(reflection_class, isIterateable, isIterable, arginfo_reflection__void, 0) ZEND_ME(reflection_class, implementsInterface, arginfo_reflection_class_implementsInterface, 0) ZEND_ME(reflection_class, getExtension, arginfo_reflection__void, 0) ZEND_ME(reflection_class, getExtensionName, arginfo_reflection__void, 0) diff --git a/ext/reflection/tests/002.phpt b/ext/reflection/tests/002.phpt index 833fed4aa5..cbd7319731 100644 --- a/ext/reflection/tests/002.phpt +++ b/ext/reflection/tests/002.phpt @@ -50,14 +50,14 @@ var_dump($r->bar); ===DONE=== --EXPECTF-- ReflectionMethodEx::__construct -%unicode|string%(26) "ReflectionFunctionAbstract" -%unicode|string%(7) "getName" -%unicode|string%(3) "xyz" +string(26) "ReflectionFunctionAbstract" +string(7) "getName" +string(3) "xyz" NULL Cannot set read-only property ReflectionMethodEx::$class Cannot set read-only property ReflectionMethodEx::$name -%unicode|string%(26) "ReflectionFunctionAbstract" -%unicode|string%(7) "getName" -%unicode|string%(3) "bar" -%unicode|string%(3) "baz" +string(26) "ReflectionFunctionAbstract" +string(7) "getName" +string(3) "bar" +string(3) "baz" ===DONE=== diff --git a/ext/reflection/tests/007.phpt b/ext/reflection/tests/007.phpt index d9204171b5..8dfc2e8bcc 100644 --- a/ext/reflection/tests/007.phpt +++ b/ext/reflection/tests/007.phpt @@ -53,10 +53,9 @@ function test($class) echo "\n"; } -function __autoload($class) -{ +spl_autoload_register(function ($class) { echo __FUNCTION__ . "($class)\n"; -} +}); test('Class_does_not_exist'); @@ -94,7 +93,7 @@ test('WithCtorWithArgs'); --EXPECTF-- ====>Class_does_not_exist -__autoload(Class_does_not_exist) +{closure}(Class_does_not_exist) string(41) "Class Class_does_not_exist does not exist" ====>NoCtor ====>newInstance() diff --git a/ext/reflection/tests/027.phpt b/ext/reflection/tests/027.phpt new file mode 100644 index 0000000000..06db60b8ec --- /dev/null +++ b/ext/reflection/tests/027.phpt @@ -0,0 +1,22 @@ +--TEST-- +ReflectionGenerator::getTrace() +--FILE-- +<?php +function foo() +{ + yield 1; +} + +$g = foo(); +$r = new ReflectionGenerator($g); + +$g->next(); + +try { + $r->getTrace(); +} catch (ReflectionException $e) { + echo $e->getMessage(); +} +?> +--EXPECTF-- +Cannot fetch information from a terminated Generator diff --git a/ext/reflection/tests/028.phpt b/ext/reflection/tests/028.phpt new file mode 100644 index 0000000000..5f1e7a2faa --- /dev/null +++ b/ext/reflection/tests/028.phpt @@ -0,0 +1,20 @@ +--TEST-- +ReflectionGenerator::__construct() +--FILE-- +<?php +function foo() +{ + yield 1; +} + +$g = foo(); +$g->next(); + +try { + $r = new ReflectionGenerator($g); +} catch (ReflectionException $e) { + echo "Done!\n"; +} +?> +--EXPECTF-- +Done! diff --git a/ext/reflection/tests/ReflectionClass_getMethod_001.phpt b/ext/reflection/tests/ReflectionClass_getMethod_001.phpt index 2f2d790f68..780b558cc7 100644 --- a/ext/reflection/tests/ReflectionClass_getMethod_001.phpt +++ b/ext/reflection/tests/ReflectionClass_getMethod_001.phpt @@ -48,121 +48,121 @@ foreach($classes as $class) { --EXPECTF-- Reflecting on class pubf: --> Check for f(): object(ReflectionMethod)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "f" - [%u|b%"class"]=> - %unicode|string%(4) "pubf" + ["name"]=> + string(1) "f" + ["class"]=> + string(4) "pubf" } --> Check for s(): object(ReflectionMethod)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "s" - [%u|b%"class"]=> - %unicode|string%(4) "pubf" + ["name"]=> + string(1) "s" + ["class"]=> + string(4) "pubf" } --> Check for F(): object(ReflectionMethod)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "f" - [%u|b%"class"]=> - %unicode|string%(4) "pubf" + ["name"]=> + string(1) "f" + ["class"]=> + string(4) "pubf" } --> Check for doesntExist(): Method doesntExist does not exist Reflecting on class subpubf: --> Check for f(): object(ReflectionMethod)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "f" - [%u|b%"class"]=> - %unicode|string%(4) "pubf" + ["name"]=> + string(1) "f" + ["class"]=> + string(4) "pubf" } --> Check for s(): object(ReflectionMethod)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "s" - [%u|b%"class"]=> - %unicode|string%(4) "pubf" + ["name"]=> + string(1) "s" + ["class"]=> + string(4) "pubf" } --> Check for F(): object(ReflectionMethod)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "f" - [%u|b%"class"]=> - %unicode|string%(4) "pubf" + ["name"]=> + string(1) "f" + ["class"]=> + string(4) "pubf" } --> Check for doesntExist(): Method doesntExist does not exist Reflecting on class protf: --> Check for f(): object(ReflectionMethod)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "f" - [%u|b%"class"]=> - %unicode|string%(5) "protf" + ["name"]=> + string(1) "f" + ["class"]=> + string(5) "protf" } --> Check for s(): object(ReflectionMethod)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "s" - [%u|b%"class"]=> - %unicode|string%(5) "protf" + ["name"]=> + string(1) "s" + ["class"]=> + string(5) "protf" } --> Check for F(): object(ReflectionMethod)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "f" - [%u|b%"class"]=> - %unicode|string%(5) "protf" + ["name"]=> + string(1) "f" + ["class"]=> + string(5) "protf" } --> Check for doesntExist(): Method doesntExist does not exist Reflecting on class subprotf: --> Check for f(): object(ReflectionMethod)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "f" - [%u|b%"class"]=> - %unicode|string%(5) "protf" + ["name"]=> + string(1) "f" + ["class"]=> + string(5) "protf" } --> Check for s(): object(ReflectionMethod)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "s" - [%u|b%"class"]=> - %unicode|string%(5) "protf" + ["name"]=> + string(1) "s" + ["class"]=> + string(5) "protf" } --> Check for F(): object(ReflectionMethod)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "f" - [%u|b%"class"]=> - %unicode|string%(5) "protf" + ["name"]=> + string(1) "f" + ["class"]=> + string(5) "protf" } --> Check for doesntExist(): Method doesntExist does not exist Reflecting on class privf: --> Check for f(): object(ReflectionMethod)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "f" - [%u|b%"class"]=> - %unicode|string%(5) "privf" + ["name"]=> + string(1) "f" + ["class"]=> + string(5) "privf" } --> Check for s(): object(ReflectionMethod)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "s" - [%u|b%"class"]=> - %unicode|string%(5) "privf" + ["name"]=> + string(1) "s" + ["class"]=> + string(5) "privf" } --> Check for F(): object(ReflectionMethod)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "f" - [%u|b%"class"]=> - %unicode|string%(5) "privf" + ["name"]=> + string(1) "f" + ["class"]=> + string(5) "privf" } --> Check for doesntExist(): Method doesntExist does not exist Reflecting on class subprivf: --> Check for f(): object(ReflectionMethod)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "f" - [%u|b%"class"]=> - %unicode|string%(5) "privf" + ["name"]=> + string(1) "f" + ["class"]=> + string(5) "privf" } --> Check for s(): object(ReflectionMethod)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "s" - [%u|b%"class"]=> - %unicode|string%(5) "privf" + ["name"]=> + string(1) "s" + ["class"]=> + string(5) "privf" } --> Check for F(): object(ReflectionMethod)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "f" - [%u|b%"class"]=> - %unicode|string%(5) "privf" + ["name"]=> + string(1) "f" + ["class"]=> + string(5) "privf" } --> Check for doesntExist(): Method doesntExist does not exist diff --git a/ext/reflection/tests/ReflectionClass_getMethods_001.phpt b/ext/reflection/tests/ReflectionClass_getMethods_001.phpt index 1e11dee2f3..7d4b6774c2 100644 --- a/ext/reflection/tests/ReflectionClass_getMethods_001.phpt +++ b/ext/reflection/tests/ReflectionClass_getMethods_001.phpt @@ -40,101 +40,101 @@ Reflecting on class pubf: array(2) { [0]=> object(ReflectionMethod)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "f" - [%u|b%"class"]=> - %unicode|string%(4) "pubf" + ["name"]=> + string(1) "f" + ["class"]=> + string(4) "pubf" } [1]=> object(ReflectionMethod)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "s" - [%u|b%"class"]=> - %unicode|string%(4) "pubf" + ["name"]=> + string(1) "s" + ["class"]=> + string(4) "pubf" } } Reflecting on class subpubf: array(2) { [0]=> object(ReflectionMethod)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "f" - [%u|b%"class"]=> - %unicode|string%(4) "pubf" + ["name"]=> + string(1) "f" + ["class"]=> + string(4) "pubf" } [1]=> object(ReflectionMethod)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "s" - [%u|b%"class"]=> - %unicode|string%(4) "pubf" + ["name"]=> + string(1) "s" + ["class"]=> + string(4) "pubf" } } Reflecting on class protf: array(2) { [0]=> object(ReflectionMethod)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "f" - [%u|b%"class"]=> - %unicode|string%(5) "protf" + ["name"]=> + string(1) "f" + ["class"]=> + string(5) "protf" } [1]=> object(ReflectionMethod)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "s" - [%u|b%"class"]=> - %unicode|string%(5) "protf" + ["name"]=> + string(1) "s" + ["class"]=> + string(5) "protf" } } Reflecting on class subprotf: array(2) { [0]=> object(ReflectionMethod)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "f" - [%u|b%"class"]=> - %unicode|string%(5) "protf" + ["name"]=> + string(1) "f" + ["class"]=> + string(5) "protf" } [1]=> object(ReflectionMethod)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "s" - [%u|b%"class"]=> - %unicode|string%(5) "protf" + ["name"]=> + string(1) "s" + ["class"]=> + string(5) "protf" } } Reflecting on class privf: array(2) { [0]=> object(ReflectionMethod)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "f" - [%u|b%"class"]=> - %unicode|string%(5) "privf" + ["name"]=> + string(1) "f" + ["class"]=> + string(5) "privf" } [1]=> object(ReflectionMethod)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "s" - [%u|b%"class"]=> - %unicode|string%(5) "privf" + ["name"]=> + string(1) "s" + ["class"]=> + string(5) "privf" } } Reflecting on class subprivf: array(2) { [0]=> object(ReflectionMethod)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "f" - [%u|b%"class"]=> - %unicode|string%(5) "privf" + ["name"]=> + string(1) "f" + ["class"]=> + string(5) "privf" } [1]=> object(ReflectionMethod)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "s" - [%u|b%"class"]=> - %unicode|string%(5) "privf" + ["name"]=> + string(1) "s" + ["class"]=> + string(5) "privf" } } diff --git a/ext/reflection/tests/ReflectionClass_getModifiers_basic.phpt b/ext/reflection/tests/ReflectionClass_getModifiers_basic.phpt index 68189db2bb..f77bbacda7 100644 --- a/ext/reflection/tests/ReflectionClass_getModifiers_basic.phpt +++ b/ext/reflection/tests/ReflectionClass_getModifiers_basic.phpt @@ -31,7 +31,7 @@ dump_modifiers('g'); int(0) int(32) int(4) -int(64) -int(524288) -int(524352) +int(0) +int(0) +int(0) int(0) diff --git a/ext/reflection/tests/ReflectionClass_getProperties_001.phpt b/ext/reflection/tests/ReflectionClass_getProperties_001.phpt index cd4a29d450..ed0b160b93 100644 --- a/ext/reflection/tests/ReflectionClass_getProperties_001.phpt +++ b/ext/reflection/tests/ReflectionClass_getProperties_001.phpt @@ -40,85 +40,85 @@ Reflecting on class pubf: array(2) { [0]=> object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "a" - [%u|b%"class"]=> - %unicode|string%(4) "pubf" + ["name"]=> + string(1) "a" + ["class"]=> + string(4) "pubf" } [1]=> object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "s" - [%u|b%"class"]=> - %unicode|string%(4) "pubf" + ["name"]=> + string(1) "s" + ["class"]=> + string(4) "pubf" } } Reflecting on class subpubf: array(2) { [0]=> object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "a" - [%u|b%"class"]=> - %unicode|string%(4) "pubf" + ["name"]=> + string(1) "a" + ["class"]=> + string(4) "pubf" } [1]=> object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "s" - [%u|b%"class"]=> - %unicode|string%(4) "pubf" + ["name"]=> + string(1) "s" + ["class"]=> + string(4) "pubf" } } Reflecting on class protf: array(2) { [0]=> object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "a" - [%u|b%"class"]=> - %unicode|string%(5) "protf" + ["name"]=> + string(1) "a" + ["class"]=> + string(5) "protf" } [1]=> object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "s" - [%u|b%"class"]=> - %unicode|string%(5) "protf" + ["name"]=> + string(1) "s" + ["class"]=> + string(5) "protf" } } Reflecting on class subprotf: array(2) { [0]=> object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "a" - [%u|b%"class"]=> - %unicode|string%(5) "protf" + ["name"]=> + string(1) "a" + ["class"]=> + string(5) "protf" } [1]=> object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "s" - [%u|b%"class"]=> - %unicode|string%(5) "protf" + ["name"]=> + string(1) "s" + ["class"]=> + string(5) "protf" } } Reflecting on class privf: array(2) { [0]=> object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "a" - [%u|b%"class"]=> - %unicode|string%(5) "privf" + ["name"]=> + string(1) "a" + ["class"]=> + string(5) "privf" } [1]=> object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "s" - [%u|b%"class"]=> - %unicode|string%(5) "privf" + ["name"]=> + string(1) "s" + ["class"]=> + string(5) "privf" } } Reflecting on class subprivf: diff --git a/ext/reflection/tests/ReflectionClass_getProperty_001.phpt b/ext/reflection/tests/ReflectionClass_getProperty_001.phpt index 9e174b749e..fca68ed30f 100644 --- a/ext/reflection/tests/ReflectionClass_getProperty_001.phpt +++ b/ext/reflection/tests/ReflectionClass_getProperty_001.phpt @@ -61,85 +61,85 @@ foreach($classes as $class) { --EXPECTF-- Reflecting on class pubf: --> Check for s: object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "s" - [%u|b%"class"]=> - %unicode|string%(4) "pubf" + ["name"]=> + string(1) "s" + ["class"]=> + string(4) "pubf" } --> Check for a: object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "a" - [%u|b%"class"]=> - %unicode|string%(4) "pubf" + ["name"]=> + string(1) "a" + ["class"]=> + string(4) "pubf" } --> Check for A: Property A does not exist --> Check for doesntExist: Property doesntExist does not exist Reflecting on class subpubf: --> Check for s: object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "s" - [%u|b%"class"]=> - %unicode|string%(4) "pubf" + ["name"]=> + string(1) "s" + ["class"]=> + string(4) "pubf" } --> Check for a: object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "a" - [%u|b%"class"]=> - %unicode|string%(4) "pubf" + ["name"]=> + string(1) "a" + ["class"]=> + string(4) "pubf" } --> Check for A: Property A does not exist --> Check for doesntExist: Property doesntExist does not exist Reflecting on class protf: --> Check for s: object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "s" - [%u|b%"class"]=> - %unicode|string%(5) "protf" + ["name"]=> + string(1) "s" + ["class"]=> + string(5) "protf" } --> Check for a: object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "a" - [%u|b%"class"]=> - %unicode|string%(5) "protf" + ["name"]=> + string(1) "a" + ["class"]=> + string(5) "protf" } --> Check for A: Property A does not exist --> Check for doesntExist: Property doesntExist does not exist Reflecting on class subprotf: --> Check for s: object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "s" - [%u|b%"class"]=> - %unicode|string%(5) "protf" + ["name"]=> + string(1) "s" + ["class"]=> + string(5) "protf" } --> Check for a: object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "a" - [%u|b%"class"]=> - %unicode|string%(5) "protf" + ["name"]=> + string(1) "a" + ["class"]=> + string(5) "protf" } --> Check for A: Property A does not exist --> Check for doesntExist: Property doesntExist does not exist Reflecting on class privf: --> Check for s: object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "s" - [%u|b%"class"]=> - %unicode|string%(5) "privf" + ["name"]=> + string(1) "s" + ["class"]=> + string(5) "privf" } --> Check for a: object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "a" - [%u|b%"class"]=> - %unicode|string%(5) "privf" + ["name"]=> + string(1) "a" + ["class"]=> + string(5) "privf" } --> Check for A: Property A does not exist --> Check for doesntExist: Property doesntExist does not exist Reflecting on class subprivf: --> Check for s: object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(1) "s" - [%u|b%"class"]=> - %unicode|string%(5) "privf" + ["name"]=> + string(1) "s" + ["class"]=> + string(5) "privf" } --> Check for a: Property a does not exist --> Check for A: Property A does not exist diff --git a/ext/reflection/tests/ReflectionClass_getProperty_003.phpt b/ext/reflection/tests/ReflectionClass_getProperty_003.phpt index 515d9860ba..16c0c306ba 100644 --- a/ext/reflection/tests/ReflectionClass_getProperty_003.phpt +++ b/ext/reflection/tests/ReflectionClass_getProperty_003.phpt @@ -97,146 +97,146 @@ showInfo("doesntexist::doesntExist"); --EXPECTF-- --- (Reflecting on pubA) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(4) "pubA" - [%u|b%"class"]=> - %unicode|string%(1) "A" + ["name"]=> + string(4) "pubA" + ["class"]=> + string(1) "A" } -%unicode|string%(9) "pubA in A" +string(9) "pubA in A" --- (Reflecting on protA) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(5) "protA" - [%u|b%"class"]=> - %unicode|string%(1) "A" + ["name"]=> + string(5) "protA" + ["class"]=> + string(1) "A" } Cannot access non-public member C::protA --- (Reflecting on privA) --- Property privA does not exist --- (Reflecting on pubB) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(4) "pubB" - [%u|b%"class"]=> - %unicode|string%(1) "B" + ["name"]=> + string(4) "pubB" + ["class"]=> + string(1) "B" } -%unicode|string%(9) "pubB in B" +string(9) "pubB in B" --- (Reflecting on protB) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(5) "protB" - [%u|b%"class"]=> - %unicode|string%(1) "B" + ["name"]=> + string(5) "protB" + ["class"]=> + string(1) "B" } Cannot access non-public member C::protB --- (Reflecting on privB) --- Property privB does not exist --- (Reflecting on pubC) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(4) "pubC" - [%u|b%"class"]=> - %unicode|string%(1) "C" + ["name"]=> + string(4) "pubC" + ["class"]=> + string(1) "C" } -%unicode|string%(9) "pubC in C" +string(9) "pubC in C" --- (Reflecting on protC) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(5) "protC" - [%u|b%"class"]=> - %unicode|string%(1) "C" + ["name"]=> + string(5) "protC" + ["class"]=> + string(1) "C" } Cannot access non-public member C::protC --- (Reflecting on privC) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(5) "privC" - [%u|b%"class"]=> - %unicode|string%(1) "C" + ["name"]=> + string(5) "privC" + ["class"]=> + string(1) "C" } Cannot access non-public member C::privC --- (Reflecting on doesntExist) --- Property doesntExist does not exist --- (Reflecting on A::pubC) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(4) "pubC" - [%u|b%"class"]=> - %unicode|string%(1) "A" + ["name"]=> + string(4) "pubC" + ["class"]=> + string(1) "A" } -%unicode|string%(9) "pubC in A" +string(9) "pubC in A" --- (Reflecting on A::protC) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(5) "protC" - [%u|b%"class"]=> - %unicode|string%(1) "A" + ["name"]=> + string(5) "protC" + ["class"]=> + string(1) "A" } Cannot access non-public member A::protC --- (Reflecting on A::privC) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(5) "privC" - [%u|b%"class"]=> - %unicode|string%(1) "A" + ["name"]=> + string(5) "privC" + ["class"]=> + string(1) "A" } Cannot access non-public member A::privC --- (Reflecting on B::pubC) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(4) "pubC" - [%u|b%"class"]=> - %unicode|string%(1) "B" + ["name"]=> + string(4) "pubC" + ["class"]=> + string(1) "B" } -%unicode|string%(9) "pubC in B" +string(9) "pubC in B" --- (Reflecting on B::protC) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(5) "protC" - [%u|b%"class"]=> - %unicode|string%(1) "B" + ["name"]=> + string(5) "protC" + ["class"]=> + string(1) "B" } Cannot access non-public member B::protC --- (Reflecting on B::privC) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(5) "privC" - [%u|b%"class"]=> - %unicode|string%(1) "B" + ["name"]=> + string(5) "privC" + ["class"]=> + string(1) "B" } Cannot access non-public member B::privC --- (Reflecting on c::pubC) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(4) "pubC" - [%u|b%"class"]=> - %unicode|string%(1) "C" + ["name"]=> + string(4) "pubC" + ["class"]=> + string(1) "C" } -%unicode|string%(9) "pubC in C" +string(9) "pubC in C" --- (Reflecting on c::PUBC) --- Property PUBC does not exist --- (Reflecting on C::pubC) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(4) "pubC" - [%u|b%"class"]=> - %unicode|string%(1) "C" + ["name"]=> + string(4) "pubC" + ["class"]=> + string(1) "C" } -%unicode|string%(9) "pubC in C" +string(9) "pubC in C" --- (Reflecting on C::protC) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(5) "protC" - [%u|b%"class"]=> - %unicode|string%(1) "C" + ["name"]=> + string(5) "protC" + ["class"]=> + string(1) "C" } Cannot access non-public member C::protC --- (Reflecting on C::privC) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(5) "privC" - [%u|b%"class"]=> - %unicode|string%(1) "C" + ["name"]=> + string(5) "privC" + ["class"]=> + string(1) "C" } Cannot access non-public member C::privC --- (Reflecting on X::pubC) --- diff --git a/ext/reflection/tests/ReflectionClass_getProperty_004.phpt b/ext/reflection/tests/ReflectionClass_getProperty_004.phpt index 1070d57ce4..89335f42c4 100644 --- a/ext/reflection/tests/ReflectionClass_getProperty_004.phpt +++ b/ext/reflection/tests/ReflectionClass_getProperty_004.phpt @@ -97,146 +97,146 @@ showInfo("doesntexist::doesntExist"); --EXPECTF-- --- (Reflecting on pubA) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(4) "pubA" - [%u|b%"class"]=> - %unicode|string%(1) "A" + ["name"]=> + string(4) "pubA" + ["class"]=> + string(1) "A" } -%unicode|string%(9) "pubA in A" +string(9) "pubA in A" --- (Reflecting on protA) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(5) "protA" - [%u|b%"class"]=> - %unicode|string%(1) "A" + ["name"]=> + string(5) "protA" + ["class"]=> + string(1) "A" } Cannot access non-public member C::protA --- (Reflecting on privA) --- Property privA does not exist --- (Reflecting on pubB) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(4) "pubB" - [%u|b%"class"]=> - %unicode|string%(1) "B" + ["name"]=> + string(4) "pubB" + ["class"]=> + string(1) "B" } -%unicode|string%(9) "pubB in B" +string(9) "pubB in B" --- (Reflecting on protB) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(5) "protB" - [%u|b%"class"]=> - %unicode|string%(1) "B" + ["name"]=> + string(5) "protB" + ["class"]=> + string(1) "B" } Cannot access non-public member C::protB --- (Reflecting on privB) --- Property privB does not exist --- (Reflecting on pubC) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(4) "pubC" - [%u|b%"class"]=> - %unicode|string%(1) "C" + ["name"]=> + string(4) "pubC" + ["class"]=> + string(1) "C" } -%unicode|string%(9) "pubC in C" +string(9) "pubC in C" --- (Reflecting on protC) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(5) "protC" - [%u|b%"class"]=> - %unicode|string%(1) "C" + ["name"]=> + string(5) "protC" + ["class"]=> + string(1) "C" } Cannot access non-public member C::protC --- (Reflecting on privC) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(5) "privC" - [%u|b%"class"]=> - %unicode|string%(1) "C" + ["name"]=> + string(5) "privC" + ["class"]=> + string(1) "C" } Cannot access non-public member C::privC --- (Reflecting on doesntExist) --- Property doesntExist does not exist --- (Reflecting on A::pubC) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(4) "pubC" - [%u|b%"class"]=> - %unicode|string%(1) "A" + ["name"]=> + string(4) "pubC" + ["class"]=> + string(1) "A" } -%unicode|string%(9) "pubC in C" +string(9) "pubC in C" --- (Reflecting on A::protC) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(5) "protC" - [%u|b%"class"]=> - %unicode|string%(1) "A" + ["name"]=> + string(5) "protC" + ["class"]=> + string(1) "A" } Cannot access non-public member A::protC --- (Reflecting on A::privC) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(5) "privC" - [%u|b%"class"]=> - %unicode|string%(1) "A" + ["name"]=> + string(5) "privC" + ["class"]=> + string(1) "A" } Cannot access non-public member A::privC --- (Reflecting on B::pubC) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(4) "pubC" - [%u|b%"class"]=> - %unicode|string%(1) "B" + ["name"]=> + string(4) "pubC" + ["class"]=> + string(1) "B" } -%unicode|string%(9) "pubC in C" +string(9) "pubC in C" --- (Reflecting on B::protC) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(5) "protC" - [%u|b%"class"]=> - %unicode|string%(1) "B" + ["name"]=> + string(5) "protC" + ["class"]=> + string(1) "B" } Cannot access non-public member B::protC --- (Reflecting on B::privC) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(5) "privC" - [%u|b%"class"]=> - %unicode|string%(1) "B" + ["name"]=> + string(5) "privC" + ["class"]=> + string(1) "B" } Cannot access non-public member B::privC --- (Reflecting on c::pubC) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(4) "pubC" - [%u|b%"class"]=> - %unicode|string%(1) "C" + ["name"]=> + string(4) "pubC" + ["class"]=> + string(1) "C" } -%unicode|string%(9) "pubC in C" +string(9) "pubC in C" --- (Reflecting on c::PUBC) --- Property PUBC does not exist --- (Reflecting on C::pubC) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(4) "pubC" - [%u|b%"class"]=> - %unicode|string%(1) "C" + ["name"]=> + string(4) "pubC" + ["class"]=> + string(1) "C" } -%unicode|string%(9) "pubC in C" +string(9) "pubC in C" --- (Reflecting on C::protC) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(5) "protC" - [%u|b%"class"]=> - %unicode|string%(1) "C" + ["name"]=> + string(5) "protC" + ["class"]=> + string(1) "C" } Cannot access non-public member C::protC --- (Reflecting on C::privC) --- object(ReflectionProperty)#%d (2) { - [%u|b%"name"]=> - %unicode|string%(5) "privC" - [%u|b%"class"]=> - %unicode|string%(1) "C" + ["name"]=> + string(5) "privC" + ["class"]=> + string(1) "C" } Cannot access non-public member C::privC --- (Reflecting on X::pubC) --- diff --git a/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_001.phpt b/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_001.phpt index ffd81ffb87..ab8afb8cb9 100644 --- a/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_001.phpt +++ b/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_001.phpt @@ -3,8 +3,6 @@ ReflectionClass::getStaticPropertyValue() --CREDITS-- Robin Fernandes <robinf@php.net> Steve Seear <stevseea@php.net> ---SKIPIF-- -<?php if (version_compare(zend_version(), '2.4.0', '>=')) die('skip ZendEngine 2.3 or below needed'); ?> --FILE-- <?php class A { @@ -53,17 +51,9 @@ try { --EXPECTF-- Retrieving static values from A: string(13) "default value" -string(16) "original private" -string(13) "default value" -string(18) "original protected" -string(15) "original public" - -Retrieving static values from B: -string(16) "original private" -string(15) "changed private" -string(17) "changed protected" -string(14) "changed public" -Retrieving non-existent values from A with no default value: -Class A does not have a property named protectedOverridden -Class A does not have a property named privateOverridden +Fatal error: Uncaught ReflectionException: Class A does not have a property named in %s:%d +Stack trace: +#0 %s(%d): ReflectionClass->getStaticPropertyValue('\x00A\x00privateOverr...') +#1 {main} + thrown in %s on line %d diff --git a/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_001_2_4.phpt b/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_001_2_4.phpt deleted file mode 100644 index 02f7595cb4..0000000000 --- a/ext/reflection/tests/ReflectionClass_getStaticPropertyValue_001_2_4.phpt +++ /dev/null @@ -1,61 +0,0 @@ ---TEST-- -ReflectionClass::getStaticPropertyValue() ---CREDITS-- -Robin Fernandes <robinf@php.net> -Steve Seear <stevseea@php.net> ---SKIPIF-- -<?php if (version_compare(zend_version(), '2.4.0', '<')) die('skip ZendEngine 2.4 needed'); ?> ---FILE-- -<?php -class A { - static private $privateOverridden = "original private"; - static protected $protectedOverridden = "original protected"; - static public $publicOverridden = "original public"; -} - -class B extends A { - static private $privateOverridden = "changed private"; - static protected $protectedOverridden = "changed protected"; - static public $publicOverridden = "changed public"; -} - -echo "Retrieving static values from A:\n"; -$rcA = new ReflectionClass('A'); -var_dump($rcA->getStaticPropertyValue("privateOverridden", "default value")); -var_dump($rcA->getStaticPropertyValue("\0A\0privateOverridden")); -var_dump($rcA->getStaticPropertyValue("protectedOverridden", "default value")); -var_dump($rcA->getStaticPropertyValue("\0*\0protectedOverridden")); -var_dump($rcA->getStaticPropertyValue("publicOverridden")); - -echo "\nRetrieving static values from B:\n"; -$rcB = new ReflectionClass('B'); -var_dump($rcB->getStaticPropertyValue("\0A\0privateOverridden")); -var_dump($rcB->getStaticPropertyValue("\0B\0privateOverridden")); -var_dump($rcB->getStaticPropertyValue("\0*\0protectedOverridden")); -var_dump($rcB->getStaticPropertyValue("publicOverridden")); - -echo "\nRetrieving non-existent values from A with no default value:\n"; -try { - var_dump($rcA->getStaticPropertyValue("protectedOverridden")); - echo "you should not see this"; -} catch (Exception $e) { - echo $e->getMessage() . "\n"; -} - -try { - var_dump($rcA->getStaticPropertyValue("privateOverridden")); - echo "you should not see this"; -} catch (Exception $e) { - echo $e->getMessage() . "\n"; -} - -?> ---EXPECTF-- -Retrieving static values from A: -string(13) "default value" - -Fatal error: Uncaught ReflectionException: Class A does not have a property named in %sReflectionClass_getStaticPropertyValue_001_2_4.php:%d -Stack trace: -#0 %sReflectionClass_getStaticPropertyValue_001_2_4.php(%d): ReflectionClass->getStaticPropertyValue('\x00A\x00privateOverr...') -#1 {main} - thrown in %sReflectionClass_getStaticPropertyValue_001_2_4.php on line %d diff --git a/ext/reflection/tests/ReflectionClass_modifiers_001.phpt b/ext/reflection/tests/ReflectionClass_modifiers_001.phpt index 7f62b565a2..a1464a5ab9 100644 --- a/ext/reflection/tests/ReflectionClass_modifiers_001.phpt +++ b/ext/reflection/tests/ReflectionClass_modifiers_001.phpt @@ -41,4 +41,4 @@ int(4) bool(false) bool(true) bool(false) -int(64)
\ No newline at end of file +int(0) diff --git a/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001.phpt b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001.phpt index 9e8f01e679..0004f3ff5a 100644 --- a/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001.phpt +++ b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001.phpt @@ -3,8 +3,6 @@ ReflectionClass::setStaticPropertyValue() --CREDITS-- Robin Fernandes <robinf@php.net> Steve Seear <stevseea@php.net> ---SKIPIF-- -<?php if (version_compare(zend_version(), '2.4.0', '>=')) die('skip ZendEngine 2.3 or below needed'); ?> --FILE-- <?php class A { @@ -53,27 +51,9 @@ try { ?> --EXPECTF-- Set static values in A: -Array -( - [privateOverridden] => new value 1 - [protectedOverridden] => new value 2 - [publicOverridden] => new value 3 -) -Set static values in B: -Array -( - [privateOverridden] => new value 4 - [protectedOverridden] => new value 2 - [publicOverridden] => new value 3 -) -Array -( - [privateOverridden] => new value 5 - [protectedOverridden] => new value 6 - [publicOverridden] => new value 7 -) - -Set non-existent values from A with no default value: -Class A does not have a property named protectedOverridden -Class A does not have a property named privateOverridden +Fatal error: Uncaught ReflectionException: Class A does not have a property named in %s:%d +Stack trace: +#0 %s(%d): ReflectionClass->setStaticPropertyValue('\x00A\x00privateOverr...', 'new value 1') +#1 {main} + thrown in %s on line %d diff --git a/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001_2_4.phpt b/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001_2_4.phpt deleted file mode 100644 index 6720d2daa2..0000000000 --- a/ext/reflection/tests/ReflectionClass_setStaticPropertyValue_001_2_4.phpt +++ /dev/null @@ -1,61 +0,0 @@ ---TEST-- -ReflectionClass::setStaticPropertyValue() ---CREDITS-- -Robin Fernandes <robinf@php.net> -Steve Seear <stevseea@php.net> ---SKIPIF-- -<?php if (version_compare(zend_version(), '2.4.0', '<')) die('skip ZendEngine 2.4 needed'); ?> ---FILE-- -<?php -class A { - static private $privateOverridden = "original private"; - static protected $protectedOverridden = "original protected"; - static public $publicOverridden = "original public"; -} - -class B extends A { - static private $privateOverridden = "changed private"; - static protected $protectedOverridden = "changed protected"; - static public $publicOverridden = "changed public"; -} - -echo "Set static values in A:\n"; -$rcA = new ReflectionClass('A'); -$rcA->setStaticPropertyValue("\0A\0privateOverridden", "new value 1"); -$rcA->setStaticPropertyValue("\0*\0protectedOverridden", "new value 2"); -$rcA->setStaticPropertyValue("publicOverridden", "new value 3"); -print_r($rcA->getStaticProperties()); - -echo "\nSet static values in B:\n"; -$rcB = new ReflectionClass('B'); -$rcB->setStaticPropertyValue("\0A\0privateOverridden", "new value 4"); -$rcB->setStaticPropertyValue("\0B\0privateOverridden", "new value 5"); -$rcB->setStaticPropertyValue("\0*\0protectedOverridden", "new value 6"); -$rcB->setStaticPropertyValue("publicOverridden", "new value 7"); -print_r($rcA->getStaticProperties()); -print_r($rcB->getStaticProperties()); - -echo "\nSet non-existent values from A with no default value:\n"; -try { - var_dump($rcA->setStaticPropertyValue("protectedOverridden", "new value 8")); - echo "you should not see this"; -} catch (Exception $e) { - echo $e->getMessage() . "\n"; -} - -try { - var_dump($rcA->setStaticPropertyValue("privateOverridden", "new value 9")); - echo "you should not see this"; -} catch (Exception $e) { - echo $e->getMessage() . "\n"; -} - -?> ---EXPECTF-- -Set static values in A: - -Fatal error: Uncaught ReflectionException: Class A does not have a property named in %sReflectionClass_setStaticPropertyValue_001_2_4.php:%d -Stack trace: -#0 %sReflectionClass_setStaticPropertyValue_001_2_4.php(%d): ReflectionClass->setStaticPropertyValue('\x00A\x00privateOverr...', 'new value 1') -#1 {main} - thrown in %sReflectionClass_setStaticPropertyValue_001_2_4.php on line %d diff --git a/ext/reflection/tests/ReflectionClass_toString_001.phpt b/ext/reflection/tests/ReflectionClass_toString_001.phpt index 29d58420e3..5a2b497905 100644 --- a/ext/reflection/tests/ReflectionClass_toString_001.phpt +++ b/ext/reflection/tests/ReflectionClass_toString_001.phpt @@ -34,7 +34,7 @@ Class [ <internal:Reflection> class ReflectionClass implements Reflector ] { Property [ <default> public $name ] } - - Methods [52] { + - Methods [53] { Method [ <internal:Reflection> final private method __clone ] { - Parameters [0] { @@ -265,7 +265,7 @@ Class [ <internal:Reflection> class ReflectionClass implements Reflector ] { Method [ <internal:Reflection> public method newInstance ] { - Parameters [1] { - Parameter #0 [ <required> $args ] + Parameter #0 [ <optional> ...$args ] } } @@ -323,6 +323,12 @@ Class [ <internal:Reflection> class ReflectionClass implements Reflector ] { } } + Method [ <internal:Reflection> public method isIterable ] { + + - Parameters [0] { + } + } + Method [ <internal:Reflection> public method isIterateable ] { - Parameters [0] { diff --git a/ext/reflection/tests/ReflectionFunction_getClosureScopeClass.phpt b/ext/reflection/tests/ReflectionFunction_getClosureScopeClass.phpt index f725dfd088..e32790c923 100644 --- a/ext/reflection/tests/ReflectionFunction_getClosureScopeClass.phpt +++ b/ext/reflection/tests/ReflectionFunction_getClosureScopeClass.phpt @@ -2,9 +2,7 @@ Reflection::getClosureScopeClass() --SKIPIF-- <?php -if (!extension_loaded('reflection') || !defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50399) { - print 'skip'; -} +if (!extension_loaded('reflection')) print 'skip'; ?> --FILE-- <?php diff --git a/ext/reflection/tests/ReflectionFunction_getClosureThis.phpt b/ext/reflection/tests/ReflectionFunction_getClosureThis.phpt index 776bfafee0..4795025798 100644 --- a/ext/reflection/tests/ReflectionFunction_getClosureThis.phpt +++ b/ext/reflection/tests/ReflectionFunction_getClosureThis.phpt @@ -2,9 +2,7 @@ Reflection::getClosureThis() --SKIPIF-- <?php -if (!extension_loaded('reflection') || !defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50300) { - print 'skip'; -} +if (!extension_loaded('reflection')) print 'skip'; ?> --FILE-- <?php diff --git a/ext/reflection/tests/ReflectionFunction_isClosure_basic.phpt b/ext/reflection/tests/ReflectionFunction_isClosure_basic.phpt index 368464e130..df101fcd3e 100644 --- a/ext/reflection/tests/ReflectionFunction_isClosure_basic.phpt +++ b/ext/reflection/tests/ReflectionFunction_isClosure_basic.phpt @@ -5,9 +5,7 @@ Stefan Koopmanschap <stefan@phpgg.nl> TestFest PHP|Tek --SKIPIF-- <?php -if (!extension_loaded('reflection') || !defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50300) { - print 'skip'; -} +if (!extension_loaded('reflection')) print 'skip'; ?> --FILE-- <?php diff --git a/ext/reflection/tests/ReflectionMethod_getClosureThis.phpt b/ext/reflection/tests/ReflectionMethod_getClosureThis.phpt index 58c09994cf..536f40c2e1 100644 --- a/ext/reflection/tests/ReflectionMethod_getClosureThis.phpt +++ b/ext/reflection/tests/ReflectionMethod_getClosureThis.phpt @@ -2,9 +2,7 @@ Reflection::getClosureThis() --SKIPIF-- <?php -if (!extension_loaded('reflection') || !defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50300) { - print 'skip'; -} +if (!extension_loaded('reflection')) print 'skip'; ?> --FILE-- <?php diff --git a/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt b/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt index 72baa53fda..55aea10763 100644 --- a/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt +++ b/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt @@ -87,156 +87,156 @@ printf("0x%08x\n", $a->getModifiers()); ?> --EXPECTF-- Modifiers for method TestClass::foo(): -0x08010100 +0x00000100 Modifiers for method TestClass::stat(): -0x08000101 +0x00000101 Modifiers for method TestClass::priv(): -0x08010400 +0x00000400 Modifiers for method TestClass::prot(): -0x08010200 +0x00000200 Modifiers for method TestClass::fin(): -0x08010104 +0x00000104 Modifiers for method TestClass::__destruct(): -0x08004100 +0x00000100 Modifiers for method TestClass::__call(): -0x08000100 +0x00000100 Modifiers for method TestClass::__clone(): -0x08008100 +0x00000100 Modifiers for method TestClass::__get(): -0x08000100 +0x00000100 Modifiers for method TestClass::__set(): -0x08000100 +0x00000100 Modifiers for method TestClass::__unset(): -0x08000100 +0x00000100 Modifiers for method TestClass::__isset(): -0x08000100 +0x00000100 Modifiers for method TestClass::__tostring(): -0x08000100 +0x00000100 Modifiers for method TestClass::__sleep(): -0x08010100 +0x00000100 Modifiers for method TestClass::__wakeup(): -0x08010100 +0x00000100 Modifiers for method TestClass::__set_state(): -0x08010100 +0x00000100 Modifiers for method TestClass::__autoload(): -0x08010100 +0x00000100 Modifiers for method TestClass::foo(): -0x08010100 +0x00000100 Modifiers for method TestClass::stat(): -0x08000101 +0x00000101 Modifiers for method TestClass::priv(): -0x08010400 +0x00000400 Modifiers for method TestClass::prot(): -0x08010200 +0x00000200 Modifiers for method TestClass::fin(): -0x08010104 +0x00000104 Modifiers for method TestClass::__destruct(): -0x08004100 +0x00000100 Modifiers for method TestClass::__call(): -0x08000100 +0x00000100 Modifiers for method TestClass::__clone(): -0x08008100 +0x00000100 Modifiers for method TestClass::__get(): -0x08000100 +0x00000100 Modifiers for method TestClass::__set(): -0x08000100 +0x00000100 Modifiers for method TestClass::__unset(): -0x08000100 +0x00000100 Modifiers for method TestClass::__isset(): -0x08000100 +0x00000100 Modifiers for method TestClass::__tostring(): -0x08000100 +0x00000100 Modifiers for method TestClass::__sleep(): -0x08010100 +0x00000100 Modifiers for method TestClass::__wakeup(): -0x08010100 +0x00000100 Modifiers for method TestClass::__set_state(): -0x08010100 +0x00000100 Modifiers for method TestClass::__autoload(): -0x08010100 +0x00000100 Modifiers for method TestInterface::int(): -0x08000102 +0x00000102 Modifiers for method TestInterface::__clone(): -0x08000102 +0x00000102 Modifiers for method AbstractClass::foo(): -0x08010102 +0x00000102 Wrong number of params: -Warning: ReflectionMethod::getModifiers() expects exactly 0 parameters, 1 given in %sReflectionMethod_getModifiers_basic.php on line %d +Warning: ReflectionMethod::getModifiers() expects exactly 0 parameters, 1 given in %s on line %d ReflectionMethod::getModifiers() modifiers: 0x00000100 diff --git a/ext/reflection/tests/ReflectionParameter_canBePassedByValue.phpt b/ext/reflection/tests/ReflectionParameter_canBePassedByValue.phpt index 5655d19972..942bea2dc2 100644 --- a/ext/reflection/tests/ReflectionParameter_canBePassedByValue.phpt +++ b/ext/reflection/tests/ReflectionParameter_canBePassedByValue.phpt @@ -1,76 +1,76 @@ ---TEST--
-ReflectionParameter class - canBePassedByValue() method.
---FILE--
-<?php
-
-function aux($fun) {
-
- $func = new ReflectionFunction($fun);
- $parameters = $func->getParameters();
- foreach($parameters as $parameter) {
- echo "Name: ", $parameter->getName(), "\n";
- echo "Is passed by reference: ", $parameter->isPassedByReference()?"yes":"no", "\n";
- echo "Can be passed by value: ", $parameter->canBePassedByValue()?"yes":"no", "\n";
- echo "\n";
- }
-
-}
-
-echo "=> array_multisort:\n\n";
-
-aux('array_multisort');
-
-
-echo "=> sort:\n\n";
-
-aux('sort');
-
-echo "=> user function:\n\n";
-
-function ufunc(&$arg1, $arg2) {}
-
-aux('ufunc');
-
-echo "Done.\n";
-
-?>
---EXPECTF--
-=> array_multisort:
-
-Name: arr1
-Is passed by reference: yes
-Can be passed by value: yes
-
-Name: sort_order
-Is passed by reference: yes
-Can be passed by value: yes
-
-Name: sort_flags
-Is passed by reference: yes
-Can be passed by value: yes
-
-Name: arr2
-Is passed by reference: yes
-Can be passed by value: yes
-
-=> sort:
-
-Name: arg
-Is passed by reference: yes
-Can be passed by value: no
-
-Name: sort_flags
-Is passed by reference: no
-Can be passed by value: yes
-
-=> user function:
-
-Name: arg1
-Is passed by reference: yes
-Can be passed by value: no
-
-Name: arg2
-Is passed by reference: no
-Can be passed by value: yes
-
-Done.
+--TEST-- +ReflectionParameter class - canBePassedByValue() method. +--FILE-- +<?php + +function aux($fun) { + + $func = new ReflectionFunction($fun); + $parameters = $func->getParameters(); + foreach($parameters as $parameter) { + echo "Name: ", $parameter->getName(), "\n"; + echo "Is passed by reference: ", $parameter->isPassedByReference()?"yes":"no", "\n"; + echo "Can be passed by value: ", $parameter->canBePassedByValue()?"yes":"no", "\n"; + echo "\n"; + } + +} + +echo "=> array_multisort:\n\n"; + +aux('array_multisort'); + + +echo "=> sort:\n\n"; + +aux('sort'); + +echo "=> user function:\n\n"; + +function ufunc(&$arg1, $arg2) {} + +aux('ufunc'); + +echo "Done.\n"; + +?> +--EXPECTF-- +=> array_multisort: + +Name: arr1 +Is passed by reference: yes +Can be passed by value: yes + +Name: sort_order +Is passed by reference: yes +Can be passed by value: yes + +Name: sort_flags +Is passed by reference: yes +Can be passed by value: yes + +Name: arr2 +Is passed by reference: yes +Can be passed by value: yes + +=> sort: + +Name: arg +Is passed by reference: yes +Can be passed by value: no + +Name: sort_flags +Is passed by reference: no +Can be passed by value: yes + +=> user function: + +Name: arg1 +Is passed by reference: yes +Can be passed by value: no + +Name: arg2 +Is passed by reference: no +Can be passed by value: yes + +Done. diff --git a/ext/reflection/tests/ReflectionParameter_isDefault.phpt b/ext/reflection/tests/ReflectionParameter_isDefault.phpt index 657077093b..d8b4f0edc0 100644 --- a/ext/reflection/tests/ReflectionParameter_isDefault.phpt +++ b/ext/reflection/tests/ReflectionParameter_isDefault.phpt @@ -1,34 +1,34 @@ ---TEST--
-ReflectionParameter::isDefault()
---FILE--
-<?php
-class A {
-public $defprop;
-}
-$a = new A;
-$a->myprop = null;
-
-$ro = new ReflectionObject($a);
-$props = $ro->getProperties();
-$prop1 = $props[0];
-var_dump($prop1->isDefault());
-$prop2 = $props[1];
-var_dump($prop2->isDefault());
-
-var_dump($ro->getProperty('defprop')->isDefault());
-var_dump($ro->getProperty('myprop')->isDefault());
-
-$prop1 = new ReflectionProperty($a, 'defprop');
-$prop2 = new ReflectionProperty($a, 'myprop');
-var_dump($prop1->isDefault());
-var_dump($prop2->isDefault());
-?>
-==DONE==
---EXPECT--
-bool(true)
-bool(false)
-bool(true)
-bool(false)
-bool(true)
-bool(false)
-==DONE==
+--TEST-- +ReflectionParameter::isDefault() +--FILE-- +<?php +class A { +public $defprop; +} +$a = new A; +$a->myprop = null; + +$ro = new ReflectionObject($a); +$props = $ro->getProperties(); +$prop1 = $props[0]; +var_dump($prop1->isDefault()); +$prop2 = $props[1]; +var_dump($prop2->isDefault()); + +var_dump($ro->getProperty('defprop')->isDefault()); +var_dump($ro->getProperty('myprop')->isDefault()); + +$prop1 = new ReflectionProperty($a, 'defprop'); +$prop2 = new ReflectionProperty($a, 'myprop'); +var_dump($prop1->isDefault()); +var_dump($prop2->isDefault()); +?> +==DONE== +--EXPECT-- +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +==DONE== diff --git a/ext/reflection/tests/ReflectionProperty_getModifiers_basic.phpt b/ext/reflection/tests/ReflectionProperty_getModifiers_basic.phpt index 0d1b6bd13a..38137551fc 100644 --- a/ext/reflection/tests/ReflectionProperty_getModifiers_basic.phpt +++ b/ext/reflection/tests/ReflectionProperty_getModifiers_basic.phpt @@ -37,10 +37,10 @@ D::a1: int(256) C::a2: int(512) D::a2: int(512) C::a3: int(1024) -D::a3: int(3072) +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(3073) +D::a6: int(1025) diff --git a/ext/reflection/tests/bug26640.phpt b/ext/reflection/tests/bug26640.phpt index e375fd4f89..8a93d72247 100644 --- a/ext/reflection/tests/bug26640.phpt +++ b/ext/reflection/tests/bug26640.phpt @@ -3,8 +3,7 @@ Reflection Bug #26640 (__autoload() not invoked by Reflection classes) --FILE-- <?php -function __autoload($c) -{ +spl_autoload_register(function ($c) { class autoload_class { public function __construct() @@ -12,7 +11,7 @@ function __autoload($c) print "autoload success\n"; } } -} +}); $a = new ReflectionClass('autoload_class'); diff --git a/ext/reflection/tests/bug29268.phpt b/ext/reflection/tests/bug29268.phpt index d8efc0b06e..0ab7e332b2 100644 --- a/ext/reflection/tests/bug29268.phpt +++ b/ext/reflection/tests/bug29268.phpt @@ -2,10 +2,10 @@ Reflection Bug #29268 (__autoload() not called with reflectionProperty->getClass()) --FILE-- <?php -function __autoload($classname) { +spl_autoload_register(function ($classname) { echo "__autoload($classname)\n"; eval("class $classname {}"); -} +}); class B{ public function doit(A $a){ diff --git a/ext/reflection/tests/bug61388.phpt b/ext/reflection/tests/bug61388.phpt index 75c0300151..3d6dc83fa0 100644 --- a/ext/reflection/tests/bug61388.phpt +++ b/ext/reflection/tests/bug61388.phpt @@ -25,6 +25,12 @@ Array ( [0] => ReflectionProperty Object ( + [name] => 0 + [class] => stdClass + ) + + [1] => ReflectionProperty Object + ( [name] => oo [class] => stdClass ) diff --git a/ext/reflection/tests/bug74035.phpt b/ext/reflection/tests/bug74035.phpt new file mode 100644 index 0000000000..74cf03f5e5 --- /dev/null +++ b/ext/reflection/tests/bug74035.phpt @@ -0,0 +1,11 @@ +--TEST-- +Bug #74035: getNumberOfRequiredParameters wrong for ReflectionClass::newInstance +--FILE-- +<?php +$r = new ReflectionClass(ReflectionClass::class); +$m = $r->getMethod('newInstance'); + +echo $m->getNumberOfRequiredParameters(); +?> +--EXPECT-- +0 |