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;
+ }
}
zend_reflection_class_factory(ce, return_value TSRMLS_CC);
--- /dev/null
+--TEST--
+Bug #39067 (getDeclaringClass() and private properties)
+--FILE--
+<?php
+
+class A {
+ private $x;
+}
+
+class B extends A {
+ private $x;
+}
+
+class C extends B {
+ private $x;
+}
+
+$rc = new ReflectionClass('C');
+var_dump($rc->getProperty('x')->getDeclaringClass()->getName());
+
+$rc = new ReflectionClass('B');
+var_dump($rc->getProperty('x')->getDeclaringClass()->getName());
+
+$rc = new ReflectionClass('A');
+var_dump($rc->getProperty('x')->getDeclaringClass()->getName());
+
+echo "Done\n";
+?>
+--EXPECTF--
+string(1) "C"
+string(1) "B"
+string(1) "A"
+Done