Short Arrow Functions Approved By PHP
An RFC was proposed earlier in March 2019, which overwhelmingly passed with 51, “yes” against 8, “no” votes. Voting ended on May 1st, 2019 and as per the “A 2/3 majority is required” for an RFC to pass, we can expect to see short arrow functions in an upcoming PHP release. Short Arrow Functions is currently targeted for the PHP 7.4 release.
quoted from the RFC introduction
“Anonymous functions in PHP can be quite verbose, even when they only perform a simple operation. Partly this is due to a large amount of syntactic boilerplate, and party due to the need to manually import used variables. This makes code using simple closures hard to read and understand. This RFC proposes a more concise syntax for this pattern.”
The RFC proposed the following syntax for the short arrow functions:
fn(parameter_list) => expr.
The RFC further provides an example of how it could be used:
Read more about it here: https://wiki.php.net/rfc/arrow_functions_v2