Hi

On 2026-07-10 06:45, Caleb White wrote:
I'd like to open discussion on my (first!) RFC for the pipe assignment operator (|>=):
https://wiki.php.net/rfc/pipe_assignment_operator

I've given the RFC a read now and have the following comments:

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!

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.

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.

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(...);

Best regards
Tim Düsterhus

Reply via email to