Skip to content

feat: add pipe assignment operator (|>=)#22633

Open
calebdw wants to merge 1 commit into
php:masterfrom
calebdw:calebdw/push-zkppokymsmqt
Open

feat: add pipe assignment operator (|>=)#22633
calebdw wants to merge 1 commit into
php:masterfrom
calebdw:calebdw/push-zkppokymsmqt

Conversation

@calebdw

@calebdw calebdw commented Jul 8, 2026

Copy link
Copy Markdown

Hello!

(aka, the weightlifter operator)

RFC: tbd (as soon as I get them wiki karma, username cdwhite3)

Thanks!

@NickSdot NickSdot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got this review myself so it caught my eye.

Comment thread Zend/tests/pipe_operator/assign_pipe_009.phpt Outdated
Comment thread Zend/tests/pipe_operator/assign_pipe_014.phpt Outdated
@calebdw calebdw force-pushed the calebdw/push-zkppokymsmqt branch from b933907 to 46028af Compare July 8, 2026 11:59
@jorgsowa

jorgsowa commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

can someone create this page for me please? https://wiki.php.net/rfc/pipe_assignment_operator)

You must do it by yourself after karma points will be granted to you. FYI: your email landed in my Gmail mailbox to spam. https://news-web.php.net/php.internals/131804

@calebdw calebdw requested a review from NickSdot July 8, 2026 14:52
@calebdw

calebdw commented Jul 8, 2026

Copy link
Copy Markdown
Author

FYI: your email landed in my Gmail mailbox to spam. https://news-web.php.net/php.internals/131804

☹️ that's not good---any idea why?

@jorgsowa

jorgsowa commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

that's not good---any idea why?

No idea, honestly. Google fights with ProtonMail around this topic, and it's quite long concern. You can check 4 years old topic here: https://www.reddit.com/r/ProtonMail/comments/v26rhi/proton_mail_emails_going_to_spam/

@TimWolla TimWolla left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some remarks to the tests.

Comment thread Zend/tests/pipe_operator/assign_pipe_001.phpt Outdated
Comment thread Zend/tests/pipe_operator/assign_pipe_002.phpt Outdated
Comment thread Zend/tests/pipe_operator/assign_pipe_004.phpt
Comment thread Zend/tests/pipe_operator/assign_pipe_005.phpt Outdated
Comment thread Zend/tests/pipe_operator/assign_pipe_009.phpt Outdated
Comment thread Zend/zend_ast.c
Comment thread Zend/tests/pipe_operator/assign_pipe_017.phpt Outdated
Comment thread Zend/tests/pipe_operator/assign_pipe_014.phpt Outdated
Comment thread Zend/tests/pipe_operator/assign_pipe_010.phpt
Comment thread Zend/tests/pipe_operator/assign_pipe_006.phpt Outdated
@calebdw calebdw force-pushed the calebdw/push-zkppokymsmqt branch from 46028af to 4253972 Compare July 8, 2026 21:04
Comment thread Zend/tests/pipe_operator/assign_pipe_001.phpt Outdated
Comment thread Zend/tests/pipe_operator/assign_pipe_003.phpt Outdated
Comment thread Zend/tests/pipe_operator/assign_pipe_004.phpt
Comment thread Zend/tests/pipe_operator/assign_pipe_005.phpt Outdated
Comment thread Zend/tests/pipe_operator/assign_pipe_009.phpt
Comment thread Zend/tests/pipe_operator/assign_pipe_016.phpt
Comment thread Zend/tests/pipe_operator/assign_pipe_ast.phpt
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.
@calebdw calebdw force-pushed the calebdw/push-zkppokymsmqt branch from 4253972 to 2db203c Compare July 9, 2026 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants