@@ -2029,16 +2029,23 @@ static void zend_resolve_trait_relative_class_types(zend_function *const fn, con
2029
2029
/* Variadic parameters are not counted as part of the standard number of arguments */
2030
2030
bool has_variadic_type = fn -> common .fn_flags & ZEND_ACC_VARIADIC ;
2031
2031
uint32_t num_args = fn -> common .num_args + has_variadic_type ;
2032
- /* TODO Only do allocation if need to resolve types, as arg_info is stored in SHM */
2033
2032
size_t allocated_size = sizeof (zend_arg_info ) * (has_return_type + num_args );
2034
2033
2035
- zend_arg_info * new_arg_infos = zend_arena_alloc (& CG (arena ), allocated_size );
2036
- memcpy (new_arg_infos , fn -> common .arg_info - has_return_type , allocated_size );
2037
- fn -> common .arg_info = new_arg_infos + has_return_type ;
2034
+ zend_arg_info * new_arg_infos = fn -> common .arg_info - has_return_type ;
2035
+ bool has_resolved_type = false;
2038
2036
2039
2037
for (uint32_t i = 0 ; i < num_args + has_return_type ; i ++ ) {
2040
2038
zend_type type = new_arg_infos [i ].type ;
2041
- new_arg_infos [i ].type = zend_resolve_single_type (type , ce );
2039
+ zend_type resolved_type = zend_resolve_single_type (type , ce );
2040
+ if (type .ptr != resolved_type .ptr ) {
2041
+ if (!has_resolved_type ) {
2042
+ new_arg_infos = zend_arena_alloc (& CG (arena ), allocated_size );
2043
+ memcpy (new_arg_infos , fn -> common .arg_info - has_return_type , allocated_size );
2044
+ fn -> common .arg_info = new_arg_infos + has_return_type ;
2045
+ has_resolved_type = true;
2046
+ }
2047
+ new_arg_infos [i ].type = resolved_type ;
2048
+ }
2042
2049
}
2043
2050
}
2044
2051
0 commit comments