Re: [RFC] Partial Function Application for instance of non-static methods ("$this")
| From: | Mathieu Rochette | Date: | Fri, 23 Jan 2026 13:06:11 +0000 |
| Subject: | Re: [RFC] Partial Function Application for instance of non-static methods ("$this") | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-129888@lists.php.net to get a copy of this message | ||
Mathieu Rochette
On Friday, January 23rd, 2026 at 09:37, Tim Düsterhus <tim@bastelstu.be> wrote:
> 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
>
Attachment: [application/pgp-keys] publickey - mathieu@rochette.cc - 0x8D30BA0E.asc
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
DateTimeImmutable. See:
> https://3v4l.org/3khkT#veol
ohhh
then, continuing on bikeshedding, I think I still prefer
?::DateTimeImmutable->format("c") or (? as
DateTimeImmutable)->format("c") as Larry mentioned.
(DateTimeImmutable)?->format("c") feels a bit weird. Reminds me too much
of the null-safe operator.
>
> > 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
>
They could have incompatible signatures, yes, but they also could have compatible ones too.
It's not a deal breaker. I don't imagine needing this in practice. But I don't see
why the language would prevent that; I can already make that mistake with short closures or any
methods. For me, it's the role of the static analyzer to tell me if I made such a mistake (or
runtime errors ^^).
> Interfaces are fully supported with the currently proposed
> syntax (it's explicitly mentioned in the RFC).
>
> Best regards
> Tim Düsterhus
Attachment: [application/pgp-keys] publickey - mathieu@rochette.cc - 0x8D30BA0E.asc
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc