Re: [RFC] Pipe Assignment Operator
| From: | Caleb White | Date: | Mon, 13 Jul 2026 19:02:19 +0000 |
| Subject: | Re: [RFC] Pipe Assignment Operator | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-131904@lists.php.net to get a copy of this message | ||
On Monday, July 13th, 2026 at 12:23, Tim Düsterhus <tim@bastelstu.be> wrote:
> 1.
>
> Conceptionally I like the idea of having an “in-place modification
> operator” for function calls and the semantics of the operator seem to
> be consistent with the existing “modify-assign” operators we have,
> particularly also with regard to operand order. Nice idea!
Thanks! I'm glad others think so as well :).
> 2.
>
> I appreciate how detailed the RFC describes that the feature will just
> “work as expected” (e.g. with regard to variables targets or callable
> styles), this is good to avoid any ambiguity.
Thanks again, trying to make it as clear as possible.
> 3.
>
> The only thing I'm missing for the semantics is an explicit explanation
> of the operator precedence and associativity (it has the same precedence
> and associativity as any other assignment operator; but this needs to be
> in the RFC). And please also include explicit examples along the lines
> of:
>
> If you write
$foo |>= bar(...) |> baz(...) it will be
> interpreted as
> if you have written $foo = (($foo |> bar(...)) |>
> baz(...)) with the
> very explicit redundant parentheses.
>
> Please also include some additional more complex examples, e.g. `$foo
> |>= $bar |>= …, $foo += $bar |>= …` and similar to
> make sure there is
> no ambiguity for possible use cases that users might have.
I've added a section in the RFC for this and included more complex examples..
> 4.
>
> For the examples, I'd like to note that some of the “before” examples
> are needlessly complex and might not fairly represent the old code.
> Specifically:
>
> $input = $input |> trim(...) |> strtolower(...);
> $this->currentOrder->lineItems = $this->currentOrder->lineItems
> |> array_unique(...)
> |> array_values(...)
> |> array_reverse(...);
>
> could already be:
>
> $input = trim($input) |> strtolower(...);
> $this->currentOrder->lineItems =
> array_unique($this->currentOrder->lineItems)
> |> array_values(...)
> |> array_reverse(...);
I've cleaned up the examples to make them more representative of
existing code.
Best,
Caleb