]> granicus.if.org Git - php/commitdiff
MFH: Fixed bug #48336 (ReflectionProperty::getDeclaringClass() does not
authorArnaud Le Blanc <lbarnaud@php.net>
Thu, 21 May 2009 16:05:11 +0000 (16:05 +0000)
committerArnaud Le Blanc <lbarnaud@php.net>
Thu, 21 May 2009 16:05:11 +0000 (16:05 +0000)
work with redeclared property)
(patch by Markus dot Lidel at shadowconnect dot com)

NEWS
ext/reflection/php_reflection.c
ext/reflection/tests/bug48336.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index b6714bf6318b6e80f797abc407d7ca000fa0f7db..6c21b9c897233ed930e6ae6e820904e80bcc8b5c 100644 (file)
--- 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
index 944cf3f24bb3de222da0dbb303b09a5291fce03b..f11639a61543672c97c683049df5817e7716ac68 100644 (file)
@@ -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 (file)
index 0000000..ee90675
--- /dev/null
@@ -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