From: Antony Dovgal Date: Fri, 6 Oct 2006 17:34:56 +0000 (+0000) Subject: fix #39067 (getDeclaringClass() and private properties) X-Git-Tag: RELEASE_1_0_0RC1~1388 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c65d3234cd998f6a3dd306e3d1a13fd43a86fb98;p=php fix #39067 (getDeclaringClass() and private properties) --- diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 3d2045faa6..b3e97c6908 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -4101,6 +4101,10 @@ ZEND_METHOD(reflection_property, getDeclaringClass) 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; + } } zend_reflection_class_factory(ce, return_value TSRMLS_CC); diff --git a/ext/reflection/tests/bug39067.phpt b/ext/reflection/tests/bug39067.phpt new file mode 100644 index 0000000000..c225dc4954 --- /dev/null +++ b/ext/reflection/tests/bug39067.phpt @@ -0,0 +1,38 @@ +--TEST-- +Bug #39067 (getDeclaringClass() and private properties) +--FILE-- +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 +--UEXPECTF-- +unicode(1) "C" +unicode(1) "B" +unicode(1) "A" +Done