]> granicus.if.org Git - php/commitdiff
Fixed bug #37764
authorHannes Magnusson <bjori@php.net>
Sat, 10 Jun 2006 00:28:28 +0000 (00:28 +0000)
committerHannes Magnusson <bjori@php.net>
Sat, 10 Jun 2006 00:28:28 +0000 (00:28 +0000)
- 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

ext/reflection/php_reflection.c
ext/reflection/php_reflection.h

index df80e7e5900ad48a4826ee13606385db20ac6c6f..b9bf53c1bb19fdc64777066dde36f31fed0d4890 100644 (file)
@@ -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_METHOD(reflection_function, __toString)
        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 @@ ZEND_METHOD(reflection_function, __toString)
    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 @@ ZEND_METHOD(reflection, function_isInternal)
        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 @@ ZEND_METHOD(reflection_function, isUserDefined)
        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 @@ ZEND_METHOD(reflection_function, getFileName)
        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 @@ ZEND_METHOD(reflection_function, getStartLine)
        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 @@ ZEND_METHOD(reflection_function, getEndLine)
        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 @@ ZEND_METHOD(reflection_function, getDocComment)
        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 @@ ZEND_METHOD(reflection_function, getStaticVariables)
        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 @@ ZEND_METHOD(reflection_function, returnsReference)
        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 @@ ZEND_METHOD(reflection_function, getNumberOfParameters)
        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 @@ ZEND_METHOD(reflection_function, getNumberOfRequiredParameters)
        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_METHOD(reflection_function, getParameters)
        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_METHOD(reflection_function, getExtension)
        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_METHOD(reflection_function, getExtensionName)
        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_BEGIN_ARG_INFO(arginfo_reflection_function_invokeArgs, 0)
        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 @@ static zend_function_entry reflection_function_functions[] = {
        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 @@ static zend_function_entry reflection_function_functions[] = {
        {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 @@ ZEND_END_ARG_INFO()
 
 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 @@ ZEND_END_ARG_INFO()
 
 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 @@ PHP_MINIT_FUNCTION(reflection) /* {{{ */
        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 @@ PHP_MINIT_FUNCTION(reflection) /* {{{ */
 
        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);
 
@@ -4785,4 +4795,5 @@ zend_module_entry reflection_module_entry = { /* {{{ */
  * c-basic-offset: 4
  * indent-tabs-mode: t
  * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
  */
index 1f660ae15331f41f3c1e482db1d4934725b4f836..de3cdfbbc1bee86749ed9f2e385d0ce25a6f6d8a 100644 (file)
@@ -32,6 +32,7 @@ BEGIN_EXTERN_C()
 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;