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;
5353/* {{{ zend_implement_throwable */
5454static int zend_implement_throwable (zend_class_entry * interface , zend_class_entry * class_type )
5555{
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" )) {
6664 return SUCCESS ;
6765 }
66+
6867 zend_error_noreturn (E_ERROR ,
6968 "Class %s cannot implement interface %s, extend Exception or Error instead" ,
7069 ZSTR_VAL (class_type -> name ),
You can’t perform that action at this time.
0 commit comments