Arrow functions are available in php 7.4. laravel news have a blog regarding arrow functions. Official rfc-arrow function.
Hope this helps.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Was just trying arrow functions within a factory.
$factory->define(Thread::class, function (Faker $faker) {
return [
'user_id' => function () {
return factory(App\User::class)->create()->id;
},
'channel_id' => fn() => factory('App\Channel')->create()->id,
'title' => $faker->text,
'body' => $faker->paragraph];
});
But I get this error: PHP Error: syntax error, unexpected '=>' (T_DOUBLE_ARROW) in...
Please or to participate in this conversation.