[php-src] Issue #10197: implode() does not allow to skip optional separator with named arguments
| From: | JayQ1982 | Date: | Sat, 31 Dec 2022 09:44:51 +0000 |
| Subject: | [php-src] Issue #10197: implode() does not allow to skip optional separator with named arguments | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-243300@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/10197
Author: JayQ1982
### Description
The following code:
```php
<?php
echo implode(array: $array);
```
Resulted in this output:
```
**Fatal error:** Uncaught ArgumentCountError: implode(): Argument #1 ($separator) not passed
```
But I expected this output instead:
Output of string where array of string is imploded with optional default separator (empty string) as
described in the documentation:
https://www.php.net/manual/en/function.implode
https://www.php.net/manual/en/functions.arguments.php
:
> As of PHP 8.0.0, [named
> arguments](https://www.php.net/manual/en/functions.arguments.php#functions.named-arguments) can be
> used to skip over multiple optional parameters.
https://www.php.net/manual/en/function.implode.php#refsect1-function.implode-description
:
> Alternative signature (not supported with named arguments):
implode(array $array): string
https://www.php.net/manual/en/function.implode.php#refsect1-function.implode-parameters
:
> separator
> Optional. Defaults to an empty string.
Why does implode() not accept to skip the optional separator with named parameters?
Without named parameters it works.
### PHP Version
PHP 8.2.0
### Operating System
Ubuntu 20.04