Skip to content

Commit c81cf1c

Browse files
committed
Assert that arginfo parameter name is present
1 parent 68139db commit c81cf1c

File tree

3 files changed

+12
-20
lines changed

3 files changed

+12
-20
lines changed

Zend/zend_API.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,9 +2167,10 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
21672167
if (reg_function->common.arg_info && reg_function->common.num_args) {
21682168
uint32_t i;
21692169
for (i = 0; i < reg_function->common.num_args; i++) {
2170-
if (ZEND_TYPE_IS_SET(reg_function->common.arg_info[i].type)) {
2170+
zend_arg_info *arg_info = &reg_function->common.arg_info[i];
2171+
ZEND_ASSERT(arg_info->name && "Parameter must have a name");
2172+
if (ZEND_TYPE_IS_SET(arg_info->type)) {
21712173
reg_function->common.fn_flags |= ZEND_ACC_HAS_TYPE_HINTS;
2172-
break;
21732174
}
21742175
}
21752176
}

Zend/zend_inheritance.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -670,16 +670,10 @@ static ZEND_COLD zend_string *zend_get_function_declaration(const zend_function
670670
}
671671

672672
smart_str_appendc(&str, '$');
673-
674-
if (arg_info->name) {
675-
if (fptr->type == ZEND_INTERNAL_FUNCTION) {
676-
smart_str_appends(&str, ((zend_internal_arg_info*)arg_info)->name);
677-
} else {
678-
smart_str_appendl(&str, ZSTR_VAL(arg_info->name), ZSTR_LEN(arg_info->name));
679-
}
673+
if (fptr->type == ZEND_INTERNAL_FUNCTION) {
674+
smart_str_appends(&str, ((zend_internal_arg_info*)arg_info)->name);
680675
} else {
681-
smart_str_appends(&str, "param");
682-
smart_str_append_unsigned(&str, i);
676+
smart_str_appendl(&str, ZSTR_VAL(arg_info->name), ZSTR_LEN(arg_info->name));
683677
}
684678

685679
if (i >= required && !ZEND_ARG_IS_VARIADIC(arg_info)) {

ext/reflection/php_reflection.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -638,15 +638,12 @@ static void _parameter_string(smart_str *str, zend_function *fptr, struct _zend_
638638
if (ZEND_ARG_IS_VARIADIC(arg_info)) {
639639
smart_str_appends(str, "...");
640640
}
641-
if (arg_info->name) {
642-
smart_str_append_printf(str, "$%s",
643-
(fptr->type == ZEND_INTERNAL_FUNCTION &&
644-
!(fptr->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) ?
645-
((zend_internal_arg_info*)arg_info)->name :
646-
ZSTR_VAL(arg_info->name));
647-
} else {
648-
smart_str_append_printf(str, "$param%d", offset);
649-
}
641+
smart_str_append_printf(str, "$%s",
642+
(fptr->type == ZEND_INTERNAL_FUNCTION &&
643+
!(fptr->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) ?
644+
((zend_internal_arg_info*)arg_info)->name :
645+
ZSTR_VAL(arg_info->name));
646+
650647
if (fptr->type == ZEND_USER_FUNCTION && !required) {
651648
zend_op *precv = _get_recv_op((zend_op_array*)fptr, offset);
652649
if (precv && precv->opcode == ZEND_RECV_INIT && precv->op2_type != IS_UNUSED) {

0 commit comments

Comments
 (0)