summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnaud Le Blanc <lbarnaud@php.net>2009-05-21 16:01:37 +0000
committerArnaud Le Blanc <lbarnaud@php.net>2009-05-21 16:01:37 +0000
commit5c5dcf5e7ae716570a03d45a2df18abb7de229e3 (patch)
tree9a35503d773bba7bcdd9c142e1b9ad1b6927ec3d
parent9aca3c04a074ed79308c823b5eacae0e8ba1dc53 (diff)
downloadphp-git-5c5dcf5e7ae716570a03d45a2df18abb7de229e3.tar.gz
MFH: Fixed bug #48336 (ReflectionProperty::getDeclaringClass() does not
work with redeclared property) (patch by Markus dot Lidel at shadowconnect dot com)
-rw-r--r--ext/reflection/php_reflection.c4
-rw-r--r--ext/reflection/tests/bug48336.phpt44
2 files changed, 48 insertions, 0 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 5e14ec4fbe..93fb1701fb 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -4603,6 +4603,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--
+<?php
+class A {
+}
+
+class B extends A {
+ static protected $prop;
+}
+
+class C extends B {
+ static protected $prop;
+}
+
+class D extends C {
+}
+
+class E extends D {
+}
+
+class F extends E {
+ static protected $prop;
+}
+
+$class = 'A';
+for($class = 'A'; $class <= 'F'; $class ++) {
+ print($class.' => ');
+ 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