e15991d299
PHP Composer / build (push) Successful in 31s
- Namespace Tez\Utils -> Tezmanian\Utils, package tez/* -> tezmanian/* - Add keywords, homepage, authors and support metadata - Drop VCS repositories (resolved via Packagist) - Remove stale composer.lock, set license holder
24 lines
594 B
PHP
24 lines
594 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tezmanian\Utils\Fn;
|
|
|
|
/**
|
|
* Pre-fills the leading arguments of a callable and returns a new Closure
|
|
* that accepts the remaining arguments.
|
|
*/
|
|
final class Partial
|
|
{
|
|
/**
|
|
* Returns a Closure with $partial pre-filled as the leftmost arguments.
|
|
* The returned Closure forwards any additional arguments to $fn.
|
|
*/
|
|
public static function apply(callable $fn, mixed ...$partial): \Closure
|
|
{
|
|
return static function () use ($fn, $partial): mixed {
|
|
return $fn(...$partial, ...func_get_args());
|
|
};
|
|
}
|
|
}
|