Re: [RFC] Partial Function Application for instance of non-static methods ("$this")
| From: | Tim Düsterhus | Date: | Fri, 23 Jan 2026 08:37:39 +0000 |
| Subject: | Re: [RFC] Partial Function Application for instance of non-static methods ("$this") | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-129879@lists.php.net to get a copy of this message | ||
Hi
Am 2026-01-22 18:30, schrieb Mathieu Rochette:
I often whished something like this existed :) Didn't get trough to suggest it because I wasn't sure of the syntax either (and lazyness)Thank you for participating in the discussion of *this* RFC then. Having more voices available helps building things that suit the community best :-)
still, my syntax suggestions:
array_map(DateTimeImmutable->format("c"), $dates);
Unfortunately this doesn't work, because it is a already-legal method call on a method stored in the constant called DateTimeImmutable. See: https://3v4l.org/3khkT#veol
I noticed ?->method(?) was considered; evne if it was possible, I would prefer if the type was explict, as you may want to use an interface name (or a union type, etc.) too
Union types would likely be unsupported either way, since multiple members of the union could have incompatible signatures for the same method. Interfaces are fully supported with the currently proposed syntax (it's explicitly mentioned in the RFC).
Best regards
Tim Düsterhus