summaryrefslogtreecommitdiff
path: root/Zend/zend_exceptions.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-09-21 11:05:19 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-09-21 17:04:39 +0200
commitd60c43e397f45c3c92e2a980aa8bee2235bff8be (patch)
treede81cff0e3059f44c886f80401e9982084153e2d /Zend/zend_exceptions.c
parentedf22962ef4f20d3b770ab7b2873a93ed84bab22 (diff)
downloadphp-git-d60c43e397f45c3c92e2a980aa8bee2235bff8be.tar.gz
Convert exception instanceof checks to assertions
Diffstat (limited to 'Zend/zend_exceptions.c')
-rw-r--r--Zend/zend_exceptions.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c
index 1f47d88997..f037f0399a 100644
--- a/Zend/zend_exceptions.c
+++ b/Zend/zend_exceptions.c
@@ -92,11 +92,10 @@ void zend_exception_set_previous(zend_object *exception, zend_object *add_previo
return;
}
+ ZEND_ASSERT(instanceof_function(add_previous->ce, zend_ce_throwable)
+ && "Previous execption must implement Throwable");
+
ZVAL_OBJ(&pv, add_previous);
- if (!instanceof_function(Z_OBJCE(pv), zend_ce_throwable)) {
- zend_error_noreturn(E_CORE_ERROR, "Previous exception must implement Throwable");
- return;
- }
ZVAL_OBJ(&zv, exception);
ex = &zv;
do {
@@ -837,16 +836,14 @@ static zend_object *zend_throw_exception_zstr(zend_class_entry *exception_ce, ze
{
zval ex, tmp;
- if (exception_ce) {
- if (!instanceof_function(exception_ce, zend_ce_throwable)) {
- zend_error(E_NOTICE, "Exceptions must implement Throwable");
- exception_ce = zend_ce_exception;
- }
- } else {
+ if (!exception_ce) {
exception_ce = zend_ce_exception;
}
- object_init_ex(&ex, exception_ce);
+ ZEND_ASSERT(instanceof_function(exception_ce, zend_ce_throwable)
+ && "Exceptions must implement Throwable");
+
+ object_init_ex(&ex, exception_ce);
if (message) {
ZVAL_STR(&tmp, message);