@@ -946,10 +946,10 @@ static inheritance_status zend_do_perform_implementation_check(
946946/* }}} */
947947
948948static ZEND_COLD void zend_append_type_hint (
949- smart_str * str , zend_class_entry * scope , const zend_arg_info * arg_info , bool return_hint ) /* {{{ */
949+ smart_str * str , zend_class_entry * scope , const HashTable * bound_types_to_scope , const zend_arg_info * arg_info , bool return_hint ) /* {{{ */
950950{
951951 if (ZEND_TYPE_IS_SET (arg_info -> type )) {
952- zend_string * type_str = zend_type_to_string_resolved (arg_info -> type , scope );
952+ zend_string * type_str = zend_type_to_string_resolved (arg_info -> type , scope , bound_types_to_scope );
953953 smart_str_append (str , type_str );
954954 zend_string_release (type_str );
955955 if (!return_hint ) {
@@ -960,7 +960,7 @@ static ZEND_COLD void zend_append_type_hint(
960960/* }}} */
961961
962962static ZEND_COLD zend_string * zend_get_function_declaration (
963- const zend_function * fptr , zend_class_entry * scope ) /* {{{ */
963+ const zend_function * fptr , zend_class_entry * scope , const HashTable * bound_types_to_scope ) /* {{{ */
964964{
965965 smart_str str = {0 };
966966
@@ -991,7 +991,7 @@ static ZEND_COLD zend_string *zend_get_function_declaration(
991991 num_args ++ ;
992992 }
993993 for (uint32_t i = 0 ; i < num_args ;) {
994- zend_append_type_hint (& str , scope , arg_info , 0 );
994+ zend_append_type_hint (& str , scope , bound_types_to_scope , arg_info , 0 );
995995
996996 if (ZEND_ARG_SEND_MODE (arg_info )) {
997997 smart_str_appendc (& str , '&' );
@@ -1088,7 +1088,7 @@ static ZEND_COLD zend_string *zend_get_function_declaration(
10881088
10891089 if (fptr -> common .fn_flags & ZEND_ACC_HAS_RETURN_TYPE ) {
10901090 smart_str_appends (& str , ": " );
1091- zend_append_type_hint (& str , scope , fptr -> common .arg_info - 1 , 1 );
1091+ zend_append_type_hint (& str , scope , bound_types_to_scope , fptr -> common .arg_info - 1 , 1 );
10921092 }
10931093 smart_str_0 (& str );
10941094
@@ -1108,8 +1108,12 @@ static void ZEND_COLD emit_incompatible_method_error(
11081108 const zend_function * child , zend_class_entry * child_scope ,
11091109 const zend_function * parent , zend_class_entry * parent_scope ,
11101110 inheritance_status status ) {
1111- zend_string * parent_prototype = zend_get_function_declaration (parent , parent_scope );
1112- zend_string * child_prototype = zend_get_function_declaration (child , child_scope );
1111+ const HashTable * bound_types_to_parent = NULL ;
1112+ if (child_scope -> bound_types ) {
1113+ bound_types_to_parent = zend_hash_find_ptr_lc (child_scope -> bound_types , parent_scope -> name );
1114+ }
1115+ zend_string * parent_prototype = zend_get_function_declaration (parent , parent_scope , bound_types_to_parent );
1116+ zend_string * child_prototype = zend_get_function_declaration (child , child_scope , NULL );
11131117 if (status == INHERITANCE_UNRESOLVED ) {
11141118 // TODO Improve error message if first unresolved class is present in child and parent?
11151119 /* Fetch the first unresolved class from registered autoloads */
@@ -1362,7 +1366,7 @@ static inheritance_status full_property_types_compatible(
13621366
13631367static ZEND_COLD void emit_incompatible_property_error (
13641368 const zend_property_info * child , const zend_property_info * parent , prop_variance variance ) {
1365- zend_string * type_str = zend_type_to_string_resolved (parent -> type , parent -> ce );
1369+ zend_string * type_str = zend_type_to_string_resolved (parent -> type , parent -> ce , /* TODO? */ NULL );
13661370 zend_error_noreturn (E_COMPILE_ERROR ,
13671371 "Type of %s::$%s must be %s%s (as in class %s)" ,
13681372 ZSTR_VAL (child -> ce -> name ),
@@ -1376,7 +1380,7 @@ static ZEND_COLD void emit_incompatible_property_error(
13761380static ZEND_COLD void emit_set_hook_type_error (const zend_property_info * child , const zend_property_info * parent )
13771381{
13781382 zend_type set_type = parent -> hooks [ZEND_PROPERTY_HOOK_SET ]-> common .arg_info [0 ].type ;
1379- zend_string * type_str = zend_type_to_string_resolved (set_type , parent -> ce );
1383+ zend_string * type_str = zend_type_to_string_resolved (set_type , parent -> ce , /* TODO? */ NULL );
13801384 zend_error_noreturn (E_COMPILE_ERROR ,
13811385 "Set type of %s::$%s must be supertype of %s (as in %s %s)" ,
13821386 ZSTR_VAL (child -> ce -> name ),
@@ -1677,7 +1681,7 @@ static void zend_do_inherit_interfaces(zend_class_entry *ce, const zend_class_en
16771681
16781682static void emit_incompatible_class_constant_error (
16791683 const zend_class_constant * child , const zend_class_constant * parent , const zend_string * const_name ) {
1680- zend_string * type_str = zend_type_to_string_resolved (parent -> type , parent -> ce );
1684+ zend_string * type_str = zend_type_to_string_resolved (parent -> type , parent -> ce , NULL );
16811685 zend_error_noreturn (E_COMPILE_ERROR ,
16821686 "Type of %s::%s must be compatible with %s::%s of type %s" ,
16831687 ZSTR_VAL (child -> ce -> name ),
0 commit comments