]> granicus.if.org Git - php/commitdiff
- MFH
authorAndi Gutmans <andi@php.net>
Tue, 26 Oct 2004 23:25:34 +0000 (23:25 +0000)
committerAndi Gutmans <andi@php.net>
Tue, 26 Oct 2004 23:25:34 +0000 (23:25 +0000)
Zend/zend_builtin_functions.c

index a4947d20a00e782e11e4de04559d543cffe8b0d0..db7921b45202be7359185b2db33b5593136f5d64 100644 (file)
@@ -603,12 +603,21 @@ static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool only_subclass)
                ZEND_WRONG_PARAM_COUNT();
        }
 
-       if (Z_TYPE_PP(obj) != IS_OBJECT) {
+       if (only_subclass && Z_TYPE_PP(obj) == IS_STRING) {
+               zend_class_entry **the_ce;
+               if (zend_lookup_class(Z_STRVAL_PP(obj), Z_STRLEN_PP(obj), &the_ce TSRMLS_CC) == FAILURE) {
+                       zend_error(E_WARNING, "Unknown class passed as parameter");
+                       RETURN_FALSE;
+               }
+               instance_ce = *the_ce;          
+       } else if (Z_TYPE_PP(obj) != IS_OBJECT) {
                RETURN_FALSE;
+       } else {
+               instance_ce = NULL;
        }
        
        /* TBI!! new object handlers */
-       if (!HAS_CLASS_ENTRY(**obj)) {
+       if (Z_TYPE_PP(obj) == IS_OBJECT && !HAS_CLASS_ENTRY(**obj)) {
                RETURN_FALSE;
        }
 
@@ -618,7 +627,11 @@ static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool only_subclass)
                retval = 0;
        } else {
                if (only_subclass) {
-                       instance_ce = Z_OBJCE_PP(obj)->parent;
+                       if (!instance_ce) {
+                               instance_ce = Z_OBJCE_PP(obj)->parent;
+                       } else {
+                               instance_ce = instance_ce->parent;
+                       }
                } else {
                        instance_ce = Z_OBJCE_PP(obj);
                }