Short Arrow Functions Approved By PHP

Last Updated at : May 7, 2019 By - Irfan Dahir | 194

    Lots of developers (like me) have been a fan of the short arrow function usage since their addition to programming languages. In JavaScript, it has helped make coding functions/closures more concise.

    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.


    “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.”

    quoted from the RFC introduction

    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

    blog user
    Irfan Dahir

    College student living somewhere near the equator who's a coding & design enthusiast.

    Related Posts

    To expand the business across the globe your application needs some specific changes. There are many ways to handle localization in an application but today we will have to look at how to handle it on frontend using ReactJs,i18next.

    Well, that was it, now we can simply jump to validating our form data with jQuery validate plugin & see how its done in no time.

    Vue.js has taken the front-end development world by storm over the last three years. The project, however, has been around much longer than that. It started in 2013 as a one-man project by Evan You.

    You must be familiar with axios calls for API consumption, but what about getting the files in response and render those files to the user for download. We got your covered, the below snippet is tested and works well.