@@ -946,10 +946,10 @@ static inheritance_status zend_do_perform_implementation_check(
946
946
/* }}} */
947
947
948
948
static 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 ) /* {{{ */
950
950
{
951
951
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 );
953
953
smart_str_append (str , type_str );
954
954
zend_string_release (type_str );
955
955
if (!return_hint ) {
@@ -960,7 +960,7 @@ static ZEND_COLD void zend_append_type_hint(
960
960
/* }}} */
961
961
962
962
static 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 ) /* {{{ */
964
964
{
965
965
smart_str str = {0 };
966
966
@@ -991,7 +991,7 @@ static ZEND_COLD zend_string *zend_get_function_declaration(
991
991
num_args ++ ;
992
992
}
993
993
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 );
995
995
996
996
if (ZEND_ARG_SEND_MODE (arg_info )) {
997
997
smart_str_appendc (& str , '&' );
@@ -1088,7 +1088,7 @@ static ZEND_COLD zend_string *zend_get_function_declaration(
1088
1088
1089
1089
if (fptr -> common .fn_flags & ZEND_ACC_HAS_RETURN_TYPE ) {
1090
1090
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 );
1092
1092
}
1093
1093
smart_str_0 (& str );
1094
1094
@@ -1108,8 +1108,12 @@ static void ZEND_COLD emit_incompatible_method_error(
1108
1108
const zend_function * child , zend_class_entry * child_scope ,
1109
1109
const zend_function * parent , zend_class_entry * parent_scope ,
1110
1110
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 );
1113
1117
if (status == INHERITANCE_UNRESOLVED ) {
1114
1118
// TODO Improve error message if first unresolved class is present in child and parent?
1115
1119
/* Fetch the first unresolved class from registered autoloads */
@@ -1362,7 +1366,7 @@ static inheritance_status full_property_types_compatible(
1362
1366
1363
1367
static ZEND_COLD void emit_incompatible_property_error (
1364
1368
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 );
1366
1370
zend_error_noreturn (E_COMPILE_ERROR ,
1367
1371
"Type of %s::$%s must be %s%s (as in class %s)" ,
1368
1372
ZSTR_VAL (child -> ce -> name ),
@@ -1376,7 +1380,7 @@ static ZEND_COLD void emit_incompatible_property_error(
1376
1380
static ZEND_COLD void emit_set_hook_type_error (const zend_property_info * child , const zend_property_info * parent )
1377
1381
{
1378
1382
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 );
1380
1384
zend_error_noreturn (E_COMPILE_ERROR ,
1381
1385
"Set type of %s::$%s must be supertype of %s (as in %s %s)" ,
1382
1386
ZSTR_VAL (child -> ce -> name ),
@@ -1677,7 +1681,7 @@ static void zend_do_inherit_interfaces(zend_class_entry *ce, const zend_class_en
1677
1681
1678
1682
static void emit_incompatible_class_constant_error (
1679
1683
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 );
1681
1685
zend_error_noreturn (E_COMPILE_ERROR ,
1682
1686
"Type of %s::%s must be compatible with %s::%s of type %s" ,
1683
1687
ZSTR_VAL (child -> ce -> name ),
0 commit comments