Re: [Proposal] call_user_func_map(): flexible named parameter mapping for call_user_func*
From: Ralph Schindler Date: Thu, 01 Jul 2021 17:03:10 +0000 Subject: Re: [Proposal] call_user_func_map(): flexible named parameter mapping for call_user_func* References: 1 2 Groups: php.internals Request: Send a blank email to internals+get-115269@lists.php.net to get a copy of this message
If you want to ignore arguments in excess, your function may have a rest parameter collecting them. The following will run without error:This seems like a fairly clean alternative syntax with the only downside is an unused variable. Thanks for the idea! -ralphfunction foo($c, $a, ...$unused) { var_dump($a, $c); } $args = [ 'a' => 'the a value' , 'b' => 'the b value' , 'c' => 'the c value' ]; foo(...$args);
Thread (9 messages)
| « previous | php.internals (#115269) | next » |
|---|