Short Closures 2.0

Read the RFC
98
368 yes
65 no

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.

Click the bar to cast your vote!
85%
15%
1

Short doesn't mean one line, sometimes few lines may be needed to express the operation.

Another advantage of closures is the access to the outer scope.

Most important thing is to not abuse of this feature and switch to this syntax instead of the canonical function syntax.

Share:
rinodrummer avatar
rinodrummer
voted yes
1

Yeah this a way better alternative to function () use ()

Share:
alejandrotrevi avatar
alejandrotrevi
voted yes
1

When it gets deferred or closure comes from other place - it may play the evil trick, that will make you use several new copies of same variable just to exclude context from place, where the variable could be updated.

Share:
slavytuch avatar
slavytuch
voted no
1

Either this, or something like a use(*) would make the code easier to read and write. Makes sense to me. All major languages has this feature. I don't understand the push back from the core team.

Share:
takaoyama avatar
takaoyama
voted yes
1

I think the potential confusion this adds is not worth the small amount of extra code that would need to be written to use an anonymous function

Share:
moebrowne avatar
moebrowne
voted no
1

i really like this feature from js, so why not have it in php?

Share:
roeycohen avatar
roeycohen
voted yes
1

I love short closure syntax for multi lines.

Share:
thurasolinxtechnology avatar
thurasolinxtechnol...
voted yes
1

This seems a lot better thought through than the original RFC. Although I'm not usually in favour of having two different ways of doing two similar things, in this case it makes readability better and covers cases which otherwise would have to use the more verbose function and use method.

Share:
nathansalter avatar
nathansalter
voted yes
1

Why not? It won't hurt anyone. Those who love it will be able to use it, those who hate it won't.

Share:
sukei avatar
sukei
voted yes
1

There is so much boilerplate and "noise" when not using arrow functions due to having to have multiple lines. Creating a way to keep the terse code while expanding the allowed lines, is huge.

Share:
conor avatar
conor
voted yes
1

Will make our lives much more easier.

Share:
francisco avatar
francisco
voted yes
1

Let PHP advance to the future and become more accessible for newcomers. Allow bypassing the variable scope and the horrible use statement!

Share:
zois avatar
zois
voted yes
1

I would really love this!

Share:
william-2 avatar
william-2
voted yes
1

It keeps code so much cleaner, easier to read, and is already intuitive because of how most modern frontend apps are written.

Share:
kegan avatar
kegan
voted yes
1

It's not an uncommon syntax. Other languages do this. Could be handy. If you're against it, just write it the long way and/or have your code sniffer reject it. You don't have to use it.

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