Cannot use positional argument after named argument

Description

When using a mix of array unpacking and arguments, it is not possible to put the arguments after the unpacked argument. Said another way, the unpacked arguments must be the last one in the list.

Example

<?php

// Valid, the unpacked argument is the last
foo($a, $b, ...$c);

// Also valid, the unpacked arguments are the last
foo($a, $b, ...$c, ...$d);

// Not valida
foo(...$a, $b, ...$c);

?>

Solutions

  • Write the positional argument before the named ones in the call.