diff --git a/Zend/tests/error_handler_001.phpt b/Zend/tests/error_handler_001.phpt new file mode 100644 index 0000000000000..23c0ad131b956 --- /dev/null +++ b/Zend/tests/error_handler_001.phpt @@ -0,0 +1,32 @@ +--TEST-- +error handler tests - 1 +--FILE-- + +--EXPECTF-- +NULL +NULL +int(512) +string(4) "test" +string(%d) "%s/Zend/tests/error_handler_001.php" +int(7) +bool(true) +NULL +Done + diff --git a/Zend/tests/exception_handler_007.phpt b/Zend/tests/exception_handler_007.phpt new file mode 100644 index 0000000000000..58f2526d63494 --- /dev/null +++ b/Zend/tests/exception_handler_007.phpt @@ -0,0 +1,30 @@ +--TEST-- +exception handler tests - 1 +--FILE-- + +--EXPECTF-- +NULL +NULL +string(12) "test thrown!" +bool(true) +NULL diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 32f210e44c37a..97e5b27ed66b8 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -68,8 +68,10 @@ static ZEND_FUNCTION(get_object_vars); static ZEND_FUNCTION(get_class_methods); static ZEND_FUNCTION(trigger_error); static ZEND_FUNCTION(set_error_handler); +static ZEND_FUNCTION(get_error_handler); static ZEND_FUNCTION(restore_error_handler); static ZEND_FUNCTION(set_exception_handler); +static ZEND_FUNCTION(get_exception_handler); static ZEND_FUNCTION(restore_exception_handler); static ZEND_FUNCTION(get_declared_classes); static ZEND_FUNCTION(get_declared_traits); @@ -286,8 +288,10 @@ static const zend_function_entry builtin_functions[] = { /* {{{ */ ZEND_FE(trigger_error, arginfo_trigger_error) ZEND_FALIAS(user_error, trigger_error, arginfo_trigger_error) ZEND_FE(set_error_handler, arginfo_set_error_handler) + ZEND_FE(get_error_handler, arginfo_zend__void) ZEND_FE(restore_error_handler, arginfo_zend__void) ZEND_FE(set_exception_handler, arginfo_set_exception_handler) + ZEND_FE(get_exception_handler, arginfo_zend__void) ZEND_FE(restore_exception_handler, arginfo_zend__void) ZEND_FE(get_declared_classes, arginfo_zend__void) ZEND_FE(get_declared_traits, arginfo_zend__void) @@ -1656,6 +1660,20 @@ ZEND_FUNCTION(set_error_handler) } /* }}} */ +/* {{{ proto string get_error_handler(void) + Returns the currently defined error handler, or null */ +ZEND_FUNCTION(get_error_handler) +{ + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + if (Z_TYPE(EG(user_error_handler)) != IS_UNDEF) { + RETVAL_ZVAL(&EG(user_error_handler), 1, 0); + } +} +/* }}} */ + /* {{{ proto void restore_error_handler(void) Restores the previously defined error handler function */ ZEND_FUNCTION(restore_error_handler) @@ -1718,6 +1736,20 @@ ZEND_FUNCTION(set_exception_handler) } /* }}} */ +/* {{{ proto string get_exception_handler(void) + Returns the currently defined exception handler, or null */ +ZEND_FUNCTION(get_exception_handler) +{ + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) { + RETVAL_ZVAL(&EG(user_exception_handler), 1, 0); + } +} +/* }}} */ + /* {{{ proto void restore_exception_handler(void) Restores the previously defined exception handler function */ ZEND_FUNCTION(restore_exception_handler)