Creates a Closure that casts an array or iterable into an object — assigns each key/value pair as a property on the target. Defaults to stdClass when no target is supplied.
/**
* @param object|null $object Target object; null = stdClass.
* @return Closure(iterable<int|string, mixed>):object
* @throws \InvalidArgumentException If a property does not exist or is not public.
*/
Arrays\toObject($object = null): ClosureWhen Arrays\toObject() is called, it returns the following Closure which can be used like a regular function.
/**
* @param iterable<int|string, mixed> $source
* @return object
*/
$function (iterable $source): objectThis can be used to create a simple closure which can be used as a regular function.
$toStd = Arrays\toObject();
$obj = $toStd(['name' => 'Ada', 'age' => 42]);
echo $obj->name; // Ada