On Thu, Aug 29, 2013 at 12:09 AM, Stas Malyshev <smalys...@sugarcrm.com>wrote:

> Hi!
>
> I like the idea, the concept of capturing "rest of args" is pretty
> common. But couldn't we in addition have func_get_args() be able to
> receive an int argument that would produce "the rest" in an easier way
> for those that prefer func_ger_args()?
>

I would do that if this RFC doesn't pass, but I don't see much point doing
both things (syntax + extra arg). Are there any particular scenarios where
using func_get_args() would be preferable?


> For prototype checks, this:
>
>     public function query($query, ...$params);
>     public function query($query, $param = null, ...$params);
>
> Should be compatible.


It already is. Only requirement is that the typehint/by-ref-mode of
$param=null is compatible with the typehint/by-ref-mode of ...$params :)


> Same with:
>
>     public function query($query, ...$params);
>     public function query($query);
>
> functions should be able to ignore some arguments, especially ones that
> are optional anyway. I also think this:
>
> public function query($query, ...$params)
> public function query(...$params)
>
> should be legal too.
>

I would like to stay consistent with the normal PHP behavior here. PHP
currently doesn't allow leaving off (required or optional) parameters. I
created a separate thread regarding that issue:
http://markmail.org/message/ejgmqjnjnbmfnuzv If we decide to allow having
less parameters there, then I'll follow suit here as well.


> I think it should also be explicitly specified what $params is if there
> is no arguments - null? false? array()? I'd probably prefer array as it
> makes it easy to do something like:
>
> public __construct(...$params) {
>   foreach($params as $k => $v) { $this->$k = $v; }
> }
>
> but in any way it should be specified.
>

Now specified in
https://wiki.php.net/rfc/variadics#population_of_variadic_parameter: The
default is an empty array.

Thanks for the comments,
Nikita

Reply via email to