diff options
author | Antony Dovgal <tony2001@php.net> | 2006-10-06 17:35:32 +0000 |
---|---|---|
committer | Antony Dovgal <tony2001@php.net> | 2006-10-06 17:35:32 +0000 |
commit | d917bf084c9db42123a5e43436c9370f19d6c69c (patch) | |
tree | 1e267a3cf954ab84df8b08d93a8be3fcbbed4826 | |
parent | eed736d010201c39ce753c04d4820365d176a0e8 (diff) | |
download | php-git-d917bf084c9db42123a5e43436c9370f19d6c69c.tar.gz |
MFH: fix #39067 (getDeclaringClass() and private properties)
-rw-r--r-- | ext/reflection/php_reflection.c | 4 | ||||
-rw-r--r-- | ext/reflection/tests/bug39067.phpt | 33 |
2 files changed, 37 insertions, 0 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index a733a6a2f3..280f635188 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -4029,6 +4029,10 @@ ZEND_METHOD(reflection_property, getDeclaringClass) 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); diff --git a/ext/reflection/tests/bug39067.phpt b/ext/reflection/tests/bug39067.phpt new file mode 100644 index 0000000000..a3bf2ad092 --- /dev/null +++ b/ext/reflection/tests/bug39067.phpt @@ -0,0 +1,33 @@ +--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 |