Re: [RFC] Pipe Assignment Operator

From: Date: Tue, 14 Jul 2026 08:22:04 +0000
Subject: Re: [RFC] Pipe Assignment Operator
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-131910@lists.php.net to get a copy of this message
Hi On 2026-07-13 21:02, Caleb White wrote:
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.
Thank you. One note regarding “the lowest precedence level, right-associative”. This is not quite correct. While the assignment operators have fairly low precedence, they are not the lowest. As an example, the infamous $foo = bar() or die() pattern relies on or having a lower precedence than assignment. This should be corrected. The $result = ($x |>= double(...)) |> triple(...); example also doesn't showcase precedence, because of the explicit parentheses. ------ Looking at the RFC examples again, I was reminded of this RFC: https://wiki.php.net/rfc/implicit_move_optimisation, which concerns itself with optimizing the $foo = func($foo); case. Perhaps it makes sense to list this in the references section, because with |>= this “in-place” reassignment would become an official pattern. Best regards Tim Düsterhus

« previous php.internals (#131910) next »