Re: [RFC] Pipe Assignment Operator
| From: | Larry Garfield | Date: | Wed, 15 Jul 2026 21:07:50 +0000 |
| Subject: | Re: [RFC] Pipe Assignment Operator | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-131947@lists.php.net to get a copy of this message | ||
On Thu, Jul 9, 2026, at 11:45 PM, Caleb White wrote:
> Hi internals,
>
> I'd like to open discussion on my (first!) RFC for the pipe assignment
> operator (|>=):
> https://wiki.php.net/rfc/pipe_assignment_operator
>
> It adds a compound assignment form of the pipe operator, so that
> $x |>= callable is shorthand for $x = $x |> callable, with
> support for chaining. Implementation with tests is at:
> https://github.com/php/php-src/pull/22633
>
> Looking forward to your feedback.
>
> Thanks!
> Caleb
Perhaps weirdly, I am not a huge fan of this RFC. I'm open to pipe-compound operators (the
other that's been suggested is a null-safe ?|>, which I'd support), but I'm not
sure of the use case for this one.
That may be because, from a functional programming point of view, piping a back to itself makes
little if any sense. Values should be immutable, so you would be doing
$b = $a |> foo(...) |> bar(...) |> baz(...);
I cannot think of a case where I would want to put $a on the left side, too. How realistic is this
use case?
I don't think this RFC would cause any harm, I suppose, so I probably won't vote against
it. But at the moment I don't see a compelling reason to vote for it. A concrete real-world
use case would help make that case, because I cannot come up with one myself.
--Larry Garfield