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 doesn't appear in any popular language and does not bring any benefit to readability.

Share:
riki137 avatar
riki137
voted no
1

this actually looks not pretty

Share:
sunxyw avatar
sunxyw
voted no
1

I think it's a very nice way to simplify code. For me it looks readable and cleaner without the need of creating temporal variables.

Share:
marcmorente avatar
marcmorente
voted yes
1

It's not crucial, but it's gonna make code more readable and clear in a way. But It would be even greater if we had literals for passing functions instead of strings, (e.g. |> htmlentities(...) instead of |> 'htmlentities').

Share:
ozahorulia avatar
ozahorulia
voted yes
1

The new syntax is noisy. It adds more cognitive load to the currently available function invocation methods.

The existing libraries supporting pipelining do it fine without extending the language syntax.

Share:
anibalsanchez avatar
anibalsanchez
voted no
1

PHP is well known for "historic growth", i.e. internal functions often may return false instead of throwing an exception. I feel that using syntactic sugar to allow to travel the "optimistic path" (simply assuming the involved functions do not return false) is a bad idea.

Share:
invisiblesmiley avatar
invisiblesmiley
voted no
1

I've long been a fan of the pipeline operator, it is such a minor syntax change that gets in the way of nothing, but allows for, in my opinion, a much cleaner and more readable set of procedural code where you can read naturally from top-to-bottom instead of middle-out.

Share:
liam avatar
liam
voted yes
1

Having used functional programming languages before, the pipe operator is immensely useful in performing transformation on a data structure in a nice and concise way, with minimal boilerplate needed.

Share:
askonomm avatar
askonomm
voted yes
1

I like the clean syntax. It would allow chaining items and removing the function within a function within a function that quickly becomes an ugly and confusing mess of code.

Share:
jim avatar
jim
voted yes
1

because is veri beutiful

Share:
pablohernandez avatar
pablohernandez
voted yes
1

I do not like the notation with the function names as string but apart from that I think it can make processing arrays and strings more painless.

Share:
alexander avatar
alexander
voted yes
1

I'm not really hot about this feature. It doesn't really add anything, it's just sugar syntax. We should use this operator for something else, way more complex that can't simply be emulated userland, and a simple function will do the same job that this RFC proposes.

On the other hand, if other popular languages have this, in that case I'll change my vote to Yes, I'm open-minded.

Share:
dorotheexplorer avatar
dorotheexplorer
voted no
1

This syntax is really not what PHP needs to be striving for. The idea is nice and SHOULD be revisited with cleaner and more modern syntax, but i'm against the proposal as it is presented right here.

Share:
simonvanacco avatar
simonvanacco
voted no
1

It makes the code more readable, isn't one of the things we all strive for ?

Share:
sidux avatar
sidux
voted yes
1

Great with RFC: First-class callable syntax

Share:
indigoram89 avatar
indigoram89
voted yes

Check out another RFCs

Asymmetric Visibility v2

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

19
16 yes
40 no
Property Hooks

A new way of interacting with properties

70
141 yes
90 no
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
RSS Feed Contribute Watch on YouTube Our License
© 2024 RFC Vote. This project is open source. Contribute and collaborate with us!