]> granicus.if.org Git - php/commitdiff
Allow passing class name as well as an object instance to call methods.
authorAndrei Zmievski <andrei@php.net>
Sun, 4 Feb 2001 00:06:08 +0000 (00:06 +0000)
committerAndrei Zmievski <andrei@php.net>
Sun, 4 Feb 2001 00:06:08 +0000 (00:06 +0000)
Zend/zend_execute_API.c

index 0e3b4eb4c0829b37e8280972826cc2cb1a31d19a..61087edf634fb35ed2d1ff447fc70182ad2628b8 100644 (file)
@@ -365,10 +365,18 @@ int call_user_function_ex(HashTable *function_table, zval **object_pp, zval *fun
                object_pp = NULL;
        }
        if (object_pp) {
-               if (Z_TYPE_PP(object_pp) != IS_OBJECT) {
+               if (Z_TYPE_PP(object_pp) == IS_OBJECT) {
+                       function_table = &(*object_pp)->value.obj.ce->function_table;
+               } else if (Z_TYPE_PP(object_pp) == IS_STRING) {
+                       zend_class_entry *ce;
+
+                       if (zend_hash_find(EG(class_table), Z_STRVAL_PP(object_pp), Z_STRLEN_PP(object_pp) + 1, (void **) &ce)==FAILURE)
+                               return FAILURE;
+
+                       function_table = &ce->function_table;
+                       object_pp = NULL;
+               } else
                        return FAILURE;
-               }
-               function_table = &(*object_pp)->value.obj.ce->function_table;
        }
 
        if (function_name->type!=IS_STRING) {