diff options
author | Stanislav Malyshev <stas@php.net> | 2011-05-15 00:36:13 +0000 |
---|---|---|
committer | Stanislav Malyshev <stas@php.net> | 2011-05-15 00:36:13 +0000 |
commit | 516c2f5920391239d4bfa2126ab772d5f712f8ba (patch) | |
tree | f490bd54fb738507db485d47ec756fd2e3872966 /ext/reflection/php_reflection.c | |
parent | 41dbe394710a99f98b2acd8637a741b702025ce4 (diff) | |
download | php-git-516c2f5920391239d4bfa2126ab772d5f712f8ba.tar.gz |
removing scalar types in trunk
Diffstat (limited to 'ext/reflection/php_reflection.c')
-rw-r--r-- | ext/reflection/php_reflection.c | 388 |
1 files changed, 143 insertions, 245 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 874dff2c60..8eb7af24b5 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -125,7 +125,7 @@ static void string_init(string *str) str->alloced = 1024; *str->string = '\0'; } - + static string *string_printf(string *str, const char *format, ...) { int len; @@ -358,7 +358,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in { 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); @@ -397,7 +397,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in } if (ce->ce_flags & ZEND_ACC_FINAL_CLASS) { string_printf(str, "final "); - } + } string_printf(str, "class "); } string_printf(str, "%s", ce->name); @@ -452,7 +452,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in /* Static properties */ if (&ce->properties_info) { - /* counting static properties */ + /* counting static properties */ count = zend_hash_num_elements(&ce->properties_info); if (count > 0) { HashPosition pos; @@ -470,7 +470,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in } } - /* static properties */ + /* static properties */ string_printf(str, "\n%s - Static properties [%d] {\n", indent, count_static_props); if (count_static_props > 0) { HashPosition pos; @@ -488,10 +488,10 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in } string_printf(str, "%s }\n", indent); } - + /* Static methods */ if (&ce->function_table) { - /* counting static methods */ + /* counting static methods */ count = zend_hash_num_elements(&ce->function_table); if (count > 0) { HashPosition pos; @@ -509,7 +509,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in } } - /* static methods */ + /* static methods */ string_printf(str, "\n%s - Static methods [%d] {", indent, count_static_funcs); if (count_static_funcs > 0) { HashPosition pos; @@ -573,7 +573,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in if (prop_name_size && prop_name[0]) { /* skip all private and protected properties */ if (!zend_hash_quick_exists(&ce->properties_info, prop_name, prop_name_size, zend_get_hash_value(prop_name, prop_name_size))) { count++; - _property_string(&dyn, NULL, prop_name, sub_indent.string TSRMLS_CC); + _property_string(&dyn, NULL, prop_name, sub_indent.string TSRMLS_CC); } } efree(prop_name); @@ -644,7 +644,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in } string_printf(str, "%s }\n", indent); } - + string_printf(str, "%s}\n", indent); string_free(&sub_indent); } @@ -825,7 +825,7 @@ static void _function_string(string *str, zend_function *fptr, zend_class_entry unsigned int lc_name_len; /* TBD: Repair indenting of doc comment (or is this to be done in the parser?) - * What's "wrong" is that any whitespace before the doc comment start is + * What's "wrong" is that any whitespace before the doc comment start is * swallowed, leading to an unaligned comment. */ if (fptr->type == ZEND_USER_FUNCTION && fptr->op_array.doc_comment) { @@ -904,7 +904,7 @@ static void _function_string(string *str, zend_function *fptr, zend_class_entry string_printf(str, "%s ] {\n", 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, + string_printf(str, "%s @@ %s %d - %d\n", indent, fptr->op_array.filename, fptr->op_array.line_start, fptr->op_array.line_end); @@ -936,7 +936,7 @@ static void _property_string(string *str, zend_property_info *prop, char *prop_n string_write(str, "<default> ", sizeof("<default> ") - 1); } } - + /* These are mutually exclusive */ switch (prop->flags & ZEND_ACC_PPP_MASK) { case ZEND_ACC_PUBLIC: @@ -1049,7 +1049,7 @@ static void _extension_string(string *str, zend_module_entry *module, char *inde while(dep->name) { string_printf(str, "%s Dependency [ %s (", indent, dep->name); - + switch(dep->type) { case MODULE_DEP_REQUIRED: string_write(str, "Required", sizeof("Required") - 1); @@ -1065,10 +1065,10 @@ static void _extension_string(string *str, zend_module_entry *module, char *inde break; } - if (dep->rel) { + if (dep->rel) { string_printf(str, " %s", dep->rel); } - if (dep->version) { + if (dep->version) { string_printf(str, " %s", dep->version); } string_write(str, ") ]\n", sizeof(") ]\n") - 1); @@ -1092,7 +1092,7 @@ static void _extension_string(string *str, zend_module_entry *module, char *inde { string str_constants; int num_constants = 0; - + string_init(&str_constants); zend_hash_apply_with_arguments(EG(zend_constants) TSRMLS_CC, (apply_func_args_t) _extension_const_string, 4, &str_constants, indent, module, &num_constants); if (num_constants) { @@ -1116,18 +1116,18 @@ static void _extension_string(string *str, zend_module_entry *module, char *inde func++; continue; } - + _function_string(str, fptr, NULL, " " TSRMLS_CC); func++; } string_printf(str, "%s }\n", indent); } - + { string str_classes; string sub_indent; int num_classes = 0; - + string_init(&sub_indent); string_printf(&sub_indent, "%s ", indent); string_init(&str_classes); @@ -1403,7 +1403,7 @@ static void _reflection_export(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry *c fcc.object_ptr = reflector_ptr; result = zend_call_function(&fci, &fcc TSRMLS_CC); - + if (retval_ptr) { zval_ptr_dtor(&retval_ptr); } @@ -1578,10 +1578,10 @@ ZEND_METHOD(reflection_function, __construct) nsname = &lcname[1]; name_len--; } - + if (zend_hash_find(EG(function_table), nsname, name_len + 1, (void **)&fptr) == FAILURE) { efree(lcname); - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Function %s() does not exist", name_str); return; } @@ -1671,7 +1671,7 @@ ZEND_METHOD(reflection_function, getClosure) { reflection_object *intern; zend_function *fptr; - + if (zend_parse_parameters_none() == FAILURE) { return; } @@ -1804,7 +1804,7 @@ ZEND_METHOD(reflection_function, getStaticVariables) zval *tmp_copy; reflection_object *intern; zend_function *fptr; - + if (zend_parse_parameters_none() == FAILURE) { return; } @@ -1830,7 +1830,7 @@ ZEND_METHOD(reflection_function, invoke) zend_fcall_info_cache fcc; reflection_object *intern; zend_function *fptr; - + METHOD_NOTSTATIC(reflection_function_ptr); GET_REFLECTION_OBJECT_PTR(fptr); @@ -1861,7 +1861,7 @@ ZEND_METHOD(reflection_function, invoke) } if (result == FAILURE) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Invocation of function %s() failed", fptr->common.function_name); return; } @@ -1891,7 +1891,7 @@ ZEND_METHOD(reflection_function, invokeArgs) reflection_object *intern; zend_function *fptr; zval *param_array; - + METHOD_NOTSTATIC(reflection_function_ptr); GET_REFLECTION_OBJECT_PTR(fptr); @@ -1900,9 +1900,9 @@ ZEND_METHOD(reflection_function, invokeArgs) } argc = zend_hash_num_elements(Z_ARRVAL_P(param_array)); - + params = safe_emalloc(sizeof(zval **), argc, 0); - zend_hash_apply_with_argument(Z_ARRVAL_P(param_array), (apply_func_arg_t)_zval_array_to_c_array, ¶ms TSRMLS_CC); + zend_hash_apply_with_argument(Z_ARRVAL_P(param_array), (apply_func_arg_t)_zval_array_to_c_array, ¶ms TSRMLS_CC); params -= argc; fci.size = sizeof(fci); @@ -1926,7 +1926,7 @@ ZEND_METHOD(reflection_function, invokeArgs) efree(params); if (result == FAILURE) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Invocation of function %s() failed", fptr->common.function_name); return; } @@ -1995,7 +1995,7 @@ ZEND_METHOD(reflection_function, getParameters) array_init(return_value); for (i = 0; i < fptr->common.num_args; i++) { - zval *parameter; + zval *parameter; ALLOC_ZVAL(parameter); reflection_parameter_factory(_copy_function(fptr TSRMLS_CC), intern->obj, arg_info, i, fptr->common.required_num_args, parameter TSRMLS_CC); @@ -2086,7 +2086,7 @@ ZEND_METHOD(reflection_parameter, __construct) if (intern == NULL) { return; } - + /* First, find the function */ switch (Z_TYPE_P(reference)) { case IS_STRING: { @@ -2097,7 +2097,7 @@ ZEND_METHOD(reflection_parameter, __construct) lcname = zend_str_tolower_dup(Z_STRVAL_P(reference), lcname_len); if (zend_hash_find(EG(function_table), lcname, lcname_len + 1, (void**) &fptr) == FAILURE) { efree(lcname); - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Function %s() does not exist", Z_STRVAL_P(reference)); return; } @@ -2112,7 +2112,7 @@ ZEND_METHOD(reflection_parameter, __construct) zend_class_entry **pce; unsigned int lcname_len; char *lcname; - + if ((zend_hash_index_find(Z_ARRVAL_P(reference), 0, (void **) &classref) == FAILURE) || (zend_hash_index_find(Z_ARRVAL_P(reference), 1, (void **) &method) == FAILURE)) { @@ -2131,7 +2131,7 @@ ZEND_METHOD(reflection_parameter, __construct) } ce = *pce; } - + convert_to_string_ex(method); lcname_len = Z_STRLEN_PP(method); lcname = zend_str_tolower_dup(Z_STRVAL_PP(method), lcname_len); @@ -2144,17 +2144,17 @@ ZEND_METHOD(reflection_parameter, __construct) - not the closure itself */ } else if (zend_hash_find(&ce->function_table, lcname, lcname_len + 1, (void **) &fptr) == FAILURE) { efree(lcname); - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Method %s::%s() does not exist", ce->name, Z_STRVAL_PP(method)); return; } efree(lcname); } break; - + case IS_OBJECT: { ce = Z_OBJCE_P(reference); - + if (instanceof_function(ce, zend_ce_closure TSRMLS_CC)) { fptr = (zend_function *)zend_get_closure_method_def(reference TSRMLS_CC); Z_ADDREF_P(reference); @@ -2166,12 +2166,12 @@ ZEND_METHOD(reflection_parameter, __construct) } } break; - + default: _DO_THROW("The parameter class is expected to be either a string, an array(class, method) or a callable object"); /* returns out of this function */ } - + /* Now, search for the parameter */ arg_info = fptr->common.arg_info; if (Z_TYPE_PP(parameter) == IS_LONG) { @@ -2214,7 +2214,7 @@ ZEND_METHOD(reflection_parameter, __construct) /* returns out of this function */ } } - + MAKE_STD_ZVAL(name); if (arg_info[position].name) { ZVAL_STRINGL(name, arg_info[position].name, arg_info[position].name_len, 1); @@ -2301,7 +2301,7 @@ ZEND_METHOD(reflection_parameter, getDeclaringClass) if (param->fptr->common.scope) { zend_reflection_class_factory(param->fptr->common.scope, return_value TSRMLS_CC); - } + } } /* }}} */ @@ -2334,7 +2334,7 @@ ZEND_METHOD(reflection_parameter, getClass) if (0 == zend_binary_strcasecmp(param->arg_info->class_name, param->arg_info->class_name_len, "self", sizeof("self")- 1)) { ce = param->fptr->common.scope; if (!ce) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Parameter uses 'self' as type hint but function is not a class member!"); return; } @@ -2342,18 +2342,18 @@ ZEND_METHOD(reflection_parameter, getClass) } else if (0 == zend_binary_strcasecmp(param->arg_info->class_name, param->arg_info->class_name_len, "parent", sizeof("parent")- 1)) { ce = param->fptr->common.scope; if (!ce) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Parameter uses 'parent' as type hint but function is not a class member!"); return; } if (!ce->parent) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Parameter uses 'parent' as type hint although class does not have a parent!"); return; } pce= &ce->parent; } else if (zend_lookup_class(param->arg_info->class_name, param->arg_info->class_name_len, &pce TSRMLS_CC) == FAILURE) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s does not exist", param->arg_info->class_name); return; } @@ -2378,102 +2378,6 @@ ZEND_METHOD(reflection_parameter, isArray) } /* }}} */ -/* {{{ proto public bool ReflectionParameter::isInt() - Returns whether parameter MUST be a long */ -ZEND_METHOD(reflection_parameter, isInt) -{ - reflection_object *intern; - parameter_reference *param; - - if (zend_parse_parameters_none() == FAILURE) { - return; - } - GET_REFLECTION_OBJECT_PTR(param); - - RETVAL_BOOL(param->arg_info->type_hint == IS_LONG); -} -/* }}} */ - -/* {{{ proto public bool ReflectionParameter::isDouble() - Returns whether parameter MUST be a double */ -ZEND_METHOD(reflection_parameter, isDouble) -{ - reflection_object *intern; - parameter_reference *param; - - if (zend_parse_parameters_none() == FAILURE) { - return; - } - GET_REFLECTION_OBJECT_PTR(param); - - RETVAL_BOOL(param->arg_info->type_hint == IS_DOUBLE); -} -/* }}} */ - -/* {{{ proto public bool ReflectionParameter::isBool() - Returns whether parameter MUST be a boolean */ -ZEND_METHOD(reflection_parameter, isBool) -{ - reflection_object *intern; - parameter_reference *param; - - if (zend_parse_parameters_none() == FAILURE) { - return; - } - GET_REFLECTION_OBJECT_PTR(param); - - RETVAL_BOOL(param->arg_info->type_hint == IS_BOOL); -} -/* }}} */ - -/* {{{ proto public bool ReflectionParameter::isObject() - Returns whether parameter MUST be a boolean */ -ZEND_METHOD(reflection_parameter, isObject) -{ - reflection_object *intern; - parameter_reference *param; - - if (zend_parse_parameters_none() == FAILURE) { - return; - } - GET_REFLECTION_OBJECT_PTR(param); - - RETVAL_BOOL(param->arg_info->type_hint == IS_OBJECT); -} -/* }}} */ - -/* {{{ proto public bool ReflectionParameter::isString() - Returns whether parameter MUST be a string */ -ZEND_METHOD(reflection_parameter, isString) -{ - reflection_object *intern; - parameter_reference *param; - - if (zend_parse_parameters_none() == FAILURE) { - return; - } - GET_REFLECTION_OBJECT_PTR(param); - - RETVAL_BOOL(param->arg_info->type_hint == IS_STRING); -} -/* }}} */ - -/* {{{ proto public bool ReflectionParameter::isResource() - Returns whether parameter MUST be a resource */ -ZEND_METHOD(reflection_parameter, isResource) -{ - reflection_object *intern; - parameter_reference *param; - - if (zend_parse_parameters_none() == FAILURE) { - return; - } - GET_REFLECTION_OBJECT_PTR(param); - - RETVAL_BOOL(param->arg_info->type_hint == IS_RESOURCE); -} -/* }}} */ - /* {{{ proto public string ReflectionParameter::getTypeHint() Returns what type hint is defined for this parameter */ ZEND_METHOD(reflection_parameter, getTypeHint) @@ -2622,12 +2526,12 @@ ZEND_METHOD(reflection_parameter, getDefaultValue) return; } if (param->offset < param->required) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Parameter is not optional"); + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Parameter is not optional"); return; } precv = _get_recv_op((zend_op_array*)param->fptr, param->offset); if (!precv || precv->opcode != ZEND_RECV_INIT || precv->op2_type == IS_UNUSED) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Internal error"); + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Internal error"); return; } @@ -2668,7 +2572,7 @@ ZEND_METHOD(reflection_method, __construct) return; } if ((tmp = strstr(name_str, "::")) == NULL) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Invalid method name %s", name_str); + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Invalid method name %s", name_str); return; } classname = &ztmp; @@ -2688,13 +2592,13 @@ ZEND_METHOD(reflection_method, __construct) if (intern == NULL) { return; } - + /* Find the class entry */ switch (Z_TYPE_P(classname)) { case IS_STRING: if (zend_lookup_class(Z_STRVAL_P(classname), Z_STRLEN_P(classname), &pce TSRMLS_CC) == FAILURE) { zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, - "Class %s does not exist", Z_STRVAL_P(classname)); + "Class %s does not exist", Z_STRVAL_P(classname)); if (classname == &ztmp) { zval_dtor(&ztmp); } @@ -2728,7 +2632,7 @@ ZEND_METHOD(reflection_method, __construct) /* do nothing, mptr already set */ } else if (zend_hash_find(&ce->function_table, lcname, name_len + 1, (void **) &mptr) == FAILURE) { efree(lcname); - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Method %s::%s() does not exist", ce->name, name_str); return; } @@ -2738,7 +2642,7 @@ ZEND_METHOD(reflection_method, __construct) ZVAL_STRINGL(classname, mptr->common.scope->name, mptr->common.scope->name_length, 1); reflection_update_property(object, "class", classname); - + MAKE_STD_ZVAL(name); ZVAL_STRING(name, mptr->common.function_name, 1); reflection_update_property(object, "name", name); @@ -2773,7 +2677,7 @@ ZEND_METHOD(reflection_method, getClosure) reflection_object *intern; zval *obj; zend_function *mptr; - + METHOD_NOTSTATIC(reflection_method_ptr); GET_REFLECTION_OBJECT_PTR(mptr); @@ -2814,7 +2718,7 @@ ZEND_METHOD(reflection_method, invoke) zend_fcall_info fci; zend_fcall_info_cache fcc; zend_class_entry *obj_ce; - + METHOD_NOTSTATIC(reflection_method_ptr); GET_REFLECTION_OBJECT_PTR(mptr); @@ -2824,12 +2728,12 @@ ZEND_METHOD(reflection_method, invoke) && intern->ignore_visibility == 0) { if (mptr->common.fn_flags & ZEND_ACC_ABSTRACT) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, - "Trying to invoke abstract method %s::%s()", + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + "Trying to invoke abstract method %s::%s()", mptr->common.scope->name, mptr->common.function_name); } else { zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, - "Trying to invoke %s method %s::%s() from scope %s", + "Trying to invoke %s method %s::%s() from scope %s", mptr->common.fn_flags & ZEND_ACC_PROTECTED ? "protected" : "private", mptr->common.scope->name, mptr->common.function_name, Z_OBJCE_P(getThis())->name); @@ -2840,7 +2744,7 @@ ZEND_METHOD(reflection_method, invoke) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "+", ¶ms, &num_args) == FAILURE) { return; } - + /* In case this is a static method, we should'nt pass an object_ptr * (which is used as calling context aka $this). We can thus ignore the * first parameter. @@ -2866,10 +2770,10 @@ ZEND_METHOD(reflection_method, invoke) _DO_THROW("Given object is not an instance of the class this method was declared in"); /* Returns from this function */ } - + object_ptr = *params[0]; } - + fci.size = sizeof(fci); fci.function_table = NULL; fci.function_name = NULL; @@ -2887,13 +2791,13 @@ ZEND_METHOD(reflection_method, invoke) fcc.object_ptr = object_ptr; result = zend_call_function(&fci, &fcc TSRMLS_CC); - + if (params) { efree(params); } if (result == FAILURE) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Invocation of method %s::%s() failed", mptr->common.scope->name, mptr->common.function_name); return; } @@ -2919,7 +2823,7 @@ ZEND_METHOD(reflection_method, invokeArgs) zend_fcall_info_cache fcc; zend_class_entry *obj_ce; zval *param_array; - + METHOD_NOTSTATIC(reflection_method_ptr); GET_REFLECTION_OBJECT_PTR(mptr); @@ -2933,12 +2837,12 @@ ZEND_METHOD(reflection_method, invokeArgs) && intern->ignore_visibility == 0) { if (mptr->common.fn_flags & ZEND_ACC_ABSTRACT) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, - "Trying to invoke abstract method %s::%s()", + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + "Trying to invoke abstract method %s::%s()", mptr->common.scope->name, mptr->common.function_name); } else { zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, - "Trying to invoke %s method %s::%s() from scope %s", + "Trying to invoke %s method %s::%s() from scope %s", mptr->common.fn_flags & ZEND_ACC_PROTECTED ? "protected" : "private", mptr->common.scope->name, mptr->common.function_name, Z_OBJCE_P(getThis())->name); @@ -2947,11 +2851,11 @@ ZEND_METHOD(reflection_method, invokeArgs) } argc = zend_hash_num_elements(Z_ARRVAL_P(param_array)); - + params = safe_emalloc(sizeof(zval **), argc, 0); - zend_hash_apply_with_argument(Z_ARRVAL_P(param_array), (apply_func_arg_t)_zval_array_to_c_array, ¶ms TSRMLS_CC); + zend_hash_apply_with_argument(Z_ARRVAL_P(param_array), (apply_func_arg_t)_zval_array_to_c_array, ¶ms TSRMLS_CC); params -= argc; - + /* In case this is a static method, we should'nt pass an object_ptr * (which is used as calling context aka $this). We can thus ignore the * first parameter. @@ -2965,11 +2869,11 @@ ZEND_METHOD(reflection_method, invokeArgs) if (!object) { efree(params); zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, - "Trying to invoke non static method %s::%s() without an object", + "Trying to invoke non static method %s::%s() without an object", mptr->common.scope->name, mptr->common.function_name); return; } - + obj_ce = Z_OBJCE_P(object); if (!instanceof_function(obj_ce, mptr->common.scope TSRMLS_CC)) { @@ -2978,7 +2882,7 @@ ZEND_METHOD(reflection_method, invokeArgs) /* Returns from this function */ } } - + fci.size = sizeof(fci); fci.function_table = NULL; fci.function_name = NULL; @@ -2996,11 +2900,11 @@ ZEND_METHOD(reflection_method, invokeArgs) fcc.object_ptr = object; result = zend_call_function(&fci, &fcc TSRMLS_CC); - + efree(params); if (result == FAILURE) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Invocation of method %s::%s() failed", mptr->common.scope->name, mptr->common.function_name); return; } @@ -3147,7 +3051,7 @@ ZEND_METHOD(reflection_method, isConstructor) return; } GET_REFLECTION_OBJECT_PTR(mptr); - /* we need to check if the ctor is the ctor of the class level we we + /* we need to check if the ctor is the ctor of the class level we we * looking at since we might be looking at an inherited old style ctor * defined in base class. */ RETURN_BOOL(mptr->common.fn_flags & ZEND_ACC_CTOR && intern->ce->constructor && intern->ce->constructor->common.scope == mptr->common.scope); @@ -3194,7 +3098,7 @@ ZEND_METHOD(reflection_method, getDeclaringClass) METHOD_NOTSTATIC(reflection_method_ptr); GET_REFLECTION_OBJECT_PTR(mptr); - + if (zend_parse_parameters_none() == FAILURE) { return; } @@ -3212,13 +3116,13 @@ ZEND_METHOD(reflection_method, getPrototype) METHOD_NOTSTATIC(reflection_method_ptr); GET_REFLECTION_OBJECT_PTR(mptr); - + if (zend_parse_parameters_none() == FAILURE) { return; } - + if (!mptr->common.prototype) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Method %s::%s does not have a prototype", intern->ce->name, mptr->common.function_name); return; } @@ -3280,7 +3184,7 @@ static void reflection_class_object_ctor(INTERNAL_FUNCTION_PARAMETERS, int is_ob if (intern == NULL) { return; } - + if (Z_TYPE_P(argument) == IS_OBJECT) { MAKE_STD_ZVAL(classname); ZVAL_STRINGL(classname, Z_OBJCE_P(argument)->name, Z_OBJCE_P(argument)->name_length, 1); @@ -3290,7 +3194,7 @@ static void reflection_class_object_ctor(INTERNAL_FUNCTION_PARAMETERS, int is_ob intern->obj = argument; zval_add_ref(&argument); } - } else { + } else { convert_to_string_ex(&argument); if (zend_lookup_class(Z_STRVAL_P(argument), Z_STRLEN_P(argument), &ce TSRMLS_CC) == FAILURE) { if (!EG(exception)) { @@ -3357,7 +3261,7 @@ static void add_class_vars(zend_class_entry *ce, int statics, zval *return_value zval_copy_ctor(prop_copy); INIT_PZVAL(prop_copy); - /* this is necessary to make it able to work with default array + /* this is necessary to make it able to work with default array * properties, returned to user */ if (Z_TYPE_P(prop_copy) == IS_CONSTANT_ARRAY || (Z_TYPE_P(prop_copy) & IS_CONSTANT_TYPE_MASK) == IS_CONSTANT) { zval_update_constant(&prop_copy, (void *) 1 TSRMLS_CC); @@ -3378,7 +3282,7 @@ ZEND_METHOD(reflection_class, getStaticProperties) if (zend_parse_parameters_none() == FAILURE) { return; } - + GET_REFLECTION_OBJECT_PTR(ce); zend_update_class_constants(ce TSRMLS_CC); @@ -3397,7 +3301,7 @@ ZEND_METHOD(reflection_class, getStaticPropertyValue) char *name; int name_len; zval **prop, *def_value = NULL; - + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z", &name, &name_len, &def_value) == FAILURE) { return; } @@ -3410,7 +3314,7 @@ ZEND_METHOD(reflection_class, getStaticPropertyValue) if (def_value) { RETURN_ZVAL(def_value, 1, 0); } else { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s does not have a property named %s", ce->name, name); } return; @@ -3431,7 +3335,7 @@ ZEND_METHOD(reflection_class, setStaticPropertyValue) zval **variable_ptr, *value; int refcount; zend_uchar is_ref; - + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz", &name, &name_len, &value) == FAILURE) { return; } @@ -3441,10 +3345,10 @@ ZEND_METHOD(reflection_class, setStaticPropertyValue) zend_update_class_constants(ce TSRMLS_CC); variable_ptr = zend_std_get_static_property(ce, name, name_len, 1, NULL TSRMLS_CC); if (!variable_ptr) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s does not have a property named %s", ce->name, name); return; - } + } refcount = Z_REFCOUNT_PP(variable_ptr); is_ref = Z_ISREF_PP(variable_ptr); zval_dtor(*variable_ptr); @@ -3462,7 +3366,7 @@ ZEND_METHOD(reflection_class, getDefaultProperties) { reflection_object *intern; zend_class_entry *ce; - + if (zend_parse_parameters_none() == FAILURE) { return; } @@ -3631,7 +3535,7 @@ ZEND_METHOD(reflection_class, hasMethod) { reflection_object *intern; zend_class_entry *ce; - char *name, *lc_name; + char *name, *lc_name; int name_len; METHOD_NOTSTATIC(reflection_class_ptr); @@ -3661,7 +3565,7 @@ ZEND_METHOD(reflection_class, getMethod) zend_class_entry *ce; zend_function *mptr; zval obj_tmp; - char *name, *lc_name; + char *name, *lc_name; int name_len; METHOD_NOTSTATIC(reflection_class_ptr); @@ -3692,7 +3596,7 @@ ZEND_METHOD(reflection_class, getMethod) efree(lc_name); } else { efree(lc_name); - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Method %s does not exist", name); return; } @@ -3730,7 +3634,7 @@ static int _addmethod_va(zend_function *mptr TSRMLS_DC, int num_args, va_list ar zval *retval = va_arg(args, zval*); long filter = va_arg(args, long); zval *obj = va_arg(args, zval *); - + _addmethod(mptr, ce, retval, filter, obj TSRMLS_CC); return ZEND_HASH_APPLY_KEEP; } @@ -3776,7 +3680,7 @@ ZEND_METHOD(reflection_class, hasProperty) reflection_object *intern; zend_property_info *property_info; zend_class_entry *ce; - char *name; + char *name; int name_len; zval *property; @@ -3813,7 +3717,7 @@ ZEND_METHOD(reflection_class, getProperty) reflection_object *intern; zend_class_entry *ce, **pce; zend_property_info *property_info; - char *name, *tmp, *classname; + char *name, *tmp, *classname; int name_len, classname_len; METHOD_NOTSTATIC(reflection_class_ptr); @@ -3869,9 +3773,9 @@ ZEND_METHOD(reflection_class, getProperty) if (zend_hash_find(&ce->properties_info, name, name_len + 1, (void**) &property_info) == SUCCESS && (property_info->flags & ZEND_ACC_SHADOW) == 0) { reflection_property_factory(ce, property_info, return_value TSRMLS_CC); return; - } + } } - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Property %s does not exist", name); } /* }}} */ @@ -3887,7 +3791,7 @@ static int _addproperty(zend_property_info *pptr TSRMLS_DC, int num_args, va_lis if (pptr->flags & ZEND_ACC_SHADOW) { return 0; } - + if (pptr->flags & filter) { ALLOC_ZVAL(property); reflection_property_factory(ce, pptr, property TSRMLS_CC); @@ -3998,7 +3902,7 @@ ZEND_METHOD(reflection_class, getConstant) reflection_object *intern; zend_class_entry *ce; zval **value; - char *name; + char *name; int name_len; METHOD_NOTSTATIC(reflection_class_ptr); @@ -4082,7 +3986,7 @@ ZEND_METHOD(reflection_class, isCloneable) object_init_ex(&obj, ce); RETVAL_BOOL(Z_OBJ_HANDLER(obj, clone_obj) != NULL); zval_dtor(&obj); - } + } } } /* }}} */ @@ -4147,7 +4051,7 @@ ZEND_METHOD(reflection_class, isInstance) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &object) == FAILURE) { return; } - GET_REFLECTION_OBJECT_PTR(ce); + GET_REFLECTION_OBJECT_PTR(ce); RETURN_BOOL(HAS_CLASS_ENTRY(*object) && instanceof_function(Z_OBJCE_P(object), ce TSRMLS_CC)); } /* }}} */ @@ -4159,7 +4063,7 @@ ZEND_METHOD(reflection_class, newInstance) zval *retval_ptr = NULL; reflection_object *intern; zend_class_entry *ce; - + METHOD_NOTSTATIC(reflection_class_ptr); GET_REFLECTION_OBJECT_PTR(ce); @@ -4233,8 +4137,8 @@ ZEND_METHOD(reflection_class, newInstanceArgs) zend_class_entry *ce; int argc = 0; HashTable *args; - - + + METHOD_NOTSTATIC(reflection_class_ptr); GET_REFLECTION_OBJECT_PTR(ce); @@ -4244,7 +4148,7 @@ ZEND_METHOD(reflection_class, newInstanceArgs) if (ZEND_NUM_ARGS() > 0) { argc = args->nNumOfElements; } - + /* Run the constructor if there is one */ if (ce->constructor) { zval ***params = NULL; @@ -4255,10 +4159,10 @@ ZEND_METHOD(reflection_class, newInstanceArgs) zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Access to non-public constructor of class %s", ce->name); return; } - + if (argc) { params = safe_emalloc(sizeof(zval **), argc, 0); - zend_hash_apply_with_argument(args, (apply_func_arg_t)_zval_array_to_c_array, ¶ms TSRMLS_CC); + zend_hash_apply_with_argument(args, (apply_func_arg_t)_zval_array_to_c_array, ¶ms TSRMLS_CC); params -= argc; } @@ -4439,7 +4343,7 @@ ZEND_METHOD(reflection_class, getParentClass) return; } GET_REFLECTION_OBJECT_PTR(ce); - + if (ce->parent) { zend_reflection_class_factory(ce->parent, return_value TSRMLS_CC); } else { @@ -4462,16 +4366,16 @@ ZEND_METHOD(reflection_class, isSubclassOf) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &class_name) == FAILURE) { return; } - + switch(class_name->type) { case IS_STRING: if (zend_lookup_class(Z_STRVAL_P(class_name), Z_STRLEN_P(class_name), &pce TSRMLS_CC) == FAILURE) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s does not exist", Z_STRVAL_P(class_name)); return; } class_ce = *pce; - break; + break; case IS_OBJECT: if (instanceof_function(Z_OBJCE_P(class_name), reflection_class_ptr TSRMLS_CC)) { argument = (reflection_object *) zend_object_store_get_object(class_name TSRMLS_CC); @@ -4484,7 +4388,7 @@ ZEND_METHOD(reflection_class, isSubclassOf) } /* no break */ default: - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Parameter one must either be a string or a ReflectionClass object"); return; } @@ -4507,16 +4411,16 @@ ZEND_METHOD(reflection_class, implementsInterface) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &interface) == FAILURE) { return; } - + switch(interface->type) { case IS_STRING: if (zend_lookup_class(Z_STRVAL_P(interface), Z_STRLEN_P(interface), &pce TSRMLS_CC) == FAILURE) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Interface %s does not exist", Z_STRVAL_P(interface)); return; } interface_ce = *pce; - break; + break; case IS_OBJECT: if (instanceof_function(Z_OBJCE_P(interface), reflection_class_ptr TSRMLS_CC)) { argument = (reflection_object *) zend_object_store_get_object(interface TSRMLS_CC); @@ -4529,13 +4433,13 @@ ZEND_METHOD(reflection_class, implementsInterface) } /* no break */ default: - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Parameter one must either be a string or a ReflectionClass object"); return; } if (!(interface_ce->ce_flags & ZEND_ACC_INTERFACE)) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Interface %s is a Class", interface_ce->name); return; } @@ -4549,7 +4453,7 @@ ZEND_METHOD(reflection_class, isIterateable) { reflection_object *intern; zend_class_entry *ce; - + if (zend_parse_parameters_none() == FAILURE) { return; } @@ -4567,7 +4471,7 @@ ZEND_METHOD(reflection_class, getExtension) { reflection_object *intern; zend_class_entry *ce; - + if (zend_parse_parameters_none() == FAILURE) { return; } @@ -4587,7 +4491,7 @@ ZEND_METHOD(reflection_class, getExtensionName) { reflection_object *intern; zend_class_entry *ce; - + if (zend_parse_parameters_none() == FAILURE) { return; } @@ -4719,13 +4623,13 @@ ZEND_METHOD(reflection_property, __construct) if (intern == NULL) { return; } - + /* Find the class entry */ switch (Z_TYPE_P(classname)) { case IS_STRING: if (zend_lookup_class(Z_STRVAL_P(classname), Z_STRLEN_P(classname), &pce TSRMLS_CC) == FAILURE) { zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, - "Class %s does not exist", Z_STRVAL_P(classname)); + "Class %s does not exist", Z_STRVAL_P(classname)); return; } ce = *pce; @@ -4734,7 +4638,7 @@ ZEND_METHOD(reflection_property, __construct) case IS_OBJECT: ce = Z_OBJCE_P(classname); break; - + default: _DO_THROW("The parameter class is expected to be either a string or an object"); /* returns out of this function */ @@ -4752,12 +4656,12 @@ ZEND_METHOD(reflection_property, __construct) return; } } - + if (dynam_prop == 0 && (property_info->flags & ZEND_ACC_PRIVATE) == 0) { /* we have to search the class hierarchy for this (implicit) public or protected property */ zend_class_entry *tmp_ce = ce; zend_property_info *tmp_info; - + while (tmp_ce && zend_hash_find(&tmp_ce->properties_info, name_str, name_len + 1, (void **) &tmp_info) != SUCCESS) { ce = tmp_ce; property_info = tmp_info; @@ -4765,15 +4669,15 @@ ZEND_METHOD(reflection_property, __construct) } } - MAKE_STD_ZVAL(classname); + MAKE_STD_ZVAL(classname); MAKE_STD_ZVAL(propname); - + if (dynam_prop == 0) { zend_unmangle_property_name(property_info->name, property_info->name_length, &class_name, &prop_name); ZVAL_STRINGL(classname, property_info->ce->name, property_info->ce->name_length, 1); ZVAL_STRING(propname, prop_name, 1); } else { - ZVAL_STRINGL(classname, ce->name, ce->name_length, 1); + ZVAL_STRINGL(classname, ce->name, ce->name_length, 1); ZVAL_STRINGL(propname, name_str, name_len, 1); } reflection_update_property(object, "class", classname); @@ -4910,7 +4814,7 @@ ZEND_METHOD(reflection_property, getValue) if (!(ref->prop.flags & (ZEND_ACC_PUBLIC | ZEND_ACC_IMPLICIT_PUBLIC)) && intern->ignore_visibility == 0) { _default_get_entry(getThis(), "name", sizeof("name"), &name TSRMLS_CC); - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Cannot access non-public member %s::%s", intern->ce->name, Z_STRVAL(name)); zval_dtor(&name); return; @@ -4927,7 +4831,7 @@ ZEND_METHOD(reflection_property, getValue) INIT_PZVAL(return_value); } else { char *class_name, *prop_name; - + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &object) == FAILURE) { return; } @@ -4958,7 +4862,7 @@ ZEND_METHOD(reflection_property, setValue) if (!(ref->prop.flags & ZEND_ACC_PUBLIC) && intern->ignore_visibility == 0) { _default_get_entry(getThis(), "name", sizeof("name"), &name TSRMLS_CC); - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Cannot access non-public member %s::%s", intern->ce->name, Z_STRVAL(name)); zval_dtor(&name); return; @@ -5124,7 +5028,7 @@ ZEND_METHOD(reflection_extension, __construct) zend_str_tolower_copy(lcname, name_str, name_len); if (zend_hash_find(&module_registry, lcname, name_len + 1, (void **)&module) == FAILURE) { free_alloca(lcname, use_heap); - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Extension %s does not exist", name_str); return; } @@ -5213,7 +5117,7 @@ ZEND_METHOD(reflection_extension, getFunctions) func++; continue; } - + ALLOC_ZVAL(function); reflection_function_factory(fptr, NULL, function TSRMLS_CC); add_assoc_zval_ex(return_value, func->fname, strlen(func->fname)+1, function); @@ -5357,11 +5261,11 @@ ZEND_METHOD(reflection_extension, getDependencies) return; } GET_REFLECTION_OBJECT_PTR(module); - + array_init(return_value); dep = module->deps; - + if (!dep) { return; @@ -5371,7 +5275,7 @@ ZEND_METHOD(reflection_extension, getDependencies) char *relation; char *rel_type; int len; - + switch(dep->type) { case MODULE_DEP_REQUIRED: rel_type = "Required"; @@ -5387,10 +5291,10 @@ ZEND_METHOD(reflection_extension, getDependencies) break; } - len = spprintf(&relation, 0, "%s%s%s%s%s", + len = spprintf(&relation, 0, "%s%s%s%s%s", rel_type, dep->rel ? " " : "", - dep->rel ? dep->rel : "", + dep->rel ? dep->rel : "", dep->version ? " " : "", dep->version ? dep->version : ""); add_assoc_stringl(return_value, dep->name, relation, len, 0); @@ -5478,7 +5382,7 @@ ZEND_METHOD(reflection_zend_extension, __construct) extension = zend_get_extension(name_str); if (!extension) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Zend Extension %s does not exist", name_str); return; } @@ -5506,7 +5410,7 @@ ZEND_METHOD(reflection_zend_extension, __toString) string_init(&str); _zend_extension_string(&str, extension, "" TSRMLS_CC); RETURN_STRINGL(str.string, str.len - 1, 0); -} +} /* }}} */ /* {{{ proto public string ReflectionZendExtension::getName() @@ -5933,13 +5837,7 @@ static const zend_function_entry reflection_parameter_functions[] = { ZEND_ME(reflection_parameter, getDeclaringClass, arginfo_reflection__void, 0) ZEND_ME(reflection_parameter, getClass, arginfo_reflection__void, 0) ZEND_ME(reflection_parameter, isArray, arginfo_reflection__void, 0) - ZEND_ME(reflection_parameter, isInt, arginfo_reflection__void, 0) - ZEND_ME(reflection_parameter, isDouble, arginfo_reflection__void, 0) - ZEND_ME(reflection_parameter, isBool, arginfo_reflection__void, 0) ZEND_ME(reflection_parameter, getTypeHint, arginfo_reflection__void, 0) - ZEND_ME(reflection_parameter, isString, arginfo_reflection__void, 0) - ZEND_ME(reflection_parameter, isObject, arginfo_reflection__void, 0) - ZEND_ME(reflection_parameter, isResource, arginfo_reflection__void, 0) ZEND_ME(reflection_parameter, allowsNull, arginfo_reflection__void, 0) ZEND_ME(reflection_parameter, getPosition, arginfo_reflection__void, 0) ZEND_ME(reflection_parameter, isOptional, arginfo_reflection__void, 0) @@ -6008,7 +5906,7 @@ static void _reflection_write_property(zval *object, zval *member, zval *value, && ((Z_STRLEN_P(member) == sizeof("name") - 1 && !memcmp(Z_STRVAL_P(member), "name", sizeof("name"))) || (Z_STRLEN_P(member) == sizeof("class") - 1 && !memcmp(Z_STRVAL_P(member), "class", sizeof("class"))))) { - zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Cannot set read-only property %s::$%s", Z_OBJCE_P(object)->name, Z_STRVAL_P(member)); } else |