Cannot combine partial application and unpacking
Description
PHP 8.5 extends the first-class callable syntax with partial application: a lone … placeholder as the last argument of a call turns it into a Closure over the remaining, not-yet-supplied parameters. The same … token is already used for argument unpacking (spreading an array’s values as arguments), so a call that both spreads an array and ends with the placeholder is ambiguous between “spread this array, then partially apply” and a typo, and PHP rejects it outright.
Example
<?php
function add($a, $b, $c) {
return $a + $b + $c;
}
$args = [1, 2];
$curried = add(...$args, ...);
?>
Alternatives
- Wrap the call in an explicit closure instead: $curried = fn($c) => add(…$args, $c);
Related error messages
Changed Behavior
This error may appear following an evolution in behavior, in previous versions. See