File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -53,18 +53,17 @@ static zend_object_handlers default_exception_handlers;
53
53
/* {{{ zend_implement_throwable */
54
54
static int zend_implement_throwable (zend_class_entry * interface , zend_class_entry * class_type )
55
55
{
56
- /* During the registration of Exception/Error themselves, this may be called before
57
- * zend_ce_exception and zend_ce_error have been initialized, so handle these explicitly. */
58
- if (zend_ce_exception && instanceof_function (class_type , zend_ce_exception )) {
59
- return SUCCESS ;
60
- }
61
- if (zend_ce_error && instanceof_function (class_type , zend_ce_error )) {
62
- return SUCCESS ;
63
- }
64
- if (zend_string_equals_literal (class_type -> name , "Exception" )
65
- || zend_string_equals_literal (class_type -> name , "Error" )) {
56
+ /* zend_ce_exception and zend_ce_error may not be initialized yet when this is caleld (e.g when
57
+ * implementing Throwable for Exception itself). Perform a manual inheritance check. */
58
+ zend_class_entry * root = class_type ;
59
+ while (root -> parent ) {
60
+ root = root -> parent ;
61
+ }
62
+ if (zend_string_equals_literal (root -> name , "Exception" )
63
+ || zend_string_equals_literal (root -> name , "Error" )) {
66
64
return SUCCESS ;
67
65
}
66
+
68
67
zend_error_noreturn (E_ERROR ,
69
68
"Class %s cannot implement interface %s, extend Exception or Error instead" ,
70
69
ZSTR_VAL (class_type -> name ),
You can’t perform that action at this time.
0 commit comments