calebdw · GitHub

@calebdw

Adds the `|>=` compound assignment operator for the pipe operator,
allowing `$x |>= callable` to be used as shorthand for `$x = $x |> callable`.
Supports pipe chains on the RHS:
`$x |>= fn1(...) |> fn2(...) |> fn3(...)`
is equivalent to
`$x = $x |> fn1(...) |> fn2(...) |> fn3(...)`.
Implementation modeled after `??=` (ZEND_AST_ASSIGN_COALESCE), with a
dedicated AST node (ZEND_AST_ASSIGN_PIPE) and compiler function that
uses memoization to avoid double-evaluating complex LHS expressions.
Extracts shared callable dispatch logic into zend_pipe_build_fcall()
helper used by both `|>` and `|>=` compilation.
All variable target types supported: simple vars, array dims, object
properties, static properties.

Read the original on github.com ↗