Req #80327 [NEW]: Conflicts of parameter names and variadics
| From: | david at grudl dot com | Date: | Fri, 06 Nov 2020 13:25:37 +0000 |
| Subject: | Req #80327 [NEW]: Conflicts of parameter names and variadics | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-230163@lists.php.net to get a copy of this message | ||
From: david at grudl dot com
Operating system:
PHP version: 8.0.0RC3
Package: Scripting Engine problem
Bug Type: Feature/Change Request
Bug description:Conflicts of parameter names and variadics
Description:
------------
I quote directly from RFC: https://wiki.php.net/rfc/named_params
> One of the primary use-cases for that variadic/unpacking syntaxes is
forwarding of arguments. The support for named arguments in both
variadics and argument unpacking ensures that this pattern will continue
to work once named arguments are introduced.
function passthru(callable $c, ...$args) {
return $c(...$args);
}
Unfortunately, there is one limitation for forwarding at this time. You
cannot pass argument with key 'c' to $args because it conflicts with
parameter $c. So this
passthru($callable, $args);
May throws "Uncaught Error: Named parameter $c overwrites previous
argument." depending on the content of (the otherwise valid) $args.
How to solve it?
A possible solution is to use a very non-conflicting name for $c, for
example passthru(callable $ââ, ...$args), but I think that a better
solution would be to ignore the conflicts if positional parameters are
passed and variadics follows.
--
Edit bug report at https://bugs.php.net/bug.php?id=80327&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80327&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80327&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80327&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80327&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80327&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80327&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80327&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80327&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80327&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80327&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80327&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80327&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80327&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80327&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80327&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80327&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80327&r=mysqlcfg