Re: [RFC] Named parameters
| From: | Lazare Inepologlou | Date: | Fri, 06 Sep 2013 17:55:19 +0000 |
| Subject: | Re: [RFC] Named parameters | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-68918@lists.php.net to get a copy of this message | ||
2013/9/6 Adam Harvey <aharvey@php.net>
>
>
> Variadics/splat: collecting both named and positional arguments into
> one array seems reasonable to me. I think the main use case there
> would be option parameters, which you'd have to validate anyway, so
> positional parameters would be dealt with at that point — I don't see
> separate arrays as conferring any great advantage in terms of
> validating parameters, and it's no simpler conceptually.
>
>
There is a small drawback. Suppose this code:
function foo( $bar = 0 , ...$args ){}
foo( bart => 3 ); // misspelled name
According to the RFC, any unknown argument name will fall into the $args
array, making the above code valid. As this cannot be verified statically,
it is a possible source of bugs.
Lazare INEPOLOGLOU
Ingénieur Logiciel