summaryrefslogtreecommitdiff
path: root/zend/exception_handler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'zend/exception_handler.cpp')
-rw-r--r--zend/exception_handler.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/zend/exception_handler.cpp b/zend/exception_handler.cpp
index 51874a4..75361b2 100644
--- a/zend/exception_handler.cpp
+++ b/zend/exception_handler.cpp
@@ -43,6 +43,31 @@ Value set_exception_handler(const std::function<Value(Parameters &params)> &hand
return output;
}
+Value set_error_handler(const std::function<Value(Parameters &params)> &handler)
+{
+ // create the functor which wraps our callback
+ Function functor(handler);
+
+ // initialize our output value
+ Value output;
+
+ // turn our user_error_handler into a Value if we have one, just so we can return it later on
+ if (EG(user_error_handler)) output = EG(user_error_handler);
+
+ // detach so we have the zval
+ auto value = functor.detach(true);
+
+ // alocate the user_error_handler
+ ALLOC_ZVAL(EG(user_error_handler));
+
+ // copy our zval into the user_error_handler
+ MAKE_COPY_ZVAL(&value, EG(user_error_handler));
+ EG(user_error_handler_error_reporting) = (int) (E_ALL | E_STRICT);
+
+ // return the original handler
+ return output;
+}
+
/**
* End of namespace
*/