diff options
Diffstat (limited to 'ext/reflection')
30 files changed, 847 insertions, 74 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 7ed925593..1eedbb6e3 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_reflection.c,v 1.164.2.17 2006/01/01 12:50:12 sniper Exp $ */ +/* $Id: php_reflection.c,v 1.164.2.33 2006/03/29 14:28:42 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -240,9 +240,7 @@ static void reflection_objects_clone(void *object, void **object_clone TSRMLS_DC reflection_object **intern_clone = (reflection_object **) object_clone; *intern_clone = emalloc(sizeof(reflection_object)); - (*intern_clone)->zo.ce = intern->zo.ce; - (*intern_clone)->zo.guards = NULL; - ALLOC_HASHTABLE((*intern_clone)->zo.properties); + zend_object_std_init(&(*intern_clone)->zo, intern->zo.ce TSRMLS_CC); (*intern_clone)->ptr = intern->ptr; (*intern_clone)->free_ptr = intern->free_ptr; (*intern_clone)->obj = intern->obj; @@ -264,8 +262,7 @@ static zend_object_value reflection_objects_new(zend_class_entry *class_type TSR intern->obj = NULL; intern->free_ptr = 0; - ALLOC_HASHTABLE(intern->zo.properties); - zend_hash_init(intern->zo.properties, 0, NULL, ZVAL_PTR_DTOR, 0); + zend_object_std_init(&intern->zo, class_type TSRMLS_CC); zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); retval.handle = zend_objects_store_put(intern, NULL, reflection_free_objects_storage, reflection_objects_clone TSRMLS_CC); retval.handlers = &reflection_object_handlers; @@ -352,6 +349,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in /* Constants */ if (&ce->constants_table) { + zend_hash_apply_with_argument(&ce->constants_table, (apply_func_arg_t) zval_update_constant, (void*)1 TSRMLS_CC); string_printf(str, "\n"); count = zend_hash_num_elements(&ce->constants_table); string_printf(str, "%s - Constants [%d] {\n", indent, count); @@ -553,7 +551,7 @@ static zend_op* _get_recv_op(zend_op_array *op_array, zend_uint offset) ++offset; while (op < end) { if ((op->opcode == ZEND_RECV || op->opcode == ZEND_RECV_INIT) && - op->op1.u.constant.value.lval == offset) { + op->op1.u.constant.value.lval == (long)offset) { return op; } ++op; @@ -670,6 +668,9 @@ static void _function_string(string *str, zend_function *fptr, zend_class_entry string_printf(str, fptr->common.scope ? "%sMethod [ " : "%sFunction [ ", indent); string_printf(str, (fptr->type == ZEND_USER_FUNCTION) ? "<user" : "<internal"); + if (fptr->common.fn_flags & ZEND_ACC_DEPRECATED) { + string_printf(str, ", deprecated"); + } #if MBO_0 if (fptr->type == ZEND_INTERNAL_FUNCTION && ((zend_internal_function*)fptr)->module) { string_printf(str, ":%s", ((zend_internal_function*)fptr)->module->name); @@ -867,6 +868,41 @@ static void _extension_string(string *str, zend_module_entry *module, char *inde module->module_number, module->name, (module->version == NO_VERSION_YET) ? "<no_version>" : module->version); + if (module->deps) { + zend_module_dep* dep = module->deps; + + string_printf(str, "\n - Dependencies {\n"); + + 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); + break; + case MODULE_DEP_CONFLICTS: + string_write(str, "Conflicts", sizeof("Conflicts") - 1); + break; + case MODULE_DEP_OPTIONAL: + string_write(str, "Optional", sizeof("Optional") - 1); + break; + default: + string_write(str, "Error", sizeof("Error") - 1); /* shouldn't happen */ + break; + } + + if (dep->rel) { + string_printf(str, " %s", dep->rel); + } + if (dep->version) { + string_printf(str, " %s", dep->version); + } + string_write(str, ") ]\n", sizeof(") ]\n") - 1); + dep++; + } + string_printf(str, "%s }\n", indent); + } + { string str_ini; string_init(&str_ini); @@ -1070,14 +1106,10 @@ static void reflection_property_factory(zend_class_entry *ce, zend_property_info if (!(prop->flags & ZEND_ACC_PRIVATE)) { /* we have to seach the class hierarchy for this (implicit) public or protected property */ - zend_class_entry *tmp_ce = ce->parent; + zend_class_entry *tmp_ce = ce; zend_property_info *tmp_info; - while (tmp_ce && zend_hash_find(&tmp_ce->properties_info, prop_name, strlen(prop_name) + 1, (void **) &tmp_info) == SUCCESS) { - if (tmp_info->flags & ZEND_ACC_PRIVATE) { - /* private in super class => NOT the same property */ - break; - } + while (tmp_ce && zend_hash_find(&tmp_ce->properties_info, prop_name, strlen(prop_name) + 1, (void **) &tmp_info) != SUCCESS) { ce = tmp_ce; prop = tmp_info; tmp_ce = tmp_ce->parent; @@ -1284,7 +1316,7 @@ ZEND_METHOD(reflection, getModifierNames) } /* }}} */ -/* {{{ proto public static mixed ReflectionFunction::export(string name [, bool return]) throws ReflectionException +/* {{{ proto public static mixed ReflectionFunction::export(string name [, bool return]) Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */ ZEND_METHOD(reflection_function, export) { @@ -1292,7 +1324,7 @@ ZEND_METHOD(reflection_function, export) } /* }}} */ -/* {{{ proto public ReflectionFunction::__construct(string name) +/* {{{ proto public void ReflectionFunction::__construct(string name) Constructor. Throws an Exception in case the given function does not exist */ ZEND_METHOD(reflection_function, __construct) { @@ -1711,7 +1743,7 @@ ZEND_METHOD(reflection_parameter, export) } /* }}} */ -/* {{{ proto public ReflectionParameter::__construct(mixed function, mixed parameter) +/* {{{ proto public void ReflectionParameter::__construct(mixed function, mixed parameter) Constructor. Throws an Exception in case the given method does not exist */ ZEND_METHOD(reflection_parameter, __construct) { @@ -1752,6 +1784,7 @@ ZEND_METHOD(reflection_parameter, __construct) } efree(lcname); } + ce = fptr->common.scope; break; case IS_ARRAY: { @@ -1866,9 +1899,10 @@ ZEND_METHOD(reflection_parameter, getName) } /* }}} */ -/* {{{ proto public ReflectionClass ReflectionParameter::getClass() - Returns this parameters's class hint or NULL if there is none */ -ZEND_METHOD(reflection_parameter, getClass) +#if MBO_0 +/* {{{ proto public ReflectionFunction ReflectionParameter::getDeclaringFunction() + Returns the ReflectionFunction for the function of this parameter */ +ZEND_METHOD(reflection_parameter, getDeclaringFunction) { reflection_object *intern; parameter_reference *param; @@ -1876,12 +1910,44 @@ ZEND_METHOD(reflection_parameter, getClass) METHOD_NOTSTATIC_NUMPARAMS(reflection_parameter_ptr, 0); GET_REFLECTION_OBJECT_PTR(param); - if (!param->arg_info->class_name) { - RETURN_NULL(); + if (!param->fptr->common.scope) { + reflection_function_factory(param->fptr, return_value TSRMLS_CC); } else { - zend_class_entry **pce; + reflection_method_factory(param->fptr->common.scope, param->fptr, return_value TSRMLS_CC); + } +} +/* }}} */ +#endif + +/* {{{ proto public ReflectionClass|NULL ReflectionParameter::getDeclaringClass() + Returns in which class this parameter is defined (not the typehint of the parameter) */ +ZEND_METHOD(reflection_parameter, getDeclaringClass) +{ + reflection_object *intern; + parameter_reference *param; + + METHOD_NOTSTATIC_NUMPARAMS(reflection_parameter_ptr, 0); + GET_REFLECTION_OBJECT_PTR(param); + + if (param->fptr->common.scope) { + zend_reflection_class_factory(param->fptr->common.scope, return_value TSRMLS_CC); + } +} +/* }}} */ + +/* {{{ proto public ReflectionClass|NULL ReflectionParameter::getClass() + Returns this parameters's class hint or NULL if there is none */ +ZEND_METHOD(reflection_parameter, getClass) +{ + reflection_object *intern; + parameter_reference *param; + zend_class_entry **pce; + + METHOD_NOTSTATIC_NUMPARAMS(reflection_parameter_ptr, 0); + GET_REFLECTION_OBJECT_PTR(param); - if (zend_lookup_class_ex(param->arg_info->class_name, param->arg_info->class_name_len, 1, &pce TSRMLS_CC) == FAILURE) { + if (param->arg_info->class_name) { + 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, "Class %s does not exist", param->arg_info->class_name); return; @@ -1933,6 +1999,22 @@ ZEND_METHOD(reflection_parameter, isPassedByReference) } /* }}} */ +#if MBO_0 +/* {{{ proto public bool ReflectionParameter::getPosition() + Returns whether this parameter is an optional parameter */ +ZEND_METHOD(reflection_parameter, getPosition) +{ + reflection_object *intern; + parameter_reference *param; + + METHOD_NOTSTATIC_NUMPARAMS(reflection_parameter_ptr, 0); + GET_REFLECTION_OBJECT_PTR(param); + + RETVAL_LONG(param->offset); +} +/* }}} */ +#endif + /* {{{ proto public bool ReflectionParameter::isOptional() Returns whether this parameter is an optional parameter */ ZEND_METHOD(reflection_parameter, isOptional) @@ -2015,7 +2097,7 @@ ZEND_METHOD(reflection_method, export) } /* }}} */ -/* {{{ proto public ReflectionMethod::__construct(mixed class_or_method [, string name]) +/* {{{ proto public void ReflectionMethod::__construct(mixed class_or_method [, string name]) Constructor. Throws an Exception in case the given method does not exist */ ZEND_METHOD(reflection_method, __construct) { @@ -2369,6 +2451,14 @@ ZEND_METHOD(reflection_method, isStatic) } /* }}} */ +/* {{{ proto public bool ReflectionFunction::isDeprecated() + Returns whether this function is deprecated */ +ZEND_METHOD(reflection_function, isDeprecated) +{ + _function_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_DEPRECATED); +} +/* }}} */ + /* {{{ proto public bool ReflectionMethod::isConstructor() Returns whether this method is the constructor */ ZEND_METHOD(reflection_method, isConstructor) @@ -2507,7 +2597,7 @@ static void reflection_class_object_ctor(INTERNAL_FUNCTION_PARAMETERS, int is_ob } /* }}} */ -/* {{{ proto public ReflectionClass::__construct(mixed argument) throws ReflectionException +/* {{{ proto public void ReflectionClass::__construct(mixed argument) throws ReflectionException Constructor. Takes a string or an instance as an argument */ ZEND_METHOD(reflection_class, __construct) { @@ -3179,8 +3269,6 @@ ZEND_METHOD(reflection_class, newInstance) METHOD_NOTSTATIC(reflection_class_ptr); GET_REFLECTION_OBJECT_PTR(ce); - object_init_ex(return_value, ce); - /* Run the constructor if there is one */ if (ce->constructor) { zval ***params; @@ -3198,6 +3286,77 @@ ZEND_METHOD(reflection_class, newInstance) RETURN_FALSE; } + object_init_ex(return_value, ce); + + fci.size = sizeof(fci); + fci.function_table = EG(function_table); + fci.function_name = NULL; + fci.symbol_table = NULL; + fci.object_pp = &return_value; + fci.retval_ptr_ptr = &retval_ptr; + fci.param_count = argc; + fci.params = params; + fci.no_separation = 1; + + fcc.initialized = 1; + fcc.function_handler = ce->constructor; + fcc.calling_scope = EG(scope); + fcc.object_pp = &return_value; + + if (zend_call_function(&fci, &fcc TSRMLS_CC) == FAILURE) { + efree(params); + zval_ptr_dtor(&retval_ptr); + zend_error(E_WARNING, "Invocation of %s's constructor failed", ce->name); + RETURN_NULL(); + } + if (retval_ptr) { + zval_ptr_dtor(&retval_ptr); + } + efree(params); + } else if (!ZEND_NUM_ARGS()) { + object_init_ex(return_value, ce); + } else { + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s does not have a constructor, so you cannot pass any constructor arguments", ce->name); + } +} +/* }}} */ + +/* {{{ proto public stdclass ReflectionClass::newInstanceArgs(array args) + Returns an instance of this class */ +ZEND_METHOD(reflection_class, newInstanceArgs) +{ + zval *retval_ptr; + reflection_object *intern; + zend_class_entry *ce; + int argc; + HashTable *args; + + + METHOD_NOTSTATIC(reflection_class_ptr); + GET_REFLECTION_OBJECT_PTR(ce); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|h", &args) == FAILURE) { + return; + } + argc = args->nNumOfElements; + + /* Run the constructor if there is one */ + if (ce->constructor) { + zval ***params; + zend_fcall_info fci; + zend_fcall_info_cache fcc; + + if (!(ce->constructor->common.fn_flags & ZEND_ACC_PUBLIC)) { + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Access to non-public constructor of class %s", ce->name); + return; + } + + 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); + params -= argc; + + object_init_ex(return_value, ce); + fci.size = sizeof(fci); fci.function_table = EG(function_table); fci.function_name = NULL; @@ -3223,6 +3382,10 @@ ZEND_METHOD(reflection_class, newInstance) zval_ptr_dtor(&retval_ptr); } efree(params); + } else if (!ZEND_NUM_ARGS()) { + object_init_ex(return_value, ce); + } else { + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s does not have a constructor, so you cannot pass any constructor arguments", ce->name); } } /* }}} */ @@ -3247,7 +3410,7 @@ ZEND_METHOD(reflection_class, getInterfaces) zval *interface; ALLOC_ZVAL(interface); zend_reflection_class_factory(ce->interfaces[i], interface TSRMLS_CC); - add_assoc_zval_ex(return_value, ce->interfaces[i]->name, ce->interfaces[i]->name_length, interface); + add_assoc_zval_ex(return_value, ce->interfaces[i]->name, ce->interfaces[i]->name_length + 1, interface); } } } @@ -3423,7 +3586,7 @@ ZEND_METHOD(reflection_object, export) } /* }}} */ -/* {{{ proto public ReflectionObject::__construct(mixed argument) throws ReflectionException +/* {{{ proto public void ReflectionObject::__construct(mixed argument) throws ReflectionException Constructor. Takes an instance as an argument */ ZEND_METHOD(reflection_object, __construct) { @@ -3439,7 +3602,7 @@ ZEND_METHOD(reflection_property, export) } /* }}} */ -/* {{{ proto public ReflectionProperty::__construct(mixed class, string name) +/* {{{ proto public void ReflectionProperty::__construct(mixed class, string name) Constructor. Throws an Exception in case the given property does not exist */ ZEND_METHOD(reflection_property, __construct) { @@ -3491,14 +3654,10 @@ ZEND_METHOD(reflection_property, __construct) if (!(property_info->flags & ZEND_ACC_PRIVATE)) { /* we have to seach the class hierarchy for this (implicit) public or protected property */ - zend_class_entry *tmp_ce = ce->parent; + 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) { - if (tmp_info->flags & ZEND_ACC_PRIVATE) { - /* private in super class => NOT the same property */ - break; - } + 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; tmp_ce = tmp_ce->parent; @@ -3724,11 +3883,19 @@ ZEND_METHOD(reflection_property, getDeclaringClass) { reflection_object *intern; property_reference *ref; + zend_class_entry *tmp_ce, *ce; + zend_property_info *tmp_info; METHOD_NOTSTATIC_NUMPARAMS(reflection_property_ptr, 0); GET_REFLECTION_OBJECT_PTR(ref); - zend_reflection_class_factory(ref->ce, return_value TSRMLS_CC); + ce = tmp_ce = ref->ce; + while (tmp_ce && zend_hash_find(&tmp_ce->properties_info, ref->prop->name, ref->prop->name_length + 1, (void **) &tmp_info) == SUCCESS) { + ce = tmp_ce; + tmp_ce = tmp_ce->parent; + } + + zend_reflection_class_factory(ce, return_value TSRMLS_CC); } /* {{{ proto public string ReflectionProperty::getDocComment() @@ -3754,7 +3921,7 @@ ZEND_METHOD(reflection_extension, export) } /* }}} */ -/* {{{ proto public ReflectionExtension::__construct(string name) +/* {{{ proto public void ReflectionExtension::__construct(string name) Constructor. Throws an Exception in case the given extension does not exist */ ZEND_METHOD(reflection_extension, __construct) { @@ -3983,6 +4150,58 @@ ZEND_METHOD(reflection_extension, getClassNames) } /* }}} */ +/* {{{ proto public array ReflectionExtension::getDependencies() + Returns an array containing all names of all extensions this extension depends on */ +ZEND_METHOD(reflection_extension, getDependencies) +{ + reflection_object *intern; + zend_module_entry *module; + zend_module_dep *dep; + + METHOD_NOTSTATIC_NUMPARAMS(reflection_extension_ptr, 0); + GET_REFLECTION_OBJECT_PTR(module); + + array_init(return_value); + + dep = module->deps; + + if (!dep) + { + return; + } + + while(dep->name) { + char *relation; + char *rel_type; + int len; + + switch(dep->type) { + case MODULE_DEP_REQUIRED: + rel_type = "Required"; + break; + case MODULE_DEP_CONFLICTS: + rel_type = "Conflicts"; + break; + case MODULE_DEP_OPTIONAL: + rel_type = "Optional"; + break; + default: + rel_type = "Error"; /* shouldn't happen */ + break; + } + + len = spprintf(&relation, 0, "%s%s%s%s%s", + rel_type, + dep->rel ? " " : "", + dep->rel ? dep->rel : "", + dep->version ? " " : "", + dep->version ? dep->version : ""); + add_assoc_stringl(return_value, dep->name, relation, len, 0); + dep++; + } +} +/* }}} */ + /* {{{ method tables */ static zend_function_entry reflection_exception_functions[] = { {NULL, NULL, NULL} @@ -4023,6 +4242,7 @@ static zend_function_entry reflection_function_functions[] = { ZEND_ME(reflection_function, getExtension, NULL, 0) ZEND_ME(reflection_function, getExtensionName, NULL, 0) #endif + ZEND_ME(reflection_function, isDeprecated, NULL, 0) {NULL, NULL, NULL} }; @@ -4076,6 +4296,7 @@ static zend_function_entry reflection_class_functions[] = { ZEND_ME(reflection_class, getModifiers, NULL, 0) ZEND_ME(reflection_class, isInstance, NULL, 0) ZEND_ME(reflection_class, newInstance, NULL, 0) + ZEND_ME(reflection_class, newInstanceArgs, NULL, 0) ZEND_ME(reflection_class, getParentClass, NULL, 0) ZEND_ME(reflection_class, isSubclassOf, NULL, 0) ZEND_ME(reflection_class, getStaticProperties, NULL, 0) @@ -4121,9 +4342,16 @@ static zend_function_entry reflection_parameter_functions[] = { ZEND_ME(reflection_parameter, __toString, NULL, 0) ZEND_ME(reflection_parameter, getName, NULL, 0) ZEND_ME(reflection_parameter, isPassedByReference, NULL, 0) +#if MBO_0 + ZEND_ME(reflection_parameter, getDeclaringFunction, NULL, 0) +#endif + ZEND_ME(reflection_parameter, getDeclaringClass, NULL, 0) ZEND_ME(reflection_parameter, getClass, NULL, 0) ZEND_ME(reflection_parameter, isArray, NULL, 0) ZEND_ME(reflection_parameter, allowsNull, NULL, 0) +#if MBO_0 + ZEND_ME(reflection_parameter, getPosition, NULL, 0) +#endif ZEND_ME(reflection_parameter, isOptional, NULL, 0) ZEND_ME(reflection_parameter, isDefaultValueAvailable, NULL, 0) ZEND_ME(reflection_parameter, getDefaultValue, NULL, 0) @@ -4142,6 +4370,7 @@ static zend_function_entry reflection_extension_functions[] = { ZEND_ME(reflection_extension, getINIEntries, NULL, 0) ZEND_ME(reflection_extension, getClasses, NULL, 0) ZEND_ME(reflection_extension, getClassNames, NULL, 0) + ZEND_ME(reflection_extension, getDependencies, NULL, 0) {NULL, NULL, NULL} }; /* }}} */ @@ -4195,6 +4424,8 @@ PHP_MINIT_FUNCTION(reflection) /* {{{ */ reflection_register_implement(reflection_function_ptr, reflector_ptr TSRMLS_CC); zend_declare_property_string(reflection_function_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC TSRMLS_CC); + REGISTER_REFLECTION_CLASS_CONST_LONG(function, "IS_DEPRECATED", ZEND_ACC_DEPRECATED); + INIT_CLASS_ENTRY(_reflection_entry, "ReflectionParameter", reflection_parameter_functions); _reflection_entry.create_object = reflection_objects_new; reflection_parameter_ptr = zend_register_internal_class(&_reflection_entry TSRMLS_CC); @@ -4207,12 +4438,12 @@ PHP_MINIT_FUNCTION(reflection) /* {{{ */ zend_declare_property_string(reflection_method_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC TSRMLS_CC); zend_declare_property_string(reflection_method_ptr, "class", sizeof("class")-1, "", ZEND_ACC_PUBLIC TSRMLS_CC); - REGISTER_REFLECTION_CLASS_CONST_LONG(method, "STATIC", ZEND_ACC_STATIC); - REGISTER_REFLECTION_CLASS_CONST_LONG(method, "PUBLIC", ZEND_ACC_PUBLIC); - REGISTER_REFLECTION_CLASS_CONST_LONG(method, "PROTECTED", ZEND_ACC_PROTECTED); - REGISTER_REFLECTION_CLASS_CONST_LONG(method, "PRIVATE", ZEND_ACC_PRIVATE); - REGISTER_REFLECTION_CLASS_CONST_LONG(method, "ABSTRACT", ZEND_ACC_ABSTRACT); - REGISTER_REFLECTION_CLASS_CONST_LONG(method, "FINAL", ZEND_ACC_FINAL); + REGISTER_REFLECTION_CLASS_CONST_LONG(method, "IS_STATIC", ZEND_ACC_STATIC); + REGISTER_REFLECTION_CLASS_CONST_LONG(method, "IS_PUBLIC", ZEND_ACC_PUBLIC); + REGISTER_REFLECTION_CLASS_CONST_LONG(method, "IS_PROTECTED", ZEND_ACC_PROTECTED); + REGISTER_REFLECTION_CLASS_CONST_LONG(method, "IS_PRIVATE", ZEND_ACC_PRIVATE); + REGISTER_REFLECTION_CLASS_CONST_LONG(method, "IS_ABSTRACT", ZEND_ACC_ABSTRACT); + REGISTER_REFLECTION_CLASS_CONST_LONG(method, "IS_FINAL", ZEND_ACC_FINAL); INIT_CLASS_ENTRY(_reflection_entry, "ReflectionClass", reflection_class_functions); _reflection_entry.create_object = reflection_objects_new; @@ -4220,9 +4451,9 @@ PHP_MINIT_FUNCTION(reflection) /* {{{ */ reflection_register_implement(reflection_class_ptr, reflector_ptr TSRMLS_CC); zend_declare_property_string(reflection_class_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC TSRMLS_CC); - REGISTER_REFLECTION_CLASS_CONST_LONG(class, "IMPLICIT_ABSTRACT", ZEND_ACC_IMPLICIT_ABSTRACT_CLASS); - REGISTER_REFLECTION_CLASS_CONST_LONG(class, "EXPLICIT_ABSTRACT", ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - REGISTER_REFLECTION_CLASS_CONST_LONG(class, "FINAL", ZEND_ACC_FINAL_CLASS); + REGISTER_REFLECTION_CLASS_CONST_LONG(class, "IS_IMPLICIT_ABSTRACT", ZEND_ACC_IMPLICIT_ABSTRACT_CLASS); + REGISTER_REFLECTION_CLASS_CONST_LONG(class, "IS_EXPLICIT_ABSTRACT", ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + REGISTER_REFLECTION_CLASS_CONST_LONG(class, "IS_FINAL", ZEND_ACC_FINAL_CLASS); INIT_CLASS_ENTRY(_reflection_entry, "ReflectionObject", reflection_object_functions); _reflection_entry.create_object = reflection_objects_new; @@ -4235,10 +4466,10 @@ PHP_MINIT_FUNCTION(reflection) /* {{{ */ zend_declare_property_string(reflection_property_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC TSRMLS_CC); zend_declare_property_string(reflection_property_ptr, "class", sizeof("class")-1, "", ZEND_ACC_PUBLIC TSRMLS_CC); - REGISTER_REFLECTION_CLASS_CONST_LONG(property, "STATIC", ZEND_ACC_STATIC); - REGISTER_REFLECTION_CLASS_CONST_LONG(property, "PUBLIC", ZEND_ACC_PUBLIC); - REGISTER_REFLECTION_CLASS_CONST_LONG(property, "PROTECTED", ZEND_ACC_PROTECTED); - REGISTER_REFLECTION_CLASS_CONST_LONG(property, "PRIVATE", ZEND_ACC_PRIVATE); + REGISTER_REFLECTION_CLASS_CONST_LONG(property, "IS_STATIC", ZEND_ACC_STATIC); + REGISTER_REFLECTION_CLASS_CONST_LONG(property, "IS_PUBLIC", ZEND_ACC_PUBLIC); + REGISTER_REFLECTION_CLASS_CONST_LONG(property, "IS_PROTECTED", ZEND_ACC_PROTECTED); + REGISTER_REFLECTION_CLASS_CONST_LONG(property, "IS_PRIVATE", ZEND_ACC_PRIVATE); INIT_CLASS_ENTRY(_reflection_entry, "ReflectionExtension", reflection_extension_functions); _reflection_entry.create_object = reflection_objects_new; @@ -4254,7 +4485,7 @@ PHP_MINFO_FUNCTION(reflection) /* {{{ */ php_info_print_table_start(); php_info_print_table_header(2, "Reflection", "enabled"); - php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v 1.164.2.17 2006/01/01 12:50:12 sniper Exp $"); + php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v 1.164.2.33 2006/03/29 14:28:42 tony2001 Exp $"); php_info_print_table_end(); } /* }}} */ diff --git a/ext/reflection/tests/001.phpt b/ext/reflection/tests/001.phpt index 6a9d31a30..55458885c 100755 --- a/ext/reflection/tests/001.phpt +++ b/ext/reflection/tests/001.phpt @@ -1,5 +1,7 @@ --TEST--
Reflection inheritance
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
diff --git a/ext/reflection/tests/002.phpt b/ext/reflection/tests/002.phpt index bef4c8166..9b233d372 100755 --- a/ext/reflection/tests/002.phpt +++ b/ext/reflection/tests/002.phpt @@ -1,5 +1,7 @@ --TEST--
Reflection properties are read only
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
diff --git a/ext/reflection/tests/003.phpt b/ext/reflection/tests/003.phpt index 660389255..af8d82d57 100755 --- a/ext/reflection/tests/003.phpt +++ b/ext/reflection/tests/003.phpt @@ -1,5 +1,7 @@ --TEST-- -invoke() with base class method +ReflectionMethod::invoke() with base class method +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> --FILE-- <?php diff --git a/ext/reflection/tests/004.phpt b/ext/reflection/tests/004.phpt index f8a448e6c..912d52654 100755 --- a/ext/reflection/tests/004.phpt +++ b/ext/reflection/tests/004.phpt @@ -1,5 +1,7 @@ --TEST--
-invoke() with non object or null value
+ReflectionMethod::invoke() with non object or null value
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
diff --git a/ext/reflection/tests/005.phpt b/ext/reflection/tests/005.phpt index f337e44ae..bedc7d032 100755 --- a/ext/reflection/tests/005.phpt +++ b/ext/reflection/tests/005.phpt @@ -1,5 +1,7 @@ --TEST-- ReflectionMethod::getDocComment() uses wrong comment block +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> --FILE-- <?php diff --git a/ext/reflection/tests/006.phpt b/ext/reflection/tests/006.phpt index 89c438765..9e97ae465 100755 --- a/ext/reflection/tests/006.phpt +++ b/ext/reflection/tests/006.phpt @@ -1,5 +1,7 @@ --TEST-- ReflectionClass::[gs]etStaticPropertyValue +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> --FILE-- <?php diff --git a/ext/reflection/tests/007.phpt b/ext/reflection/tests/007.phpt new file mode 100755 index 000000000..83764e551 --- /dev/null +++ b/ext/reflection/tests/007.phpt @@ -0,0 +1,162 @@ +--TEST-- +ReflectionClass::newInstance[Args] +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> +--FILE-- +<?php + +function test($class) +{ + echo "====>$class\n"; + try + { + $ref = new ReflectionClass($class); + } + catch (ReflectionException $e) + { + var_dump($e->getMessage()); + return; // only here + } + + echo "====>newInstance()\n"; + try + { + var_dump($ref->newInstance()); + } + catch (ReflectionException $e) + { + var_dump($e->getMessage()); + } + + echo "====>newInstance(25)\n"; + try + { + var_dump($ref->newInstance(25)); + } + catch (ReflectionException $e) + { + var_dump($e->getMessage()); + } + + echo "====>newInstance(25, 42)\n"; + try + { + var_dump($ref->newInstance(25, 42)); + } + catch (ReflectionException $e) + { + var_dump($e->getMessage()); + } + + echo "\n"; +} + +function __autoload($class) +{ + echo __FUNCTION__ . "($class)\n"; +} + +test('Class_does_not_exist'); + +Class NoCtor +{ +} + +test('NoCtor'); + +Class WithCtor +{ + function __construct() + { + echo __METHOD__ . "()\n"; + var_dump(func_get_args()); + } +} + +test('WithCtor'); + +Class WithCtorWithArgs +{ + function __construct($arg) + { + echo __METHOD__ . "($arg)\n"; + var_dump(func_get_args()); + } +} + +test('WithCtorWithArgs'); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- + +====>Class_does_not_exist +__autoload(Class_does_not_exist) +string(41) "Class Class_does_not_exist does not exist" +====>NoCtor +====>newInstance() +object(NoCtor)#%d (0) { +} +====>newInstance(25) +string(86) "Class NoCtor does not have a constructor, so you cannot pass any constructor arguments" +====>newInstance(25, 42) +string(86) "Class NoCtor does not have a constructor, so you cannot pass any constructor arguments" + +====>WithCtor +====>newInstance() +WithCtor::__construct() +array(0) { +} +object(WithCtor)#%d (0) { +} +====>newInstance(25) +WithCtor::__construct() +array(1) { + [0]=> + int(25) +} +object(WithCtor)#%d (0) { +} +====>newInstance(25, 42) +WithCtor::__construct() +array(2) { + [0]=> + int(25) + [1]=> + int(42) +} +object(WithCtor)#%d (0) { +} + +====>WithCtorWithArgs +====>newInstance() + +Warning: Missing argument 1 for WithCtorWithArgs::__construct() in %s007.php on line %d + +Notice: Undefined variable: arg in %s007.php on line %d +WithCtorWithArgs::__construct() +array(0) { +} +object(WithCtorWithArgs)#%d (0) { +} +====>newInstance(25) +WithCtorWithArgs::__construct(25) +array(1) { + [0]=> + int(25) +} +object(WithCtorWithArgs)#%d (0) { +} +====>newInstance(25, 42) +WithCtorWithArgs::__construct(25) +array(2) { + [0]=> + int(25) + [1]=> + int(42) +} +object(WithCtorWithArgs)#%d (0) { +} + +===DONE=== diff --git a/ext/reflection/tests/bug26640.phpt b/ext/reflection/tests/bug26640.phpt index 2cbd0d23d..026e67561 100755 --- a/ext/reflection/tests/bug26640.phpt +++ b/ext/reflection/tests/bug26640.phpt @@ -1,5 +1,7 @@ --TEST-- -Bug #26640 (__autoload() not invoked by Reflection classes) +Reflection Bug #26640 (__autoload() not invoked by Reflection classes) +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> --FILE-- <?php diff --git a/ext/reflection/tests/bug26695.phpt b/ext/reflection/tests/bug26695.phpt index 38e6607c3..c62395325 100755 --- a/ext/reflection/tests/bug26695.phpt +++ b/ext/reflection/tests/bug26695.phpt @@ -1,5 +1,7 @@ --TEST--
-Bug #26695 (Reflection API does not recognize mixed-case class hints)
+Reflection Bug #26695 (Reflection API does not recognize mixed-case class hints)
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
diff --git a/ext/reflection/tests/bug29268.phpt b/ext/reflection/tests/bug29268.phpt index 335ee7337..9f17a5e11 100755 --- a/ext/reflection/tests/bug29268.phpt +++ b/ext/reflection/tests/bug29268.phpt @@ -1,5 +1,7 @@ --TEST--
-Bug #29268 (__autoload() not called with reflectionProperty->getClass())
+Reflection Bug #29268 (__autoload() not called with reflectionProperty->getClass())
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
function __autoload($classname) {
@@ -14,8 +16,9 @@ class B{ $ref = new reflectionMethod('B','doit');
$parameters = $ref->getParameters();
-foreach($parameters as $parameter){
- $class = $parameter->getClass();
+foreach($parameters as $parameter)
+{
+ $class = $parameter->getClass();
echo $class->name."\n";
}
echo "ok\n";
diff --git a/ext/reflection/tests/bug29523.phpt b/ext/reflection/tests/bug29523.phpt index 4eb357cc2..e952d0ffe 100755 --- a/ext/reflection/tests/bug29523.phpt +++ b/ext/reflection/tests/bug29523.phpt @@ -1,5 +1,7 @@ --TEST--
-Bug #29523 (ReflectionParameter::isOptional() is incorrect)
+Reflection Bug #29523 (ReflectionParameter::isOptional() is incorrect)
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
diff --git a/ext/reflection/tests/bug29828.phpt b/ext/reflection/tests/bug29828.phpt index e1c9bbd36..f9052ac6b 100755 --- a/ext/reflection/tests/bug29828.phpt +++ b/ext/reflection/tests/bug29828.phpt @@ -1,5 +1,7 @@ --TEST--
-Bug #29828 (Interfaces no longer work)
+Reflection Bug #29828 (Interfaces no longer work)
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
diff --git a/ext/reflection/tests/bug29986.phpt b/ext/reflection/tests/bug29986.phpt new file mode 100644 index 000000000..85bad6d6e --- /dev/null +++ b/ext/reflection/tests/bug29986.phpt @@ -0,0 +1,41 @@ +--TEST-- +Reflection Bug #29986 (Class constants won't work with predefined constants when using ReflectionClass) +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> +--FILE-- +<?php +class just_constants +{ + const BOOLEAN_CONSTANT = true; + const NULL_CONSTANT = null; + const STRING_CONSTANT = 'This is a string'; + const INTEGER_CONSTANT = 1000; + const FLOAT_CONSTANT = 3.14159265; +} + +Reflection::export(new ReflectionClass('just_constants')); +?> +--EXPECTF-- +Class [ <user> class just_constants ] { + @@ %s + + - Constants [5] { + Constant [ boolean BOOLEAN_CONSTANT ] { } + Constant [ null NULL_CONSTANT ] { } + Constant [ string STRING_CONSTANT ] { } + Constant [ integer INTEGER_CONSTANT ] { } + Constant [ double FLOAT_CONSTANT ] { } + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [0] { + } + + - Methods [0] { + } +} diff --git a/ext/reflection/tests/bug30146.phpt b/ext/reflection/tests/bug30146.phpt index 72c6d2e5f..d7dd2fc21 100755 --- a/ext/reflection/tests/bug30146.phpt +++ b/ext/reflection/tests/bug30146.phpt @@ -1,5 +1,7 @@ --TEST--
-Bug #30146 (ReflectionProperty->getValue() requires instance for static property)
+Reflection Bug #30146 (ReflectionProperty->getValue() requires instance for static property)
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
class test {
diff --git a/ext/reflection/tests/bug30148.phpt b/ext/reflection/tests/bug30148.phpt index bc4415bfd..91bc31b65 100755 --- a/ext/reflection/tests/bug30148.phpt +++ b/ext/reflection/tests/bug30148.phpt @@ -1,5 +1,7 @@ --TEST--
-Bug #30148 (ReflectionMethod->isConstructor() fails for inherited classes)
+Reflection Bug #30148 (ReflectionMethod->isConstructor() fails for inherited classes)
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
diff --git a/ext/reflection/tests/bug30209.phpt b/ext/reflection/tests/bug30209.phpt index 6705c6704..bab16ee35 100755 --- a/ext/reflection/tests/bug30209.phpt +++ b/ext/reflection/tests/bug30209.phpt @@ -1,5 +1,7 @@ --TEST-- -Bug #30209 (ReflectionClass::getMethod() lowercases attribute) +Reflection Bug #30209 (ReflectionClass::getMethod() lowercases attribute) +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> --FILE-- <?php diff --git a/ext/reflection/tests/bug30856.phpt b/ext/reflection/tests/bug30856.phpt index 6c6d3171a..eaa6cf289 100755 --- a/ext/reflection/tests/bug30856.phpt +++ b/ext/reflection/tests/bug30856.phpt @@ -1,5 +1,7 @@ --TEST--
-Bug #30856 (ReflectionClass::getStaticProperties segfaults)
+Reflection Bug #30856 (ReflectionClass::getStaticProperties segfaults)
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
class bogus {
diff --git a/ext/reflection/tests/bug30961.phpt b/ext/reflection/tests/bug30961.phpt index 67964343e..c765e7cc8 100755 --- a/ext/reflection/tests/bug30961.phpt +++ b/ext/reflection/tests/bug30961.phpt @@ -1,5 +1,7 @@ --TEST--
-Bug #30961 (Wrong linenumber in ReflectionClass getStartLine())
+Reflection Bug #30961 (Wrong linenumber in ReflectionClass getStartLine())
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
class a
diff --git a/ext/reflection/tests/bug31651.phpt b/ext/reflection/tests/bug31651.phpt index 60bee14e9..66a56c0f4 100755 --- a/ext/reflection/tests/bug31651.phpt +++ b/ext/reflection/tests/bug31651.phpt @@ -1,5 +1,7 @@ --TEST-- -Bug #31651 (ReflectionClass::getDefaultProperties segfaults with arrays.) +Reflection Bug #31651 (ReflectionClass::getDefaultProperties segfaults with arrays.) +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> --FILE-- <?php diff --git a/ext/reflection/tests/bug32981.phpt b/ext/reflection/tests/bug32981.phpt index 1f89ca682..53214d7aa 100755 --- a/ext/reflection/tests/bug32981.phpt +++ b/ext/reflection/tests/bug32981.phpt @@ -1,5 +1,7 @@ --TEST-- -Bug #32981 (ReflectionMethod::getStaticVariables() causes apache2.0.54 seg fault) +Reflection Bug #32981 (ReflectionMethod::getStaticVariables() causes apache2.0.54 seg fault) +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> --FILE-- <?php diff --git a/ext/reflection/tests/bug33312.phpt b/ext/reflection/tests/bug33312.phpt index 3784b56a6..2413a3dc3 100755 --- a/ext/reflection/tests/bug33312.phpt +++ b/ext/reflection/tests/bug33312.phpt @@ -1,5 +1,7 @@ --TEST--
-Bug #33312 (ReflectionParameter methods do not work correctly)
+Reflection Bug #33312 (ReflectionParameter methods do not work correctly)
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
class Foo {
diff --git a/ext/reflection/tests/bug33389.phpt b/ext/reflection/tests/bug33389.phpt index 36f7079e2..d2a84e212 100755 --- a/ext/reflection/tests/bug33389.phpt +++ b/ext/reflection/tests/bug33389.phpt @@ -1,5 +1,7 @@ --TEST-- -Bug #33389 (double free() when exporting a ReflectionClass) +Reflection Bug #33389 (double free() when exporting a ReflectionClass) +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> --FILE-- <?php define ('foobar', 1); diff --git a/ext/reflection/tests/bug36308.phpt b/ext/reflection/tests/bug36308.phpt new file mode 100755 index 000000000..52717b474 --- /dev/null +++ b/ext/reflection/tests/bug36308.phpt @@ -0,0 +1,22 @@ +--TEST-- +Reflection Bug #36308 (ReflectionProperty::getDocComment() does not reflect extended class commentary) +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> +--FILE-- +<?php +class Base { + /** Base comment block */ + public $foo = 'bar'; +} + +class Extended extends Base { + /** Extended commentary */ + public $foo = 'zim'; +} + +$reflect = new ReflectionClass('Extended'); +$props = $reflect->getProperties(); +echo $props[0]->getDocComment(); +?> +--EXPECT-- +/** Extended commentary */
\ No newline at end of file diff --git a/ext/reflection/tests/bug36337.phpt b/ext/reflection/tests/bug36337.phpt new file mode 100644 index 000000000..8ec928fc8 --- /dev/null +++ b/ext/reflection/tests/bug36337.phpt @@ -0,0 +1,30 @@ +--TEST-- +Reflection Bug #36337 (ReflectionProperty fails to return correct visibility) +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> +--FILE-- +<?php + +abstract class enum { + protected $_values; + + public function __construct() { + $property = new ReflectionProperty(get_class($this),'_values'); + var_dump($property->isProtected()); + } + +} + +final class myEnum extends enum { + public $_values = array( + 0 => 'No value', + ); +} + +$x = new myEnum(); + +echo "Done\n"; +?> +--EXPECT-- +bool(false) +Done diff --git a/ext/reflection/tests/bug36434.phpt b/ext/reflection/tests/bug36434.phpt new file mode 100644 index 000000000..e305c657a --- /dev/null +++ b/ext/reflection/tests/bug36434.phpt @@ -0,0 +1,33 @@ +--TEST-- +Reflection Bug #36434 (Properties from parent class fail to indetify their true origin) +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> +--FILE-- +<?php +class ancester +{ +public $ancester = 0; + function ancester() + { + return $this->ancester; + } +} +class foo extends ancester +{ +public $bar = "1"; + function foo() + { + return $this->bar; + } +} + +$r = new ReflectionClass('foo'); +foreach ($r->GetProperties() as $p) +{ + echo $p->getName(). " ". $p->getDeclaringClass()->getName()."\n"; +} + +?> +--EXPECT-- +bar foo +ancester ancester diff --git a/ext/reflection/tests/parameters_001.phpt b/ext/reflection/tests/parameters_001.phpt index 0879756ea..036f11973 100755 --- a/ext/reflection/tests/parameters_001.phpt +++ b/ext/reflection/tests/parameters_001.phpt @@ -1,5 +1,7 @@ --TEST--
-Check for parameter being optional
+ReflectionParameter Check for parameter being optional
+--SKIPIF--
+<?php extension_loaded('reflection') or die('skip'); ?>
--FILE--
<?php
diff --git a/ext/reflection/tests/parameters_002.phpt b/ext/reflection/tests/parameters_002.phpt new file mode 100755 index 000000000..6f911448c --- /dev/null +++ b/ext/reflection/tests/parameters_002.phpt @@ -0,0 +1,209 @@ +--TEST-- +ReflectionParameter::getClass(), getDeclaringClass(), getDeclaringFunction() +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> +--FILE-- +<?php + +function test($nix, Array $ar, &$ref, stdClass $std, NonExistingClass $na, stdClass &$opt = NULL, $def = "FooBar") +{ +} + +class test +{ + function test($nix, Array $ar, &$ref, stdClass $std, NonExistingClass $na, stdClass $opt = NULL, $def = "FooBar") + { + } +} + +function check_params_decl_func($r, $f) +{ + $c = $r->$f(); + echo $f . ': ' . ($c ? ($c instanceof ReflectionMethod ? $c->class . '::' : '') . $c->name : 'NULL') . "()\n"; +} + +function check_params_decl_class($r, $f) +{ + $c = $r->$f(); + echo $f . ': ' . ($c ? $c->name : 'NULL') . "\n"; +} + +function check_params_func($r, $f) +{ + echo $f . ': '; + $v = $r->$f(); + var_dump($v); +} + +function check_params($r) +{ + echo "#####" . ($r instanceof ReflectionMethod ? $r->class . '::' : '') . $r->name . "()#####\n"; + $i = 0; + foreach($r->getParameters() as $p) + { + echo "===" . $i . "===\n"; + $i++; + check_params_func($p, 'getName'); + check_params_func($p, 'isPassedByReference'); + try + { + check_params_decl_class($p, 'getClass'); + } + catch(ReflectionException $e) + { + echo $e->getMessage() . "\n"; + } + check_params_decl_class($p, 'getDeclaringClass'); +// check_params_decl_func($p, 'getDeclaringFunction'); + check_params_func($p, 'isArray'); + check_params_func($p, 'allowsNull'); + check_params_func($p, 'isOptional'); + check_params_func($p, 'isDefaultValueAvailable'); + if ($p->isOptional()) + { + check_params_func($p, 'getDefaultValue'); + } + } +} + +check_params(new ReflectionFunction('test')); + +check_params(new ReflectionMethod('test::test')); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECT-- +#####test()##### +===0=== +getName: string(3) "nix" +isPassedByReference: bool(false) +getClass: NULL +getDeclaringClass: NULL +isArray: bool(false) +allowsNull: bool(true) +isOptional: bool(false) +isDefaultValueAvailable: bool(false) +===1=== +getName: string(2) "ar" +isPassedByReference: bool(false) +getClass: NULL +getDeclaringClass: NULL +isArray: bool(true) +allowsNull: bool(false) +isOptional: bool(false) +isDefaultValueAvailable: bool(false) +===2=== +getName: string(3) "ref" +isPassedByReference: bool(true) +getClass: NULL +getDeclaringClass: NULL +isArray: bool(false) +allowsNull: bool(true) +isOptional: bool(false) +isDefaultValueAvailable: bool(false) +===3=== +getName: string(3) "std" +isPassedByReference: bool(false) +getClass: stdClass +getDeclaringClass: NULL +isArray: bool(false) +allowsNull: bool(false) +isOptional: bool(false) +isDefaultValueAvailable: bool(false) +===4=== +getName: string(2) "na" +isPassedByReference: bool(false) +Class NonExistingClass does not exist +getDeclaringClass: NULL +isArray: bool(false) +allowsNull: bool(false) +isOptional: bool(false) +isDefaultValueAvailable: bool(false) +===5=== +getName: string(3) "opt" +isPassedByReference: bool(true) +getClass: stdClass +getDeclaringClass: NULL +isArray: bool(false) +allowsNull: bool(true) +isOptional: bool(true) +isDefaultValueAvailable: bool(true) +getDefaultValue: NULL +===6=== +getName: string(3) "def" +isPassedByReference: bool(false) +getClass: NULL +getDeclaringClass: NULL +isArray: bool(false) +allowsNull: bool(true) +isOptional: bool(true) +isDefaultValueAvailable: bool(true) +getDefaultValue: string(6) "FooBar" +#####test::test()##### +===0=== +getName: string(3) "nix" +isPassedByReference: bool(false) +getClass: NULL +getDeclaringClass: test +isArray: bool(false) +allowsNull: bool(true) +isOptional: bool(false) +isDefaultValueAvailable: bool(false) +===1=== +getName: string(2) "ar" +isPassedByReference: bool(false) +getClass: NULL +getDeclaringClass: test +isArray: bool(true) +allowsNull: bool(false) +isOptional: bool(false) +isDefaultValueAvailable: bool(false) +===2=== +getName: string(3) "ref" +isPassedByReference: bool(true) +getClass: NULL +getDeclaringClass: test +isArray: bool(false) +allowsNull: bool(true) +isOptional: bool(false) +isDefaultValueAvailable: bool(false) +===3=== +getName: string(3) "std" +isPassedByReference: bool(false) +getClass: stdClass +getDeclaringClass: test +isArray: bool(false) +allowsNull: bool(false) +isOptional: bool(false) +isDefaultValueAvailable: bool(false) +===4=== +getName: string(2) "na" +isPassedByReference: bool(false) +Class NonExistingClass does not exist +getDeclaringClass: test +isArray: bool(false) +allowsNull: bool(false) +isOptional: bool(false) +isDefaultValueAvailable: bool(false) +===5=== +getName: string(3) "opt" +isPassedByReference: bool(false) +getClass: stdClass +getDeclaringClass: test +isArray: bool(false) +allowsNull: bool(true) +isOptional: bool(true) +isDefaultValueAvailable: bool(true) +getDefaultValue: NULL +===6=== +getName: string(3) "def" +isPassedByReference: bool(false) +getClass: NULL +getDeclaringClass: test +isArray: bool(false) +allowsNull: bool(true) +isOptional: bool(true) +isDefaultValueAvailable: bool(true) +getDefaultValue: string(6) "FooBar" +===DONE=== diff --git a/ext/reflection/tests/property_exists.phpt b/ext/reflection/tests/property_exists.phpt index fa712dfdb..8fd45f2b8 100755 --- a/ext/reflection/tests/property_exists.phpt +++ b/ext/reflection/tests/property_exists.phpt @@ -1,5 +1,7 @@ --TEST-- -ZE2 property_exists() +Reflection and property_exists() +--SKIPIF-- +<?php extension_loaded('reflection') or die('skip'); ?> --FILE-- <?php diff --git a/ext/reflection/tests/static_properties_002.phpt b/ext/reflection/tests/static_properties_002.phpt index 29b84a8e6..051b9fb10 100755 --- a/ext/reflection/tests/static_properties_002.phpt +++ b/ext/reflection/tests/static_properties_002.phpt @@ -1,7 +1,7 @@ --TEST-- -ZE2 Inheriting static properties +Reflection and inheriting static properties --SKIPIF-- -<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?> +<?php extension_loaded('reflection') or die('skip'); ?> --FILE-- <?php |
