bjori Sat Jun 10 00:40:57 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/reflection php_reflection.c php_reflection.h Log: MFH - 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.164.2.33.2.6&r2=1.164.2.33.2.7&diff_format=u Index: php-src/ext/reflection/php_reflection.c diff -u php-src/ext/reflection/php_reflection.c:1.164.2.33.2.6 php-src/ext/reflection/php_reflection.c:1.164.2.33.2.7 --- php-src/ext/reflection/php_reflection.c:1.164.2.33.2.6 Wed Jun 7 22:39:22 2006 +++ php-src/ext/reflection/php_reflection.c Sat Jun 10 00:40:56 2006 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_reflection.c,v 1.164.2.33.2.6 2006/06/07 22:39:22 helly Exp $ */ +/* $Id: php_reflection.c,v 1.164.2.33.2.7 2006/06/10 00:40:56 bjori Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -48,6 +48,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; @@ -1370,7 +1371,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); @@ -1382,7 +1383,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); } /* }}} */ @@ -1394,7 +1395,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); } @@ -1407,7 +1408,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); } @@ -1420,7 +1421,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); @@ -1436,7 +1437,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); @@ -1452,7 +1453,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); @@ -1468,7 +1469,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); @@ -1485,7 +1486,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 */ @@ -1621,7 +1622,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); @@ -1635,7 +1636,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); @@ -1649,7 +1650,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); @@ -1665,7 +1666,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; @@ -1692,7 +1693,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) { @@ -1718,7 +1719,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) { @@ -4274,9 +4275,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) @@ -4287,8 +4287,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) @@ -4301,6 +4299,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) @@ -4402,7 +4407,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 @@ -4502,12 +4507,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() @@ -4636,10 +4641,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); @@ -4652,7 +4662,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); @@ -4703,7 +4713,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.164.2.33.2.6 2006/06/07 22:39:22 helly Exp $"); + php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v 1.164.2.33.2.7 2006/06/10 00:40:56 bjori Exp $"); php_info_print_table_end(); } /* }}} */ @@ -4727,4 +4737,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.4.2.3&r2=1.4.2.3.2.1&diff_format=u Index: php-src/ext/reflection/php_reflection.h diff -u php-src/ext/reflection/php_reflection.h:1.4.2.3 php-src/ext/reflection/php_reflection.h:1.4.2.3.2.1 --- php-src/ext/reflection/php_reflection.h:1.4.2.3 Sun Jan 1 12:50:12 2006 +++ php-src/ext/reflection/php_reflection.h Sat Jun 10 00:40:57 2006 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_reflection.h,v 1.4.2.3 2006/01/01 12:50:12 sniper Exp $ */ +/* $Id: php_reflection.h,v 1.4.2.3.2.1 2006/06/10 00:40:57 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