]> granicus.if.org Git - php/commitdiff
MFH
authorHannes Magnusson <bjori@php.net>
Sat, 10 Jun 2006 00:40:57 +0000 (00:40 +0000)
committerHannes Magnusson <bjori@php.net>
Sat, 10 Jun 2006 00:40:57 +0000 (00:40 +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 311136293cb1a8fb25a2e6c450f4e6b1c8a837c3..904d867ccba6a869c0d4c51772951da5b2dab46c 100644 (file)
@@ -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_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);
@@ -1382,7 +1383,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);
 }
 /* }}} */
@@ -1394,7 +1395,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);
 }
@@ -1407,7 +1408,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);
 }
@@ -1420,7 +1421,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);
@@ -1436,7 +1437,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);
@@ -1452,7 +1453,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);
@@ -1468,7 +1469,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);
@@ -1485,7 +1486,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 */
@@ -1621,7 +1622,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);
@@ -1635,7 +1636,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);
@@ -1649,7 +1650,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);
@@ -1665,7 +1666,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;
@@ -1692,7 +1693,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) {
@@ -1718,7 +1719,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) {
@@ -4274,9 +4275,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)
@@ -4287,8 +4287,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)
@@ -4301,6 +4299,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)
@@ -4402,7 +4407,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
@@ -4502,12 +4507,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()
 
@@ -4636,10 +4641,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);
@@ -4652,7 +4662,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);
 
@@ -4727,4 +4737,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;