Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130039 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id BEAA51A00BC for ; Fri, 6 Feb 2026 20:30:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1770409838; bh=Jq4rbWayAxMhrf4uphbGNB5R15iIp7bQZWO0XYFkEKU=; h=Date:From:To:In-Reply-To:References:Subject:From; b=jWFsoxoSW/ualudoIYbuFYWqiY9UL3uKRLdFtPnFl8ffxZzdmKE8IoDf567j1sDmv yoxk9cq5rbm2XjDPyCK4b6J2e3RTM9KB0hf/H/Egyg3crMILX33TaAbmaxaoeRwIOX 4vBMrU/yB6YHv9xT042fh1EHsIh6/lgT3jeNJkbX7J9Vkt95Zm1FfipDI2emV6D9lP P0u9b2nlv6rTC/xSFMHA1h6UlOpTItPmZExhijWvVQwVGzKLaeWJKMWB/Y5pguWFc7 JPs9SAUMK+ULAnB1k3UkIgutywCrUUJKy63tgKY/mGPx5ho71wVp3aFhR6WqqsMSB9 cl+zWSLc8ajdQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 80000180050 for ; Fri, 6 Feb 2026 20:30:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from fhigh-a3-smtp.messagingengine.com (fhigh-a3-smtp.messagingengine.com [103.168.172.154]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 6 Feb 2026 20:30:37 +0000 (UTC) Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.phl.internal (Postfix) with ESMTP id DB3851400168 for ; Fri, 6 Feb 2026 15:30:31 -0500 (EST) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-04.internal (MEProxy); Fri, 06 Feb 2026 15:30:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to; s=fm3; t=1770409831; x=1770496231; bh=+pxIcG2UPQGx+vzQnQxi1 uF1cc7te8vIAYWvUqgB6YA=; b=Y/XId1l4DCG3vfJ0JyTe82LO57nXPrUShPj27 dVWnf94gys0SdsMpaz8eAfw1isLGbTd562L4/lNMKqpkNGN1lMLoW7lZO6Y4Nysm gbgGyF6Gzx7Td2bLbgKNJKxmMC1L1l+UfQCGKvTMypie7YAeDztAWn/n65Xqz0kT t38TwCttsXnQUnuCa6IgnmdthXntIRl/G2nsz70LA9yQel2tQZRidbhlI8GSM5C3 /o9Wm2q+WfWdXffqtnz1SKIILQKUEA18+sTvAXJSENEiiRtlSHQLBUf9za7V74w+ ZLHq48gBqAiJsa0SerNcmTzKl7uzubCNdAa+SIzM9zN7QlX7w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1770409831; x=1770496231; bh=+ pxIcG2UPQGx+vzQnQxi1uF1cc7te8vIAYWvUqgB6YA=; b=tysjX1s4B+0qUSvXJ Ck44Oi9NcuXA/ETbMEE24tqeKklm0vqPRCIUI5mDKbYcrh4xBQ9+yiO0c799q/zy aTScMen1rTSEAwJJniQG/pCFYlCcPZUQL5wLkntg/cnGpP4jsgWpU0knAQrim8vh a11xGiZb+37c0oQsSkEDJ786e5bNoSFO1pufe6sFtaIsBN7FKJTXTJb05MXW8lEi 4PcFM30Ql4RtfgUtdEOaY2a7FkcDaAxHu5cuL71/l6FLvLnG85/kTuSPlD31GEUj t4zcY5xjuYyRMsLvIyKcUHWlaAW9duL7Eo2KWpoOsUkBP/PKz8HDM0uKySVNfs50 T7DoQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddukeeludefucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepofggfffhvffkjghfufgtgfesthhqredtredtjeenucfhrhhomhepfdfnrghrrhih ucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmqe enucggtffrrghtthgvrhhnpeffieeivdfhvdeguddttdegteeiueegvefhteehfeeffeet udeitdehtdegjeeuieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomhdpnhgspghrtghp thhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepihhnthgvrhhnrghlsh eslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 8EEFF700065; Fri, 6 Feb 2026 15:30:31 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: Ap5THxlW55h7 Date: Fri, 06 Feb 2026 14:30:11 -0600 To: "php internals" Message-ID: In-Reply-To: <5c6ff4c3-8a1b-4b4a-8c1a-0acbb7b1cae2@bastelstu.be> References: <64953ec741a4c6609519e1878ad37b54@bastelstu.be> <253ee811-0c1d-7eab-4c36-38607401aaf6@php.net> <28461544eb11b41dce7c7563ad879e63@bastelstu.be> <62a90f31-697b-4607-a1ba-67956f5adfac@app.fastmail.com> <5c6ff4c3-8a1b-4b4a-8c1a-0acbb7b1cae2@bastelstu.be> Subject: Re: [PHP-DEV] [RFC] Partial Function Application for instance of non-static methods ("$this") Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Fri, Feb 6, 2026, at 10:43 AM, Tim D=C3=BCsterhus wrote: > Hi > > On 1/22/26 17:41, Larry Garfield wrote: >> More spitballing on my previous reply: >>=20 >> class Test { >> public function stuff(int $a) {} >> } >>=20 >> (Test)?->stuff(?); > > As mentioned in the sibling mail, this is existing syntax and thus=20 > doesn't work. Sure, but we can fiddle with the details to find something that works. = I also suggested something like these to Arnaud off-list: (?: Test)->stuff(?); (Test ?)->stuff(?); ((Test)?)->stuff(?); > Keeping full type information is the main benefit of PFA over =E2=80=9C= just=20 > write a Closure=E2=80=9D. Being able to reorder parameters as part of = partial=20 > application is another explicit feature that would not be supported by=20 > that syntax. Honestly, I don't much care about the reordering. And with this approac= h you'd still be able to reorder the method params, just keep the object= as first arg. >> That would then be a lot easier to write in cases where you're just d= ropping a $this->stuff() call into a pipe chain but want to receive $thi= s. > > The use case for partially applying `$this` is in cases where you need= a=20 > =E2=80=9Cfunction handle=E2=80=9D, that's why the examples are ones wh= ere the resulting=20 > Closure is passed as a parameter to another function. > > Within a pipe chain you would just use the regular `->` operator on th= e=20 > result of the previous step: > > $result =3D (trim($username) > |> $repository->findBy(name: ?) > )->getId(); > > It would also naturally support `?->` in case your repository returns=20 > `null` when the user cannot be found. Directly in a pipe chain, sure. However, I would see this as most usefu= l as a callback to array_map et al (or future equivalents). Eg: import_stuff() |> array_filter(?, (?)->hasField('comment') |> array_map((?)->save(), $records) ; In this case, the only thing being partialed is the object on which to i= nvoke. So there's no need to think about reordering the params in the f= irst place: There's just one. Needing to specify the type in this case: import_stuff() |> array_filter(?, Record::hasField('comment', ...) |> array_map(Record::save(...), $records) ; Just adds more noise, and IMO creates confusion between static and non-s= tatic methods. --Larry Garfield