Skip to content

Commit e0f8669

Browse files
committed
Add support for named parameters
1 parent 14cef3d commit e0f8669

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

scalar_objects.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ static zend_function *scalar_objects_get_indirection_func(
159159
ind->fn.handler = scalar_objects_indirection_func;
160160
ind->fn.scope = ce;
161161
ind->fn.fn_flags = ZEND_ACC_CALL_VIA_HANDLER | (fbc->common.fn_flags & keep_flags);
162+
ind->fn.fn_flags |= ZEND_ACC_USER_ARG_INFO;
162163
ind->fn.num_args = fbc->common.num_args - 1;
163164
ind->fn.required_num_args = fbc->common.required_num_args - 1;
164165
#if PHP_VERSION_ID >= 80000

tests/named_params.phpt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
Named parameters
3+
--SKIPIF--
4+
<?php
5+
if (PHP_VERSION_ID < 80000) die('skip For PHP >= 8.0 only');
6+
?>
7+
--FILE--
8+
<?php
9+
10+
register_primitive_type_handler('string', 'StringHandler');
11+
12+
class StringHandler {
13+
public static function test($self, $prefix = '', $suffix = '') {
14+
return $prefix . $self . $suffix;
15+
}
16+
}
17+
18+
$string = "Test";
19+
var_dump($string->test(prefix: "P"));
20+
var_dump($string->test(suffix: "S"));
21+
var_dump($string->test(prefix: "P", suffix: "S"));
22+
var_dump($string->test(suffix: "S", prefix: "P"));
23+
24+
?>
25+
--EXPECT--
26+
string(5) "PTest"
27+
string(5) "TestS"
28+
string(6) "PTestS"
29+
string(6) "PTestS"

0 commit comments

Comments
 (0)