]> granicus.if.org Git - php/commitdiff
Fix problem with Reflection_Property (patch from Timm slightly modified).
authorMarcus Boerger <helly@php.net>
Thu, 26 Feb 2004 01:06:18 +0000 (01:06 +0000)
committerMarcus Boerger <helly@php.net>
Thu, 26 Feb 2004 01:06:18 +0000 (01:06 +0000)
Zend/zend_reflection_api.c
ext/reflection/php_reflection.c

index 3bc7112b8b21c8616a81cb865d0596407860eb63..0d4dd48eb9e5590b371451e191e7e06ecce31118 100644 (file)
@@ -771,7 +771,11 @@ static void reflection_property_factory(zend_class_entry *ce, zend_property_info
                zend_class_entry *tmp_ce = ce->parent;
                zend_property_info *tmp_info;
                
-               while (tmp_ce && zend_hash_find(&ce->properties_info, prop_name, strlen(prop_name) + 1, (void **) &tmp_info) == SUCCESS) {
+               while (tmp_ce && zend_hash_find(&tmp_ce->properties_info, prop_name, strlen(prop_name) + 1, (void **) &tmp_info) == SUCCESS) {
+                       if (tmp_info->flags & ZEND_ACC_PRIVATE) {
+                               /* private in super class => NOT the same property */
+                               break;
+                       }
                        ce = tmp_ce;
                        prop = tmp_info;
                        tmp_ce = tmp_ce->parent;
@@ -2564,20 +2568,25 @@ ZEND_METHOD(reflection_property, __construct)
                        "Property %s::$%s does not exist", ce->name, name_str);
                return;
        }
-       free_alloca(lcname);
        
        if (!(property_info->flags & ZEND_ACC_PRIVATE)) {
                /* we have to seach the class hierarchy for this (implicit) public or protected property */
                zend_class_entry *tmp_ce = ce->parent;
                zend_property_info *tmp_info;
                
-               while (tmp_ce && zend_hash_find(&ce->properties_info, name_str, name_len + 1, (void **) &tmp_info) == SUCCESS) {
+               while (tmp_ce && zend_hash_find(&tmp_ce->properties_info, lcname, name_len + 1, (void **) &tmp_info) == SUCCESS) {
+                       if (tmp_info->flags & ZEND_ACC_PRIVATE) {
+                               /* private in super class => NOT the same property */
+                               break;
+                       }
                        ce = tmp_ce;
                        property_info = tmp_info;
                        tmp_ce = tmp_ce->parent;
                }
        }
 
+       free_alloca(lcname);
+
        MAKE_STD_ZVAL(classname);
        ZVAL_STRINGL(classname, ce->name, ce->name_length, 1);
        zend_hash_update(Z_OBJPROP_P(object), "class", sizeof("class"), (void **) &classname, sizeof(zval *), NULL);
index 3bc7112b8b21c8616a81cb865d0596407860eb63..0d4dd48eb9e5590b371451e191e7e06ecce31118 100644 (file)
@@ -771,7 +771,11 @@ static void reflection_property_factory(zend_class_entry *ce, zend_property_info
                zend_class_entry *tmp_ce = ce->parent;
                zend_property_info *tmp_info;
                
-               while (tmp_ce && zend_hash_find(&ce->properties_info, prop_name, strlen(prop_name) + 1, (void **) &tmp_info) == SUCCESS) {
+               while (tmp_ce && zend_hash_find(&tmp_ce->properties_info, prop_name, strlen(prop_name) + 1, (void **) &tmp_info) == SUCCESS) {
+                       if (tmp_info->flags & ZEND_ACC_PRIVATE) {
+                               /* private in super class => NOT the same property */
+                               break;
+                       }
                        ce = tmp_ce;
                        prop = tmp_info;
                        tmp_ce = tmp_ce->parent;
@@ -2564,20 +2568,25 @@ ZEND_METHOD(reflection_property, __construct)
                        "Property %s::$%s does not exist", ce->name, name_str);
                return;
        }
-       free_alloca(lcname);
        
        if (!(property_info->flags & ZEND_ACC_PRIVATE)) {
                /* we have to seach the class hierarchy for this (implicit) public or protected property */
                zend_class_entry *tmp_ce = ce->parent;
                zend_property_info *tmp_info;
                
-               while (tmp_ce && zend_hash_find(&ce->properties_info, name_str, name_len + 1, (void **) &tmp_info) == SUCCESS) {
+               while (tmp_ce && zend_hash_find(&tmp_ce->properties_info, lcname, name_len + 1, (void **) &tmp_info) == SUCCESS) {
+                       if (tmp_info->flags & ZEND_ACC_PRIVATE) {
+                               /* private in super class => NOT the same property */
+                               break;
+                       }
                        ce = tmp_ce;
                        property_info = tmp_info;
                        tmp_ce = tmp_ce->parent;
                }
        }
 
+       free_alloca(lcname);
+
        MAKE_STD_ZVAL(classname);
        ZVAL_STRINGL(classname, ce->name, ce->name_length, 1);
        zend_hash_update(Z_OBJPROP_P(object), "class", sizeof("class"), (void **) &classname, sizeof(zval *), NULL);