ajout func::withn
This commit is contained in:
parent
43f84843ae
commit
c5b9812c82
@ -478,11 +478,17 @@ class func {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static function with($func, ?array $args=null, bool $strict=true): self {
|
static function with($func, ?array $args=null, bool $strict=true): self {
|
||||||
|
if ($func instanceof self) return $func;
|
||||||
$func = self::_with($func, $args, $strict, $reason);
|
$func = self::_with($func, $args, $strict, $reason);
|
||||||
if ($func !== null) return $func;
|
if ($func !== null) return $func;
|
||||||
throw self::not_a_callable($func, $reason);
|
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 {
|
static function ensure($func, ?array $args=null, bool $strict=true): self {
|
||||||
$func = self::with($func, $args, $strict);
|
$func = self::with($func, $args, $strict);
|
||||||
if (!$func->isBound()) {
|
if (!$func->isBound()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user