From 415b75e3f58a737d8946fbccb5bb2cc58580c7eb Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Thu, 21 May 2009 16:05:11 +0000 Subject: [PATCH] MFH: Fixed bug #48336 (ReflectionProperty::getDeclaringClass() does not work with redeclared property) (patch by Markus dot Lidel at shadowconnect dot com) --- NEWS | 2 ++ ext/reflection/php_reflection.c | 4 +++ ext/reflection/tests/bug48336.phpt | 44 ++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 ext/reflection/tests/bug48336.phpt diff --git a/NEWS b/NEWS index b6714bf631..6c21b9c897 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,8 @@ PHP NEWS - Fixed segfault on invalid session.save_path. (Hannes) - Fixed leaks in imap when a mail_criteria is used. (Pierre) +- Fixed bug #48336 (ReflectionProperty::getDeclaringClass() does not work with + redeclared property). (patch by Markus dot Lidel at shadowconnect dot com) - Fixed bug #48326 (constant MSG_DONTWAIT not defined). (Arnaud) - Fixed bug #48313 (fgetcsv() does not return null for empty rows). (Ilia) - Fixed bug #48309 (stream_copy_to_stream() and fpasstru() do not update stream diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 944cf3f24b..f11639a615 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -4126,6 +4126,10 @@ ZEND_METHOD(reflection_property, getDeclaringClass) break; } ce = tmp_ce; + if (tmp_ce == tmp_info->ce) { + /* declared in this class, done */ + break; + } tmp_ce = tmp_ce->parent; } diff --git a/ext/reflection/tests/bug48336.phpt b/ext/reflection/tests/bug48336.phpt new file mode 100644 index 0000000000..ee90675f0c --- /dev/null +++ b/ext/reflection/tests/bug48336.phpt @@ -0,0 +1,44 @@ +--TEST-- +Bug #48286 (ReflectionProperty::getDeclaringClass() does not work with redeclared properties) +--FILE-- + '); + try { + $rp = new ReflectionProperty($class, 'prop'); + print($rp->getDeclaringClass()->getName()); + } catch(Exception $e) { + print('N/A'); + } + print("\n"); +} +?> +--EXPECT-- +A => N/A +B => B +C => C +D => C +E => C +F => F -- 2.50.1