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

index 280f63518848361c32c7ef0c5688f9905069cd1c..55189cda8003d6564314ee6292c50929a5ffa9a8 100644 (file)
@@ -4027,12 +4027,12 @@ ZEND_METHOD(reflection_property, getDeclaringClass)
        prop_name_len = strlen(prop_name);
        ce = tmp_ce = ref->ce;
        while (tmp_ce && zend_hash_find(&tmp_ce->properties_info, 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 a3bf2ad0922420da061f7a2f647eeaeeb46a3d17..8a7a6044e1b90a82b13c81139feec64219389f0f 100644 (file)
@@ -24,10 +24,22 @@ 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