Function that should have never been called.
Useful for default
case in exhaustive matching.
Does nothing. Useful e.g. for match
expression that currently supports single-line expressions in blocks.
match ($val) {
'1' => throw new Exception,
'2' => foo(),
default => noop(),
};
Creates a map from an iterable of entries.
use function Cdn77\Functions\mapFromEntries;
$map = mapFromEntries([
['foo', 'bar'],
['baz', 'qux'],
]);
assert($map->get('foo') === 'bar');
Finds a value in an iterable.
use function Cdn77\Functions\Iterable\find;
$iterable = [0, 1, 2, 3];
$option = find($iterable, static fn (mixed $_, int $value) => $value < 2);
assert($option->unwrap() === 0);