cvs: ZendEngine2(PHP_5_0) / zend_builtin_functions.c

From: Date: Tue, 12 Oct 2004 11:03:37 +0000
Subject: cvs: ZendEngine2(PHP_5_0) / zend_builtin_functions.c
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-3093@lists.php.net to get a copy of this message
helly Tue Oct 12 07:03:37 2004 EDT Modified files: (Branch: PHP_5_0) /ZendEngine2 zend_builtin_functions.c Log: MFH Fix visibility of get_class_vars() and get_class_methods() http://cvs.php.net/diff.php/ZendEngine2/zend_builtin_functions.c?r1=1.239.2.9&r2=1.239.2.10&ty=u Index: ZendEngine2/zend_builtin_functions.c diff -u ZendEngine2/zend_builtin_functions.c:1.239.2.9 ZendEngine2/zend_builtin_functions.c:1.239.2.10 --- ZendEngine2/zend_builtin_functions.c:1.239.2.9 Tue Oct 12 05:16:17 2004 +++ ZendEngine2/zend_builtin_functions.c Tue Oct 12 07:03:35 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_builtin_functions.c,v 1.239.2.9 2004/10/12 09:16:17 helly Exp $ */ +/* $Id: zend_builtin_functions.c,v 1.239.2.10 2004/10/12 11:03:35 helly Exp $ */ #include "zend.h" #include "zend_API.h" @@ -663,6 +663,7 @@ { zval **class_name; zend_class_entry *ce, **pce; + int instanceof; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &class_name)==FAILURE) { ZEND_WRONG_PARAM_COUNT(); @@ -674,6 +675,9 @@ RETURN_FALSE; } else { ce = *pce; + + instanceof = EG(scope) && instanceof_function(EG(scope), ce TSRMLS_CC); + array_init(return_value); if (zend_hash_num_elements(&ce->default_properties) > 0) { @@ -690,9 +694,14 @@ zend_hash_get_current_key_ex(&ce->default_properties, &key, &key_len, &num_index, 0, &pos); zend_hash_move_forward_ex(&ce->default_properties, &pos); zend_unmangle_property_name(key, &class_name, &prop_name); - if (class_name && class_name[0] != '*' && strcmp(class_name, ce->name)) { - /* filter privates from base classes */ - continue; + if (class_name) { + if (class_name[0] != '*' && strcmp(class_name, ce->name)) { + /* filter privates from base classes */ + continue; + } else if (!instanceof) { + /* filter protected if not inside class */ + continue; + } } /* copy: enforce read only access */ @@ -776,6 +785,7 @@ zend_class_entry *ce = NULL, **pce; HashPosition pos; zend_function *mptr; + int instanceof; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &class)==FAILURE) { ZEND_WRONG_PARAM_COUNT(); @@ -797,18 +807,22 @@ RETURN_NULL(); } + instanceof = EG(scope) && instanceof_function(EG(scope), ce TSRMLS_CC); + array_init(return_value); zend_hash_internal_pointer_reset_ex(&ce->function_table, &pos); while (zend_hash_get_current_data_ex(&ce->function_table, (void **) &mptr, &pos) == SUCCESS) { - MAKE_STD_ZVAL(method_name); - ZVAL_STRING(method_name, mptr->common.function_name, 1); - zend_hash_next_index_insert(return_value->value.ht, &method_name, sizeof(zval *), NULL); + if ((mptr->common.fn_flags & ZEND_ACC_PUBLIC) + || (instanceof && ((mptr->common.fn_flags & ZEND_ACC_PROTECTED) || EG(scope) == mptr->common.scope))) { + MAKE_STD_ZVAL(method_name); + ZVAL_STRING(method_name, mptr->common.function_name, 1); + zend_hash_next_index_insert(return_value->value.ht, &method_name, sizeof(zval *), NULL); + } zend_hash_move_forward_ex(&ce->function_table, &pos); } } /* }}} */ -\ /* {{{ proto bool method_exists(object object, string method)

« previous php.zend-engine.cvs (#3093) next »