diff options
author | Andi Gutmans <andi@php.net> | 2004-04-03 21:50:12 +0000 |
---|---|---|
committer | Andi Gutmans <andi@php.net> | 2004-04-03 21:50:12 +0000 |
commit | 8838b38fcbc90a74fb7c499d72813b559aad2101 (patch) | |
tree | c04314ef04d91832af4adc163365315c140921ec | |
parent | efb62ea35f8ca19eeaf06316f34fab83af1a93e3 (diff) | |
download | php-git-8838b38fcbc90a74fb7c499d72813b559aad2101.tar.gz |
Patch by Timm Friebe:
It changes
set_exception_handler() to accept the pseudo-type "callable" (instead of
a string referring to a global function).
Examples:
set_exception_handler('function_name');
set_exception_handler(array('class_name', 'static_method'));
set_exception_handler(array($instance, 'instance_method'));
This also makes set_exception_handler() more consistent with all the
other callback functionality, e.g. set_error_handler().
-rw-r--r-- | Zend/zend_builtin_functions.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 42a82754dc..53fdaeeeed 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -1009,18 +1009,26 @@ ZEND_FUNCTION(restore_error_handler) /* }}} */ -/* {{{ proto string set_exception_handler(string exception_handler) +/* {{{ proto string set_exception_handler(callable exception_handler) Sets a user-defined exception handler function. Returns the previously defined exception handler, or false on error */ ZEND_FUNCTION(set_exception_handler) { zval **exception_handler; + char *exception_handler_name = NULL; zend_bool had_orig_exception_handler=0; if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &exception_handler)==FAILURE) { ZEND_WRONG_PARAM_COUNT(); } - convert_to_string_ex(exception_handler); + if (!zend_is_callable(*exception_handler, 0, &exception_handler_name)) { + zend_error(E_WARNING, "%s() expects the argument (%s) to be a valid callback", + get_active_function_name(TSRMLS_C), exception_handler_name?exception_handler_name:"unknown"); + efree(exception_handler_name); + return; + } + efree(exception_handler_name); + if (EG(user_exception_handler)) { had_orig_exception_handler = 1; *return_value = *EG(user_exception_handler); |