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.
Would prove very useful in more complex array_map or array_filter usages
Syntax similar to default, without use statement and short for "return".
function($item) use ($baz) { $this->foo($item + $baz); return $this->bar($item); }
to
fn($item) { $this->foo($item + $baz); => $this->bar($item); }
Every major languages had this long time ago. Why is this still the subject for discussion, I don't understand. I don't think it affects performance of the language.
improves readability
This makes code much more readable and beautiful. I think the last line can be returned without having the return keyword like ruby and some other languages.
it just a good next step towards clean and readable code.
It will make php more consistent
The point of short closure is to be one instruction only, plus you can already have the body of a short closure on multiple lines.
Regular closure can do multiple lines and instruction already.
To me this is a tiny syntactic sugar that is really unecessary.
would make the code more readable, instead of the need to pass multiple parameters through the use()
I thought short closures 1.0 was a step in the right direction, I would like to see this continued.
seems obvious
Not a fan of closures.
These things can be useful in specific cases, but as i've seen someone else mention aswel shouldn't be used carelessly. In my opinion closures, especially when scattered throughout a codebase, make code hard to read.
Hiding scope makes this even more dangerous. It shouldn't always be about "faster to type", "less lines" or "doesnt require me to think". We should make sure everyone is able to work together on a codebase, we can do that by being explicit.
Please don't make javascript 2.0.
Small but nice QoL improvement
I always hoped it would work this way
Interface Default Methods improves backwards compatibility when changing interfaces, but also add a way to have multi-inheritance in PHP.
A new syntax for declaring the “set” operation visibility of an object property