ajout func::withn

This commit is contained in:
Jephté Clain 2025-05-23 07:16:44 +04:00
parent 43f84843ae
commit c5b9812c82

View File

@ -478,11 +478,17 @@ class func {
}
static function with($func, ?array $args=null, bool $strict=true): self {
if ($func instanceof self) return $func;
$func = self::_with($func, $args, $strict, $reason);
if ($func !== null) return $func;
throw self::not_a_callable($func, $reason);
}
static function withn($func, ?array $args=null, bool $strict=true): ?self {
if ($func === null) return null;
else return self::with($func, $args, $strict);
}
static function ensure($func, ?array $args=null, bool $strict=true): self {
$func = self::with($func, $args, $strict);
if (!$func->isBound()) {