[GIT-PULLS] [php-src] PR #22829: [PFA 4/n] Optimize constant pre-bound arguments

[email protected] (arnaud-lb) Mon, 20 Jul 2026 13:29:08 +0000
Newsgroups php.git-pulls
Message-ID <[email protected]>
Pull Request: https://github.com/php/php-src/pull/22829
Author: arnaud-lb

The branch includes GH-22785, but only the commit "[PFA 4/n] Optimize constant pre-bound arguments" is relevant for this PR.

---

PFA pre-bound arguments are bound to the generated closure's lexical vars:

```
function f($a, $b) {}
$f = f(1, ?);

// Generates:
$tmp = 1;
$f = function ($b) use ($tmp) {
    return f($tmp, $b);
};
```

Detect which pre-bound arguments are constant and burn them into the generated
closure instead:

```
function f($a, $b) {}
$f = f(1, ?);

// Generates:
$f = function ($b) {
    return f(1, $b);
};
```

This reduces the overhead during both instantiation and invocation of PFAs.