Re: [RFC] Partial Function Application v2
| From: | Tim Düsterhus | Date: | Wed, 02 Jul 2025 15:04:34 +0000 |
| Subject: | Re: [RFC] Partial Function Application v2 | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-127835@lists.php.net to get a copy of this message | ||
Hi
Am 2025-06-28 07:06, schrieb Larry Garfield:
Hi folks. Arnaud and I would like to present take-2 at Partial Function Application. https://wiki.php.net/rfc/partial_function_application_v2I've now had a *quick* look at the implementation and the following questions came up that the RFC does not answer (and the tests in the PR do not obviously answer either): How will PFA calls appear in a stack trace and how will PFA Closures look like to
var_dump(), Reflection, and to observers?
Classic FCC are 100% identical to the underlying function and thus can just “pretend” they are the underlying function, but that doesn't work for PFA. Consider the following:
function foo(string $s, int $i) {
var_dump($s, $i);
}
$f = foo("abc", ?);
$f([]);How will the error message for the resulting TypeError look like?
var_dump($f); // same $fHow will the output look like?
var_dump((new ReflectionFunction($f))->getName());
var_dump((new ReflectionFunction($f))->getParameters());
Ditto
is_callable($f, callable_name: $name);
var_dump($name);
Ditto
function foo(string $s, #[\SensitiveParameter] int $i) {
throw new \Exception();
}
$f = foo("abc", ?);
$f(123);How will the stack trace look like? Does
#[\SensitiveParameter] work properly?
Best regards
Tim Düsterhus