The Pipe Operator

Read the RFC Externals
93
272 yes
131 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!
67%
33%
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

Check out another RFCs

Short Closures 2.0

This RFC proposes a way to have multi-line short closures — closures that don't need explicit use statements, but can still have multiple lines and a return statement.

101
373 yes
66 no
new MyClass()->method() without parentheses

Chain method on newly created objects without parentheses

54
94 yes
16 no
Asymmetric Visibility v2

A new syntax for declaring the “set” operation visibility of an object property

18
16 yes
39 no
RSS Feed Contribute Watch on YouTube Our License
© 2024 RFC Vote. This project is open source. Contribute and collaborate with us!