1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Followup GH-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 GH-20848.

Closes GH-20951
This commit is contained in:
Arnaud Le Blanc
2026-01-16 13:40:31 +01:00
committed by GitHub
parent a7fc4fda08
commit 6e6a850cb9
5 changed files with 5 additions and 18 deletions

View File

@@ -1082,7 +1082,6 @@ void zend_startup(zend_utility_functions *utility_functions) /* {{{ */
#endif
zend_enum_startup();
zend_closure_startup();
}
/* }}} */

View File

@@ -878,8 +878,6 @@ ZEND_API void zend_create_fake_closure(zval *res, zend_function *func, zend_clas
}
/* }}} */
static zend_arg_info trampoline_arg_info[1];
void zend_closure_from_frame(zval *return_value, const zend_execute_data *call) { /* {{{ */
zval instance;
zend_internal_function trampoline;
@@ -904,9 +902,7 @@ void zend_closure_from_frame(zval *return_value, const zend_execute_data *call)
trampoline.function_name = mptr->common.function_name;
trampoline.scope = mptr->common.scope;
trampoline.doc_comment = NULL;
if (trampoline.fn_flags & ZEND_ACC_VARIADIC) {
trampoline.arg_info = trampoline_arg_info;
}
trampoline.arg_info = mptr->common.arg_info;
trampoline.attributes = mptr->common.attributes;
zend_free_trampoline(mptr);
@@ -943,11 +939,3 @@ void zend_closure_bind_var_ex(zval *closure_zv, uint32_t offset, zval *val) /* {
ZVAL_COPY_VALUE(var, val);
}
/* }}} */
void zend_closure_startup(void)
{
/* __call and __callStatic name the arguments "$arguments" in the docs. */
trampoline_arg_info[0].name = zend_string_init_interned("arguments", strlen("arguments"), true);
trampoline_arg_info[0].type = (zend_type)ZEND_TYPE_INIT_CODE(IS_MIXED, false, _ZEND_ARG_INFO_FLAGS(false, 1, 0));
trampoline_arg_info[0].default_value = NULL;
}

View File

@@ -28,7 +28,6 @@ BEGIN_EXTERN_C()
#define ZEND_CLOSURE_OBJECT(op_array) \
((zend_object*)((char*)(op_array) - sizeof(zend_object)))
void zend_closure_startup(void);
void zend_register_closure_ce(void);
void zend_closure_bind_var(zval *closure_zv, zend_string *var_name, zval *var);
void zend_closure_bind_var_ex(zval *closure_zv, uint32_t offset, zval *val);

View File

@@ -1685,7 +1685,6 @@ ZEND_API ZEND_ATTRIBUTE_NONNULL zend_function *zend_get_call_trampoline_func(
* The low bit must be zero, to not be interpreted as a MAP_PTR offset.
*/
static const void *dummy = (void*)(intptr_t)2;
static const zend_arg_info arg_info[1] = {{0}};
if (EXPECTED(EG(trampoline).common.function_name == NULL)) {
func = &EG(trampoline).op_array;
@@ -1732,7 +1731,7 @@ ZEND_API ZEND_ATTRIBUTE_NONNULL zend_function *zend_get_call_trampoline_func(
func->prop_info = NULL;
func->num_args = 0;
func->required_num_args = 0;
func->arg_info = (zend_arg_info *) arg_info;
func->arg_info = zend_call_trampoline_arginfo;
return (zend_function*)func;
}
@@ -2576,6 +2575,7 @@ ZEND_API const zend_object_handlers std_object_handlers = {
};
void zend_object_handlers_startup(void) {
zend_call_trampoline_arginfo[0].name = ZSTR_KNOWN(ZEND_STR_ARGS);
zend_call_trampoline_arginfo[0].name = ZSTR_KNOWN(ZEND_STR_ARGUMENTS);
zend_call_trampoline_arginfo[0].type = (zend_type)ZEND_TYPE_INIT_CODE(IS_MIXED, false, _ZEND_ARG_INFO_FLAGS(false, 1, 0));
zend_property_hook_arginfo[0].name = ZSTR_KNOWN(ZEND_STR_VALUE);
}

View File

@@ -563,6 +563,7 @@ EMPTY_SWITCH_DEFAULT_CASE()
_(ZEND_STR_OBJECT_OPERATOR, "->") \
_(ZEND_STR_PAAMAYIM_NEKUDOTAYIM, "::") \
_(ZEND_STR_ARGS, "args") \
_(ZEND_STR_ARGUMENTS, "arguments") \
_(ZEND_STR_UNKNOWN, "unknown") \
_(ZEND_STR_UNKNOWN_CAPITALIZED, "Unknown") \
_(ZEND_STR_EXIT, "exit") \