Skip to content

Commit 6e6a850

Browse files
authored
Followup phpGH-19022
* Fix zend_call_trampoline_arginfo arg name Name is "arguments" in documentation: https://www.php.net/__call#language.oop5.overloading.methods * Use zend_call_trampoline_arginfo in zend_get_call_trampoline_func() * Copy the original arg_info in zend_closure_from_frame None of these changes are observable, but this is cleaner, and this becomes observable in phpGH-20848. Closes phpGH-20951
1 parent a7fc4fd commit 6e6a850

File tree

5 files changed

+5
-18
lines changed

5 files changed

+5
-18
lines changed

Zend/zend.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,6 @@ void zend_startup(zend_utility_functions *utility_functions) /* {{{ */
10821082
#endif
10831083

10841084
zend_enum_startup();
1085-
zend_closure_startup();
10861085
}
10871086
/* }}} */
10881087

Zend/zend_closures.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -878,8 +878,6 @@ ZEND_API void zend_create_fake_closure(zval *res, zend_function *func, zend_clas
878878
}
879879
/* }}} */
880880

881-
static zend_arg_info trampoline_arg_info[1];
882-
883881
void zend_closure_from_frame(zval *return_value, const zend_execute_data *call) { /* {{{ */
884882
zval instance;
885883
zend_internal_function trampoline;
@@ -904,9 +902,7 @@ void zend_closure_from_frame(zval *return_value, const zend_execute_data *call)
904902
trampoline.function_name = mptr->common.function_name;
905903
trampoline.scope = mptr->common.scope;
906904
trampoline.doc_comment = NULL;
907-
if (trampoline.fn_flags & ZEND_ACC_VARIADIC) {
908-
trampoline.arg_info = trampoline_arg_info;
909-
}
905+
trampoline.arg_info = mptr->common.arg_info;
910906
trampoline.attributes = mptr->common.attributes;
911907

912908
zend_free_trampoline(mptr);
@@ -943,11 +939,3 @@ void zend_closure_bind_var_ex(zval *closure_zv, uint32_t offset, zval *val) /* {
943939
ZVAL_COPY_VALUE(var, val);
944940
}
945941
/* }}} */
946-
947-
void zend_closure_startup(void)
948-
{
949-
/* __call and __callStatic name the arguments "$arguments" in the docs. */
950-
trampoline_arg_info[0].name = zend_string_init_interned("arguments", strlen("arguments"), true);
951-
trampoline_arg_info[0].type = (zend_type)ZEND_TYPE_INIT_CODE(IS_MIXED, false, _ZEND_ARG_INFO_FLAGS(false, 1, 0));
952-
trampoline_arg_info[0].default_value = NULL;
953-
}

Zend/zend_closures.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ BEGIN_EXTERN_C()
2828
#define ZEND_CLOSURE_OBJECT(op_array) \
2929
((zend_object*)((char*)(op_array) - sizeof(zend_object)))
3030

31-
void zend_closure_startup(void);
3231
void zend_register_closure_ce(void);
3332
void zend_closure_bind_var(zval *closure_zv, zend_string *var_name, zval *var);
3433
void zend_closure_bind_var_ex(zval *closure_zv, uint32_t offset, zval *val);

Zend/zend_object_handlers.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,7 +1685,6 @@ ZEND_API ZEND_ATTRIBUTE_NONNULL zend_function *zend_get_call_trampoline_func(
16851685
* The low bit must be zero, to not be interpreted as a MAP_PTR offset.
16861686
*/
16871687
static const void *dummy = (void*)(intptr_t)2;
1688-
static const zend_arg_info arg_info[1] = {{0}};
16891688

16901689
if (EXPECTED(EG(trampoline).common.function_name == NULL)) {
16911690
func = &EG(trampoline).op_array;
@@ -1732,7 +1731,7 @@ ZEND_API ZEND_ATTRIBUTE_NONNULL zend_function *zend_get_call_trampoline_func(
17321731
func->prop_info = NULL;
17331732
func->num_args = 0;
17341733
func->required_num_args = 0;
1735-
func->arg_info = (zend_arg_info *) arg_info;
1734+
func->arg_info = zend_call_trampoline_arginfo;
17361735

17371736
return (zend_function*)func;
17381737
}
@@ -2576,6 +2575,7 @@ ZEND_API const zend_object_handlers std_object_handlers = {
25762575
};
25772576

25782577
void zend_object_handlers_startup(void) {
2579-
zend_call_trampoline_arginfo[0].name = ZSTR_KNOWN(ZEND_STR_ARGS);
2578+
zend_call_trampoline_arginfo[0].name = ZSTR_KNOWN(ZEND_STR_ARGUMENTS);
2579+
zend_call_trampoline_arginfo[0].type = (zend_type)ZEND_TYPE_INIT_CODE(IS_MIXED, false, _ZEND_ARG_INFO_FLAGS(false, 1, 0));
25802580
zend_property_hook_arginfo[0].name = ZSTR_KNOWN(ZEND_STR_VALUE);
25812581
}

Zend/zend_string.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ EMPTY_SWITCH_DEFAULT_CASE()
563563
_(ZEND_STR_OBJECT_OPERATOR, "->") \
564564
_(ZEND_STR_PAAMAYIM_NEKUDOTAYIM, "::") \
565565
_(ZEND_STR_ARGS, "args") \
566+
_(ZEND_STR_ARGUMENTS, "arguments") \
566567
_(ZEND_STR_UNKNOWN, "unknown") \
567568
_(ZEND_STR_UNKNOWN_CAPITALIZED, "Unknown") \
568569
_(ZEND_STR_EXIT, "exit") \

0 commit comments

Comments
 (0)