]> granicus.if.org Git - php/commitdiff
more improvements
authorAntony Dovgal <tony2001@php.net>
Fri, 6 Oct 2006 18:02:50 +0000 (18:02 +0000)
committerAntony Dovgal <tony2001@php.net>
Fri, 6 Oct 2006 18:02:50 +0000 (18:02 +0000)
ext/reflection/php_reflection.c
ext/reflection/tests/bug39067.phpt

index b3e97c69089b26a959ee7a49035295df88803d4c..26de54bbbf75eaa9d8e70c7c0555ac34ed019362 100644 (file)
@@ -4099,12 +4099,12 @@ ZEND_METHOD(reflection_property, getDeclaringClass)
        prop_name_len = USTR_LEN(prop_name);
        ce = tmp_ce = ref->ce;
        while (tmp_ce && zend_u_hash_find(&tmp_ce->properties_info, UG(unicode)?IS_UNICODE:IS_STRING, prop_name, prop_name_len + 1, (void **) &tmp_info) == SUCCESS) {
-               ce = tmp_ce;
-               tmp_ce = tmp_ce->parent;
                if (tmp_info->flags & ZEND_ACC_PRIVATE) {
                        /* it's a private property, so it can't be inherited */
                        break;
                }
+               ce = tmp_ce;
+               tmp_ce = tmp_ce->parent;
        }
 
        zend_reflection_class_factory(ce, return_value TSRMLS_CC);
index c225dc4954fb67c8598e083f5ba191ee10bfde6e..71e859a2c7702c0cb0828eb3d4a81dd1ad92d940 100644 (file)
@@ -24,15 +24,28 @@ var_dump($rc->getProperty('x')->getDeclaringClass()->getName());
 $rc = new ReflectionClass('A');
 var_dump($rc->getProperty('x')->getDeclaringClass()->getName());
 
+class Test {
+       private $x;
+}
+
+class Test2 extends Test {
+       public $x;
+}
+
+$rc = new ReflectionClass('Test2');
+var_dump($rc->getProperty('x')->getDeclaringClass()->getName());
+
 echo "Done\n";
 ?>
 --EXPECTF--    
 string(1) "C"
 string(1) "B"
 string(1) "A"
+string(5) "Test2"
 Done
 --UEXPECTF--
 unicode(1) "C"
 unicode(1) "B"
 unicode(1) "A"
+unicode(4) "Test2"
 Done