> Le 27 juin 2021 à 16:39, Ralph Schindler <ra...@ralphschindler.com> a écrit :
>
> The short proposal:
>
>
> Make a variation of this work (notice parameter order and 'b' is goes unused):
>
> call_user_func_map(
> fn ($c, $a) => var_dump($a, $c),
> [
> 'a' => 'the a value',
> 'b' => 'the b value',
> 'c' => 'the c value'
> ]
> );
>
> // string(11) "the a value"
> // string(11) "the c value"
>
>
Hi,
If you want to ignore arguments in excess, your function may have a rest
parameter collecting them. The following will run without error:
```php
function foo($c, $a, ...$unused) {
var_dump($a, $c);
}
$args = [
'a' => 'the a value'
, 'b' => 'the b value'
, 'c' => 'the c value'
];
foo(...$args);
```
—Claude
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php