Skip to content

Commit 3dcc430

Browse files
committed
Positional placeholders that run into the variadic portion generate an unnamed parameter
1 parent 78521dd commit 3dcc430

File tree

7 files changed

+22
-17
lines changed

7 files changed

+22
-17
lines changed

Zend/tests/partial_application/magic_001.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Partial [ <user, prototype Foo> public method method ] {
4747
@@ %s 12 - 12
4848

4949
- Parameters [1] {
50-
Parameter #0 [ <required> $args ]
50+
Parameter #0 [ <required> $ ]
5151
}
5252
}
5353
not enough arguments for application of Foo::method, 0 given and exactly 1 expected, declared in %s on line 12
@@ -58,7 +58,7 @@ Partial [ <user, prototype Foo> public method method ] {
5858
@@ %s 30 - 30
5959

6060
- Parameters [2] {
61-
Parameter #0 [ <required> $args ]
61+
Parameter #0 [ <required> $ ]
6262
Parameter #1 [ <optional> ...$args ]
6363
}
6464
}

Zend/tests/partial_application/magic_002.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Partial [ <user, prototype Foo> public method method ] {
3333
@@ %s 10 - 10
3434

3535
- Parameters [1] {
36-
Parameter #0 [ <required> $args ]
36+
Parameter #0 [ <required> $ ]
3737
}
3838
}
3939
Foo::method
@@ -42,7 +42,7 @@ Partial [ <user, prototype Foo> public method method ] {
4242
@@ %s 16 - 16
4343

4444
- Parameters [2] {
45-
Parameter #0 [ <required> $args ]
45+
Parameter #0 [ <required> $ ]
4646
Parameter #1 [ <optional> ...$args ]
4747
}
4848
}

Zend/tests/partial_application/magic_005.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ object(Closure)#%d (6) {
2424
}
2525
["parameter"]=>
2626
array(1) {
27-
["$args"]=>
27+
["$"]=>
2828
string(10) "<required>"
2929
}
3030
["args"]=>

Zend/tests/partial_application/reflection_002.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ Partial [ <user> function foo ] {
4343

4444
- Parameters [2] {
4545
Parameter #0 [ <required> $a ]
46-
Parameter #1 [ <required> $b ]
46+
Parameter #1 [ <required> $ ]
4747
}
4848
}
4949
Partial [ <user> function foo ] {
5050
@@ %s 18 - 18
5151

5252
- Parameters [3] {
5353
Parameter #0 [ <required> $a ]
54-
Parameter #1 [ <required> $b ]
55-
Parameter #2 [ <required> $b ]
54+
Parameter #1 [ <required> $ ]
55+
Parameter #2 [ <required> $ ]
5656
}
5757
}

Zend/tests/partial_application/reflection_003.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Partial [ <user> function sprintf ] {
3737

3838
- Parameters [2] {
3939
Parameter #0 [ <required> string $format ]
40-
Parameter #1 [ <required> mixed $values ]
40+
Parameter #1 [ <required> mixed $ ]
4141
}
4242
- Return [ string ]
4343
}

Zend/zend_execute.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5395,6 +5395,10 @@ static zend_always_inline uint32_t zend_get_arg_offset_by_name(
53955395
return *(uintptr_t *)(cache_slot + 1);
53965396
}
53975397

5398+
if (UNEXPECTED(ZSTR_LEN(arg_name) == 0)) {
5399+
return (uint32_t)-1;
5400+
}
5401+
53985402
// TODO: Use a hash table?
53995403
uint32_t num_args = fbc->common.num_args;
54005404
if (EXPECTED(fbc->type == ZEND_USER_FUNCTION)

Zend/zend_partial.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,14 @@ static zend_always_inline void zend_partial_signature_create(zend_partial *parti
139139
/* Placeholders that run into the variadic portion become
140140
* required and make all params before them required */
141141
required = num;
142-
// TODO: update arg name
142+
info->name = zend_empty_string;
143+
info->default_value = NULL;
143144
if (ZEND_PARTIAL_IS_CALL_TRAMPOLINE(&partial->func)) {
144-
memcpy(info, zend_call_magic_arginfo, sizeof(zend_arg_info));
145+
info->type = (zend_type){0};
145146
} else {
146-
memcpy(info,
147-
partial->func.common.arg_info + partial->func.common.num_args,
148-
sizeof(zend_arg_info));
147+
info->type = (partial->func.common.arg_info + partial->func.common.num_args)->type;
148+
ZEND_TYPE_FULL_MASK(info->type) &= ~_ZEND_IS_VARIADIC_BIT;
149149
}
150-
ZEND_TYPE_FULL_MASK(info->type) &= ~_ZEND_IS_VARIADIC_BIT;
151150
if (EXPECTED(num < MAX_ARG_FLAG_NUM)) {
152151
uint32_t mode = ZEND_ARG_SEND_MODE(info);
153152
if (mode) {
@@ -213,13 +212,15 @@ static zend_always_inline void zend_partial_signature_create(zend_partial *parti
213212
if (ZEND_PARTIAL_FUNC_FLAG(&partial->trampoline, ZEND_ACC_HAS_RETURN_TYPE)) {
214213
info++;
215214
}
216-
while (info < end) {
215+
for (; info < end; info++) {
217216
zend_internal_arg_info *ii = (zend_internal_arg_info*) info;
217+
if ((zend_string*)ii->name == zend_empty_string) {
218+
continue;
219+
}
218220
info->name = zend_string_init(ii->name, strlen(ii->name), false);
219221
if (ii->default_value) {
220222
info->default_value = zend_string_init(ii->default_value, strlen(ii->default_value), false);
221223
}
222-
info++;
223224
}
224225
}
225226

0 commit comments

Comments
 (0)