On Thu, 2004-02-26 at 01:33, Timm Friebe wrote: > On Wed, 2004-02-25 at 15:41, Andi Gutmans wrote: > > Quick reminder... > > If you have any bugs to fix, please fix them in the coming days.
...and another one: $ cat protected.php <?php class A { protected function __construct() { echo "Constructor was called\n"; } } $r= new Reflection_Class('A'); var_dump($r->newInstance()); ?> $ php-dev protected.php Constructor was called object(A)#2 (0) { } This should not be allowed. The following patch includes a fix for this and the problems mentioned with Reflection_Property:: getDeclaringClass(). - Timm
Index: Zend/zend_reflection_api.c =================================================================== RCS file: /repository/ZendEngine2/zend_reflection_api.c,v retrieving revision 1.88 diff -u -r1.88 zend_reflection_api.c --- Zend/zend_reflection_api.c 25 Feb 2004 08:58:56 -0000 1.88 +++ Zend/zend_reflection_api.c 26 Feb 2004 04:52:32 -0000 @@ -771,7 +771,10 @@ zend_class_entry *tmp_ce = ce->parent; zend_property_info *tmp_info; - while (tmp_ce && zend_hash_find(&ce->properties_info, prop_name, strlen(prop_name) + 1, (void **) &tmp_info) == SUCCESS) { + while (tmp_ce && zend_hash_find(&tmp_ce->properties_info, prop_name, strlen(prop_name) + 1, (void **) &tmp_info) == SUCCESS) { + if (tmp_info->flags != prop->flags) { /* private in super class, public in child => NOT the same property */ + break; + } ce = tmp_ce; prop = tmp_info; tmp_ce = tmp_ce->parent; @@ -2298,6 +2301,14 @@ zend_fcall_info fci; zend_fcall_info_cache fcc; + if (!(ce->constructor->common.fn_flags & ZEND_ACC_PUBLIC)) { + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + "Acess to non-public constructor of class %s", + ce->name + ); + return; + } + params = safe_emalloc(sizeof(zval **), argc, 0); if (zend_get_parameters_array_ex(argc, params) == FAILURE) { efree(params); @@ -2564,19 +2575,22 @@ "Property %s::$%s does not exist", ce->name, name_str); return; } - free_alloca(lcname); - + if (!(property_info->flags & ZEND_ACC_PRIVATE)) { /* we have to seach the class hierarchy for this (implicit) public or protected property */ zend_class_entry *tmp_ce = ce->parent; zend_property_info *tmp_info; - while (tmp_ce && zend_hash_find(&ce->properties_info, name_str, name_len + 1, (void **) &tmp_info) == SUCCESS) { + while (tmp_ce && zend_hash_find(&tmp_ce->properties_info, lcname, name_len + 1, (void **) &tmp_info) == SUCCESS) { + if (tmp_info->flags != property_info->flags) { /* private in super class, public in child => NOT the same property */ + break; + } ce = tmp_ce; property_info = tmp_info; tmp_ce = tmp_ce->parent; } } + free_alloca(lcname); MAKE_STD_ZVAL(classname); ZVAL_STRINGL(classname, ce->name, ce->name_length, 1);
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php