array_replace(). Terminal — Generator input is materialised first.
Creates a Closure that replaces values in an array or iterable based on matching keys — like array_replace() but curried.
/**
* @param mixed[] ...$with Arrays whose values override the source at matching keys.
* @return Closure(iterable<int|string, mixed>):mixed[]
*/
Arrays\replace(array ...$with): ClosureWhen Arrays\replace() 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.
$setXY = Arrays\replace(['x' => 1, 'y' => 2]);
print_r($setXY(['x' => 0, 'y' => 0, 'z' => 0]));
// ['x' => 1, 'y' => 2, 'z' => 0]