mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Convert exception instanceof checks to assertions
This commit is contained in:
parent
edf22962ef
commit
d60c43e397
1 changed files with 8 additions and 11 deletions
|
@ -92,11 +92,10 @@ void zend_exception_set_previous(zend_object *exception, zend_object *add_previo
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ZEND_ASSERT(instanceof_function(add_previous->ce, zend_ce_throwable)
|
||||||
|
&& "Previous execption must implement Throwable");
|
||||||
|
|
||||||
ZVAL_OBJ(&pv, add_previous);
|
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);
|
ZVAL_OBJ(&zv, exception);
|
||||||
ex = &zv;
|
ex = &zv;
|
||||||
do {
|
do {
|
||||||
|
@ -837,16 +836,14 @@ static zend_object *zend_throw_exception_zstr(zend_class_entry *exception_ce, ze
|
||||||
{
|
{
|
||||||
zval ex, tmp;
|
zval ex, tmp;
|
||||||
|
|
||||||
if (exception_ce) {
|
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 {
|
|
||||||
exception_ce = zend_ce_exception;
|
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) {
|
if (message) {
|
||||||
ZVAL_STR(&tmp, message);
|
ZVAL_STR(&tmp, message);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue