[GIT-PULLS] [php-src] PR #22804: Fix crash when a partial skips a param with a constant default

[email protected] (iliaal) Sun, 19 Jul 2026 14:28:44 +0000
Newsgroups php.git-pulls
Message-ID <cbh82kdTVwrPJvIT3DbaCg2IThrtQcn7XZEjlBAr9jU@main.internal.php.net>
Pull Request: https://github.com/php/php-src/pull/22804
Author: iliaal

A partial that leaves an optional parameter unbound via a named-argument gap, where that parameter's default is a constant expression, crashes the compiler. `f(a: 10, c: ?)` for `function f($a, $b = SOME_CONST, $c = 0)` compiled the callee default into the generated forwarding call as a `ZEND_AST_CONSTANT` node, which `zend_compile_expr_inner` has no case for: `ZEND_ASSERT(0)` in debug, `__builtin_unreachable` UB in release. A plain literal default (`$b = 5`) is unaffected.

For a user function, this skips the unbound parameter in the forwarding call and passes the following arguments by name, so the target applies its own default at call time. That matches a normal call exactly (verified for global constants, `self::` class constants, and enum cases) and materializes no value, so it is safe under opcache for defaults that cannot be stored as a literal, such as enum cases. Internal functions are unchanged: they still pass an explicit default and error when it is not introspectable.