Skip to content
PHP News
Search
Implemented PHP 8.6

Partial Function Application: Handling of Optional Parameters

Makes every ? placeholder in partial function application a required parameter, instead of copying the original parameter's default.

Make all ? placeholders in PFA required parameters?

Primary vote · 2/3 majority

25 Yes 0 No 1 abstain 100% approval

This poll has closed.

Accepted. Voting closed on May 20, 2026 with 25 in favor, 0 against and 1 abstaining. It needed a two-thirds majority.

Summary

Partial function application (PFA) lets you call a function with ? in place of some arguments and get back a closure that takes the missing ones. The original PFA RFC said each ? copies whether the original parameter was optional. This RFC from Tim Düsterhus, Arnaud Le Blanc and Larry Garfield changes that rule so every ? becomes a required parameter.

The authors say the old rule led to inconsistent behavior. It also got in the way of a planned follow-up: using PFA on the $this object of a method call.

How it works

function example(mixed $a, string $b = 'default', string $c = 'also optional') { }

$c = example(?, ?);

// Now the same as:
$c = static fn (mixed $a, string $b) => example($a, $b);

// Not the first RFC's version:
$c = static fn (mixed $a, string $b = 'default') => example($a, $b);

Two ? placeholders means the closure takes exactly two arguments. The RFC argues that code receiving a partial function is written for that exact shape anyway and can't rely on a parameter being optional. The change also makes it easier for static analysis tools to work out the closure's signature.

The ... placeholder doesn't change. Parameters picked up by ... still keep their default values.

Why it matters for $this

A child class can give a method parameter a different default, or make a required parameter optional. If you partially apply $this, PHP doesn't know which class's method will end up running, so it can't pick the right default. Making every ? required removes that question for all of PFA, instead of adding a special rule just for $this.

What it means for existing code

Nothing breaks, since PFA hadn't been released yet when this RFC was written. It targets PHP 8.6.

Our coverage