array_replace_recursive(). Terminal on Generator input.
Creates a Closure that recursively replaces values in an array or iterable based on matching keys — like array_replace_recursive() but curried.
/**
* @param mixed[] ...$with
* @return Closure(iterable<int|string, mixed>):mixed[]
*/
Arrays\replaceRecursive(array ...$with): ClosureWhen Arrays\replaceRecursive() is called, it returns the following Closure which can be used like a regular function.
/**
* @param iterable<int|string, mixed> $source
* @return mixed[]
*/
$function (iterable $source): arrayThis can be used to create a simple closure which can be used as a regular function.
$defaults = ['theme' => ['font' => 'Arial', 'size' => 12]];
$setFont = Arrays\replaceRecursive(['theme' => ['font' => 'Comic Sans']]);
print_r($setFont($defaults));
// ['theme' => ['font' => 'Comic Sans', 'size' => 12]]