bjori Sat Jun 10 00:28:28 2006 UTC Modified files: /php-src/ext/reflection php_reflection.c php_reflection.h Log: Fixed bug #37764 - Created new abstract class, ReflectionFunctionAbstract implementing Reflector - Moved all methods from ReflectionFunction (except export, invoke & invokeArgs) - ReflectionFunction now inherits everything from ReflectionFunctionAbstract and implements its own export, invoke & invokeArgs methods - ReflectionMethod now extends ReflectionFunctionAbstract and implements its own export, invoke & invokeArgs methods. - Removed stdClass typehint from ReflectionClass::isInstance - Removed stdClass typehint from ReflectionClass::set/getValue
http://cvs.php.net/viewcvs.cgi/php-src/ext/reflection/php_reflection.c?r1=1.234&r2=1.235&diff_format=u Index: php-src/ext/reflection/php_reflection.c diff -u php-src/ext/reflection/php_reflection.c:1.234 php-src/ext/reflection/php_reflection.c:1.235 --- php-src/ext/reflection/php_reflection.c:1.234 Wed Jun 7 22:39:00 2006 +++ php-src/ext/reflection/php_reflection.c Sat Jun 10 00:28:28 2006 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_reflection.c,v 1.234 2006/06/07 22:39:00 helly Exp $ */ +/* $Id: php_reflection.c,v 1.235 2006/06/10 00:28:28 bjori Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -43,6 +43,7 @@ PHPAPI zend_class_entry *reflector_ptr; PHPAPI zend_class_entry *reflection_exception_ptr; PHPAPI zend_class_entry *reflection_ptr; +PHPAPI zend_class_entry *reflection_function_abstract_ptr; PHPAPI zend_class_entry *reflection_function_ptr; PHPAPI zend_class_entry *reflection_parameter_ptr; PHPAPI zend_class_entry *reflection_class_ptr; @@ -1381,7 +1382,7 @@ zend_function *fptr; string str; - METHOD_NOTSTATIC_NUMPARAMS(reflection_function_ptr, 0); + METHOD_NOTSTATIC_NUMPARAMS(reflection_function_abstract_ptr, 0); GET_REFLECTION_OBJECT_PTR(fptr); string_init(&str); _function_string(&str, fptr, intern->ce, "" TSRMLS_CC); @@ -1393,7 +1394,7 @@ Returns this function's name */ ZEND_METHOD(reflection, function_getName) { - METHOD_NOTSTATIC_NUMPARAMS(reflection_function_ptr, 0); + METHOD_NOTSTATIC_NUMPARAMS(reflection_function_abstract_ptr, 0); _default_get_entry(getThis(), "name", sizeof("name"), return_value TSRMLS_CC); } /* }}} */ @@ -1405,7 +1406,7 @@ reflection_object *intern; zend_function *fptr; - METHOD_NOTSTATIC_NUMPARAMS(reflection_function_ptr, 0); + METHOD_NOTSTATIC_NUMPARAMS(reflection_function_abstract_ptr, 0); GET_REFLECTION_OBJECT_PTR(fptr); RETURN_BOOL(fptr->type == ZEND_INTERNAL_FUNCTION); } @@ -1418,7 +1419,7 @@ reflection_object *intern; zend_function *fptr; - METHOD_NOTSTATIC_NUMPARAMS(reflection_function_ptr, 0); + METHOD_NOTSTATIC_NUMPARAMS(reflection_function_abstract_ptr, 0); GET_REFLECTION_OBJECT_PTR(fptr); RETURN_BOOL(fptr->type == ZEND_USER_FUNCTION); } @@ -1431,7 +1432,7 @@ reflection_object *intern; zend_function *fptr; - METHOD_NOTSTATIC_NUMPARAMS(reflection_function_ptr, 0); + METHOD_NOTSTATIC_NUMPARAMS(reflection_function_abstract_ptr, 0); GET_REFLECTION_OBJECT_PTR(fptr); if (fptr->type == ZEND_USER_FUNCTION) { RETURN_STRING(fptr->op_array.filename, 1); @@ -1447,7 +1448,7 @@ reflection_object *intern; zend_function *fptr; - METHOD_NOTSTATIC_NUMPARAMS(reflection_function_ptr, 0); + METHOD_NOTSTATIC_NUMPARAMS(reflection_function_abstract_ptr, 0); GET_REFLECTION_OBJECT_PTR(fptr); if (fptr->type == ZEND_USER_FUNCTION) { RETURN_LONG(fptr->op_array.line_start); @@ -1463,7 +1464,7 @@ reflection_object *intern; zend_function *fptr; - METHOD_NOTSTATIC_NUMPARAMS(reflection_function_ptr, 0); + METHOD_NOTSTATIC_NUMPARAMS(reflection_function_abstract_ptr, 0); GET_REFLECTION_OBJECT_PTR(fptr); if (fptr->type == ZEND_USER_FUNCTION) { RETURN_LONG(fptr->op_array.line_end); @@ -1479,7 +1480,7 @@ reflection_object *intern; zend_function *fptr; - METHOD_NOTSTATIC_NUMPARAMS(reflection_function_ptr, 0); + METHOD_NOTSTATIC_NUMPARAMS(reflection_function_abstract_ptr, 0); GET_REFLECTION_OBJECT_PTR(fptr); if (fptr->type == ZEND_USER_FUNCTION && fptr->op_array.doc_comment) { RETURN_STRINGL(fptr->op_array.doc_comment, fptr->op_array.doc_comment_len, 1); @@ -1496,7 +1497,7 @@ reflection_object *intern; zend_function *fptr; - METHOD_NOTSTATIC_NUMPARAMS(reflection_function_ptr, 0); + METHOD_NOTSTATIC_NUMPARAMS(reflection_function_abstract_ptr, 0); GET_REFLECTION_OBJECT_PTR(fptr); /* Return an empty array in case no static variables exist */ @@ -1632,7 +1633,7 @@ reflection_object *intern; zend_function *fptr; - METHOD_NOTSTATIC(reflection_function_ptr); + METHOD_NOTSTATIC(reflection_function_abstract_ptr); GET_REFLECTION_OBJECT_PTR(fptr); RETURN_BOOL(fptr->op_array.return_reference); @@ -1646,7 +1647,7 @@ reflection_object *intern; zend_function *fptr; - METHOD_NOTSTATIC(reflection_function_ptr); + METHOD_NOTSTATIC(reflection_function_abstract_ptr); GET_REFLECTION_OBJECT_PTR(fptr); RETURN_LONG(fptr->common.num_args); @@ -1660,7 +1661,7 @@ reflection_object *intern; zend_function *fptr; - METHOD_NOTSTATIC(reflection_function_ptr); + METHOD_NOTSTATIC(reflection_function_abstract_ptr); GET_REFLECTION_OBJECT_PTR(fptr); RETURN_LONG(fptr->common.required_num_args); @@ -1676,7 +1677,7 @@ zend_uint i; struct _zend_arg_info *arg_info; - METHOD_NOTSTATIC(reflection_function_ptr); + METHOD_NOTSTATIC(reflection_function_abstract_ptr); GET_REFLECTION_OBJECT_PTR(fptr); arg_info= fptr->common.arg_info; @@ -1702,7 +1703,7 @@ zend_function *fptr; zend_internal_function *internal; - METHOD_NOTSTATIC(reflection_function_ptr); + METHOD_NOTSTATIC(reflection_function_abstract_ptr); GET_REFLECTION_OBJECT_PTR(fptr); if (fptr->type != ZEND_INTERNAL_FUNCTION) { @@ -1726,7 +1727,7 @@ zend_function *fptr; zend_internal_function *internal; - METHOD_NOTSTATIC(reflection_function_ptr); + METHOD_NOTSTATIC(reflection_function_abstract_ptr); GET_REFLECTION_OBJECT_PTR(fptr); if (fptr->type != ZEND_INTERNAL_FUNCTION) { @@ -4337,9 +4338,8 @@ ZEND_ARG_ARRAY_INFO(0, args, 0) ZEND_END_ARG_INFO() -static zend_function_entry reflection_function_functions[] = { +static zend_function_entry reflection_function_abstract_functions[] = { ZEND_ME(reflection, __clone, NULL, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL) - ZEND_ME(reflection_function, export, arginfo_reflection_function_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC) ZEND_ME(reflection_function, __construct, arginfo_reflection_function___construct, 0) ZEND_ME(reflection_function, __toString, NULL, 0) ZEND_ME(reflection_function, isInternal, NULL, 0) @@ -4350,8 +4350,6 @@ ZEND_ME(reflection_function, getEndLine, NULL, 0) ZEND_ME(reflection_function, getDocComment, NULL, 0) ZEND_ME(reflection_function, getStaticVariables, NULL, 0) - ZEND_ME(reflection_function, invoke, arginfo_reflection_function_invoke, 0) - ZEND_ME(reflection_function, invokeArgs, arginfo_reflection_function_invokeArgs, 0) ZEND_ME(reflection_function, returnsReference, NULL, 0) ZEND_ME(reflection_function, getParameters, NULL, 0) ZEND_ME(reflection_function, getNumberOfParameters, NULL, 0) @@ -4362,6 +4360,13 @@ {NULL, NULL, NULL} }; +static zend_function_entry reflection_function_functions[] = { + ZEND_ME(reflection_function, export, arginfo_reflection_function_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC) + ZEND_ME(reflection_function, invoke, arginfo_reflection_function_invoke, 0) + ZEND_ME(reflection_function, invokeArgs, arginfo_reflection_function_invokeArgs, 0) + {NULL, NULL, NULL} +}; + static ZEND_BEGIN_ARG_INFO_EX(arginfo_reflection_method_export, 0, 0, 2) ZEND_ARG_INFO(0, class) @@ -4463,7 +4468,7 @@ static ZEND_BEGIN_ARG_INFO(arginfo_reflection_class_isInstance, 0) - ZEND_ARG_OBJ_INFO(0, object, stdClass, 0) + ZEND_ARG_INFO(0, object) ZEND_END_ARG_INFO() static @@ -4563,12 +4568,12 @@ static ZEND_BEGIN_ARG_INFO(arginfo_reflection_property_getValue, 0) - ZEND_ARG_OBJ_INFO(0, object, stdClass, 0) + ZEND_ARG_INFO(0, object) ZEND_END_ARG_INFO() static ZEND_BEGIN_ARG_INFO(arginfo_reflection_property_setValue, 0) - ZEND_ARG_OBJ_INFO(0, object, stdClass, 0) + ZEND_ARG_INFO(0, object) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() @@ -4694,10 +4699,15 @@ INIT_CLASS_ENTRY(_reflection_entry, "Reflector", reflector_functions); reflector_ptr = zend_register_internal_interface(&_reflection_entry TSRMLS_CC); + INIT_CLASS_ENTRY(_reflection_entry, "ReflectionFunctionAbstract", reflection_function_abstract_functions); + _reflection_entry.create_object = reflection_objects_new; + reflection_function_abstract_ptr = zend_register_internal_class(&_reflection_entry TSRMLS_CC); + reflection_register_implement(reflection_function_abstract_ptr, reflector_ptr TSRMLS_CC); + zend_declare_property_string(reflection_function_abstract_ptr, "name", sizeof("name")-1, "", ZEND_ACC_ABSTRACT TSRMLS_CC); + INIT_CLASS_ENTRY(_reflection_entry, "ReflectionFunction", reflection_function_functions); _reflection_entry.create_object = reflection_objects_new; - reflection_function_ptr = zend_register_internal_class(&_reflection_entry TSRMLS_CC); - reflection_register_implement(reflection_function_ptr, reflector_ptr TSRMLS_CC); + reflection_function_ptr = zend_register_internal_class_ex(&_reflection_entry, reflection_function_abstract_ptr, NULL 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); @@ -4710,7 +4720,7 @@ INIT_CLASS_ENTRY(_reflection_entry, "ReflectionMethod", reflection_method_functions); _reflection_entry.create_object = reflection_objects_new; - reflection_method_ptr = zend_register_internal_class_ex(&_reflection_entry, reflection_function_ptr, NULL TSRMLS_CC); + reflection_method_ptr = zend_register_internal_class_ex(&_reflection_entry, reflection_function_abstract_ptr, NULL TSRMLS_CC); 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); @@ -4761,7 +4771,7 @@ 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.234 2006/06/07 22:39:00 helly Exp $"); + php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v 1.235 2006/06/10 00:28:28 bjori Exp $"); php_info_print_table_end(); } /* }}} */ @@ -4785,4 +4795,5 @@ * c-basic-offset: 4 * indent-tabs-mode: t * End: + * vim600: noet sw=4 ts=4 fdm=marker */ http://cvs.php.net/viewcvs.cgi/php-src/ext/reflection/php_reflection.h?r1=1.10&r2=1.11&diff_format=u Index: php-src/ext/reflection/php_reflection.h diff -u php-src/ext/reflection/php_reflection.h:1.10 php-src/ext/reflection/php_reflection.h:1.11 --- php-src/ext/reflection/php_reflection.h:1.10 Sun Jan 1 13:09:53 2006 +++ php-src/ext/reflection/php_reflection.h Sat Jun 10 00:28:28 2006 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_reflection.h,v 1.10 2006/01/01 13:09:53 sniper Exp $ */ +/* $Id: php_reflection.h,v 1.11 2006/06/10 00:28:28 bjori Exp $ */ #ifndef PHP_REFLECTION_H #define PHP_REFLECTION_H @@ -32,6 +32,7 @@ extern PHPAPI zend_class_entry *reflector_ptr; extern PHPAPI zend_class_entry *reflection_exception_ptr; extern PHPAPI zend_class_entry *reflection_ptr; +extern PHPAPI zend_class_entry *reflection_function_abstract_ptr; extern PHPAPI zend_class_entry *reflection_function_ptr; extern PHPAPI zend_class_entry *reflection_parameter_ptr; extern PHPAPI zend_class_entry *reflection_class_ptr;
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php