diff options
author | Moriyoshi Koizumi <moriyoshi@php.net> | 2002-11-26 21:21:32 +0000 |
---|---|---|
committer | Moriyoshi Koizumi <moriyoshi@php.net> | 2002-11-26 21:21:32 +0000 |
commit | 61b3d5ccb525d7524704c42a555a36eb868b803e (patch) | |
tree | 540bf9274fa639ade63638838921e0ec795a888e | |
parent | 397b35f891d7c8c5139b79876f21a90a621f661b (diff) | |
download | php-git-61b3d5ccb525d7524704c42a555a36eb868b803e.tar.gz |
Fixed incorrect error messages of array_walk() in case the callback is
specified in an array form
-rw-r--r-- | ext/standard/array.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/ext/standard/array.c b/ext/standard/array.c index 0ee5f9f8e8..84534e236c 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -980,8 +980,37 @@ static int php_array_walk(HashTable *target_hash, zval **userdata TSRMLS_DC) zval_ptr_dtor(&retval_ptr); } else { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to call %s() - function does not exist", + if (Z_TYPE_PP(BG(array_walk_func_name)) == IS_STRING) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to call %s() - function does not exist", (*BG(array_walk_func_name))->value.str.val); + } else if (Z_TYPE_PP(BG(array_walk_func_name)) == IS_ARRAY) { + char *obj_name = NULL; + zval **obj; + zval **mt_name; + + if (zend_hash_index_find(Z_ARRVAL_PP(BG(array_walk_func_name)), + 0, (void **)&obj) == SUCCESS + && zend_hash_index_find(Z_ARRVAL_PP(BG(array_walk_func_name)), + 1, (void **)&mt_name) == SUCCESS + && Z_TYPE_PP(mt_name) == IS_STRING) { + switch (Z_TYPE_PP(obj)) { + case IS_OBJECT: + obj_name = Z_OBJ_PP(obj)->ce->name; + break; + + case IS_STRING: + obj_name = Z_STRVAL_PP(obj); + break; + } + } + + if (obj_name != NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to call %s::%s() - function does not exist", + obj_name, Z_STRVAL_PP(mt_name)); + } else { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid function name"); + } + } } zend_hash_move_forward_ex(target_hash, &pos); |