Convert closure to arrow function Follow
In a lot of coding tutorials I see people hitting Alt+Enter and selecting: "Convert closure to arrow function". However, this is not showing in my PHPstorm editor (2021.3.1).
See for example my screenshot below. Any idea how to enable this? Thanks!
Please sign in to leave a comment.
It'd be great if you could share the code sample as text.
I can't reproduce that in 2021.3.1 on the following snippet:
Invoking Alt+Enter on
functionshows me the quick-fix.
Does this need to be enabled somewhere in the IDE? Eugene Morozov I am reproducing it with your code. I tried with the first code below and when it didn't work I googled and that brought me here. So I tried your code too. There is no option to convert closure to arrow function. I'm running a fresh install of PHPStorm 2021.3.1 and PHP -v 8.1.1 on a fresh new Laravel 8 app in the routes file. Thanks
I found it under settings>editor>inspections>php>code style> closure can be converted to arrow function but it is already enabled in both project and IDE default and still not working.
@joris Try settings>PHP and change the language level. Mine was set on 7.3 out of the box so when I tried to manually convert a closure to arrow it gave me an error stating that I had to have 7.4 or higher. I changed it to 8.1 since that is the only PHP installed on my system.
Isimmons33 I changed PHP version to 8.1 and now it's working. Thanks for providing the solution!