The Pipe Operator

Read the RFC Externals
87
253 yes
119 no

The "pipe operator" |> allows you to chain multiple function calls in a more convenient way.

$result = "Hello World"
    |> 'htmlentities'
    |> 'str_split'
    |> fn($x) => array_map('strtoupper', $x)
    |> fn($x) => array_filter($x, fn($v) => $v != 'O');

This RFC was already declined, but we're sharing it here as another test RFC, and because it'd be interesting to learn people's opinion about it.

Click the bar to cast your vote!
68%
32%
1

Could be nice, but like said by others without the function define using string

Share:
jarbey avatar
jarbey
voted yes
1

Much clearer than nesting multiple calls.

Share:
przemyslaw avatar
przemyslaw
voted yes
1

I like the idea, but I really don't like the proposed syntax. It looks like I'm reading a totally different language. I could get behind this if the syntax was prettier.

Share:
thomasalrek avatar
thomasalrek
voted no
1

Using first-class callables, this addition would be so dope! 🔥

Share:
zois avatar
zois
voted yes
1

In general I would love to see this added to PHP It would make it easier to debug a flow as well even without tools like XDebug because during development you would be able to insert a |> dd(...) for instance

Share:
Carakas avatar
Carakas
voted yes
1

I did not like writing function names between quotation marks

Share:
tasarsu avatar
tasarsu
voted no
1

for my part, I don't have any arguments except that I much prefer pipeline systems and not having long code like that... it's a question of readability

Share:
grazulex avatar
grazulex
voted no
1

Such an awful RFC and people are voting for it 😱, weird. I agree with Rasmus Lerdorf, Nikita Popov and Sebastian Bergmann, this PR should NOT go into the language.

I think we should focus more on improving the performance and fixing things that people don't like in PHP rather than implementing new features.

We already have a solid language that does so many things for us, everything else is provided by frameworks. I understand why people want to see features like this one, but I would prefer to focus on the performance and cleaning up the codebase of PHP source code.

Share:
Contributor serhii avatar
serhii
voted no
1

The language does not need this fancy tools, what we really need is better support for types, kinda like whats Typescript did for JS.

Share:
isaacsouza avatar
isaacsouza
voted no
1

This is another RFC that focuses on the Developer Experience of PHP and gets shutdown by internals because of bikeshedding or lack of interest in doing things for the sake of improving DX. The syntax allows for clear and concise code and goes hand-in-hand with First-party callable and short arrow functions. There aren't many things that can be expressed in a syntax, but this one can replace entire PHP libraries (kind of similar to PHP Enum) and make the entire pipeline process in PHP fluid and readable.

Share:
marco avatar
marco
voted yes
1

"Very good idea, but it would be nice to avoid using strings in the function calls."

Share:
gilbertrdzdev avatar
gilbertrdzdev
voted yes
1

Doesn't this proposal conflict with the Hack-like pipe operator where you can choose which argument to pipe into, using $$? This is not necessarily a no-vote, just a listed concern. :)

Also, the examples should use str_split(...) syntax, not strings, IMO.

Share:
olleharstedt avatar
olleharstedt
voted no
RSS Feed Contribute Watch on YouTube Our License
© 2024 RFC Vote. This project is open source. Contribute and collaborate with us!