tony2001 Mon Oct 2 12:15:47 2006 UTC Added files: /php-src/ext/reflection/tests bug39001.phpt
Modified files: /php-src/ext/reflection php_reflection.c Log: fix #39001 (ReflectionProperty returns incorrect declaring class for protected properties) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/php_reflection.c?r1=1.256&r2=1.257&diff_format=u Index: php-src/ext/reflection/php_reflection.c diff -u php-src/ext/reflection/php_reflection.c:1.256 php-src/ext/reflection/php_reflection.c:1.257 --- php-src/ext/reflection/php_reflection.c:1.256 Tue Sep 26 07:55:54 2006 +++ php-src/ext/reflection/php_reflection.c Mon Oct 2 12:15:47 2006 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_reflection.c,v 1.256 2006/09/26 07:55:54 dmitry Exp $ */ +/* $Id: php_reflection.c,v 1.257 2006/10/02 12:15:47 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -4080,12 +4080,19 @@ property_reference *ref; zend_class_entry *tmp_ce, *ce; zend_property_info *tmp_info; + zstr prop_name, class_name; + int prop_name_len; METHOD_NOTSTATIC_NUMPARAMS(reflection_property_ptr, 0); GET_REFLECTION_OBJECT_PTR(ref); + if (zend_u_unmangle_property_name(UG(unicode)?IS_UNICODE:IS_STRING, ref->prop->name, ref->prop->name_length, &class_name, &prop_name) != SUCCESS) { + RETURN_FALSE; + } + + 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, ref->prop->name, ref->prop->name_length + 1, (void **) &tmp_info) == SUCCESS) { + 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) { ce = tmp_ce; tmp_ce = tmp_ce->parent; } @@ -4896,7 +4903,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.256 2006/09/26 07:55:54 dmitry Exp $"); + php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v 1.257 2006/10/02 12:15:47 tony2001 Exp $"); php_info_print_table_end(); } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/bug39001.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/bug39001.phpt +++ php-src/ext/reflection/tests/bug39001.phpt --TEST-- Bug #39001 (ReflectionProperty returns incorrect declaring class for protected properties) --FILE-- <?php class Meta { } class CParent extends Meta { public $publicVar; protected $protectedVar; } class Child extends CParent { } $r = new ReflectionClass('Child'); var_dump($r->getProperty('publicVar')->getDeclaringClass()->getName()); var_dump($r->getProperty('protectedVar')->getDeclaringClass()->getName()); echo "Done\n"; ?> --EXPECTF-- string(7) "CParent" string(7) "CParent" Done --UEXPECTF-- unicode(7) "CParent" unicode(7) "CParent" Done -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php