Named Parameters And Variadic

It is possible to use the three dots ... operator and named parameters when calling a method. The unpacked array must have named arguments, and so does the arguments after it.

In PHP 8.0, it was not possible.

PHP code

<?php

function foo($a, ...$b) {
    echo $a.' '.implode(', ', $b);
}

foo(...[b => 1], a: 2);

?>

Before

PHP Fatal error:  Cannot combine named arguments and argument unpacking in /codes/named_parameters_and_variadic.php on line 7

Fatal error: Cannot combine named arguments and argument unpacking in /codes/named_parameters_and_variadic.php on line 7

After

2 1

PHP version change

This behavior changed in 8.1

Error Messages