James Ball

How Do You Do, Fellow Kids?

PHP Lambda Functions Approved!

1
2
3
4
5
6
$extended = function ($c) use ($callable, $factory) {
    return $callable($factory($c), $c);
};

// with arrow function:
$extended = fn($c) => $callable($factory($c), $c);
1
2
3
4
5
6
7
// Laravel collection example
$users->map(function($user) {
    return $user->first_name.' '.$user->last_name;
});

// with arrow function:
$users->map(fn($user) => $user->first_name.' '.$user->last_name);