Skip to content

RFC: Pipe operator #17118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 47 commits into from
Jun 10, 2025
Merged

RFC: Pipe operator #17118

merged 47 commits into from
Jun 10, 2025

Conversation

Crell
Copy link
Contributor

@Crell Crell commented Dec 11, 2024

cf: https://wiki.php.net/rfc/pipe-operator-v3

Vote has been approved, code seems clean, it should be mergable as soon as CI is happy.

@Crell Crell changed the title Pipe and function composition operators Pipe operator Feb 6, 2025
@Bilge
Copy link

Bilge commented Feb 7, 2025

Oh, nice. You're implementing your own RFCs now? 👍🏻

@Crell
Copy link
Contributor Author

Crell commented Feb 7, 2025

Well, with help. :-)

@Crell Crell force-pushed the func-composition branch 2 times, most recently from e98f4df to 2beea97 Compare March 18, 2025 16:39
@fadrian06
Copy link

If this comes to integrate it would be one of the first to try it, it looks super good

@Crell Crell marked this pull request as ready for review May 17, 2025 15:21
@Crell Crell requested a review from kocsismate as a code owner May 17, 2025 15:21
thekid added a commit to xp-framework/compiler that referenced this pull request May 18, 2025
Once php/php-src#17118 is merged, we can create a PHP 8.5 emitter which
does not include it and emits pipes natively
@Crell Crell force-pushed the func-composition branch from 9f9e054 to 9915924 Compare May 28, 2025 22:50
Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

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

If the optimization Tim mentioned could be added, that would be nice. But LGTM otherwise.

callable_ast->child[0], callable_ast->child[1], arg_list_ast);
/* Turn $foo |> $expr into ($expr)($foo) */
} else {
zend_compile_expr(&callable_result, callable_ast);
Copy link
Member

Choose a reason for hiding this comment

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

Did you check Derick's request for ZEND_EXT_STMT? It looks like their currently only emitted after statements, more or less. So, I don't think anything is needed but it would be good if you verified with him.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My understanding from the discussion in Slack was that the current code should be sufficient. I'm not sure how to verify. @derickr, please advise (or verify).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Absent any other feedback, I am pretty sure that even in the worst case Xdebug would catch the start/end of the function call anyway, just like it would if you nested functions. I think it's fine to leave as is for now; if it causes a problem for Xdebug during beta testing, that seems like a reasonable thing to fix at that time.

Copy link
Member

@nielsdos nielsdos left a comment

Choose a reason for hiding this comment

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

I'm not a fan of the 80-col wrapping as it's archaic and makes code hard to read, but that doesn't block this PR. I don't see an obvious issue

@TimWolla TimWolla added the RFC label Jun 10, 2025
@TimWolla TimWolla changed the title Pipe operator RFC: Pipe operator Jun 10, 2025
@TimWolla TimWolla merged commit 1c09c0c into php:master Jun 10, 2025
9 checks passed
@Crell Crell deleted the func-composition branch June 11, 2025 03:55
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.

8 participants