felipe          Sun Jun  1 03:13:54 2008 UTC

  Modified files:              
    /php-src/ext/reflection     php_reflection.c 
    /php-src/ext/reflection/tests       bug45139.phpt 
  Log:
  - MFB: Fixed bug #45139 (ReflectionProperty returns incorrect declaring class)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/php_reflection.c?r1=1.295&r2=1.296&diff_format=u
Index: php-src/ext/reflection/php_reflection.c
diff -u php-src/ext/reflection/php_reflection.c:1.295 
php-src/ext/reflection/php_reflection.c:1.296
--- php-src/ext/reflection/php_reflection.c:1.295       Mon Feb 18 14:31:01 2008
+++ php-src/ext/reflection/php_reflection.c     Sun Jun  1 03:13:54 2008
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_reflection.c,v 1.295 2008/02/18 14:31:01 dmitry Exp $ */
+/* $Id: php_reflection.c,v 1.296 2008/06/01 03:13:54 felipe Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -4202,7 +4202,7 @@
        prop_name_len = USTR_LEN(prop_name);
        ce = tmp_ce = ref->ce;
        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) {
-               if (tmp_info->flags & ZEND_ACC_PRIVATE) {
+               if (tmp_info->flags & ZEND_ACC_PRIVATE || tmp_info->flags & 
ZEND_ACC_SHADOW) {
                        /* it's a private property, so it can't be inherited */
                        break;
                }
@@ -5060,7 +5060,7 @@
        php_info_print_table_start();
        php_info_print_table_header(2, "Reflection", "enabled");
 
-       php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v 1.295 
2008/02/18 14:31:01 dmitry Exp $");
+       php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v 1.296 
2008/06/01 03:13:54 felipe Exp $");
 
        php_info_print_table_end();
 } /* }}} */
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/bug45139.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/reflection/tests/bug45139.phpt
diff -u /dev/null php-src/ext/reflection/tests/bug45139.phpt:1.2
--- /dev/null   Sun Jun  1 03:13:54 2008
+++ php-src/ext/reflection/tests/bug45139.phpt  Sun Jun  1 03:13:54 2008
@@ -0,0 +1,58 @@
+--TEST--
+Bug #45139 (ReflectionProperty returns incorrect declaring class)
+--FILE--
+<?php
+
+class A {
+       private $foo;
+}
+
+class B extends A {
+       protected $bar;
+       private $baz;
+       private $quux;
+}
+
+class C extends B {
+       public $foo;
+       private $baz;
+       protected $quux;
+}
+
+$rc = new ReflectionClass('C');
+$rp = $rc->getProperty('foo');
+var_dump($rp->getDeclaringClass()->getName()); // c
+
+$rc = new ReflectionClass('A');
+$rp = $rc->getProperty('foo');
+var_dump($rp->getDeclaringClass()->getName()); // A
+
+$rc = new ReflectionClass('B');
+$rp = $rc->getProperty('bar');
+var_dump($rp->getDeclaringClass()->getName()); // B
+
+$rc = new ReflectionClass('C');
+$rp = $rc->getProperty('bar');
+var_dump($rp->getDeclaringClass()->getName()); // B
+
+$rc = new ReflectionClass('C');
+$rp = $rc->getProperty('baz');
+var_dump($rp->getDeclaringClass()->getName()); // C
+
+$rc = new ReflectionClass('B');
+$rp = $rc->getProperty('baz');
+var_dump($rp->getDeclaringClass()->getName()); // B
+
+$rc = new ReflectionClass('C');
+$rp = $rc->getProperty('quux');
+var_dump($rp->getDeclaringClass()->getName()); // C
+
+?>
+--EXPECT--
+unicode(1) "C"
+unicode(1) "A"
+unicode(1) "B"
+unicode(1) "B"
+unicode(1) "C"
+unicode(1) "B"
+unicode(1) "C"



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to