From c5b9812c82a220f54af20078f335f3189f174b9e Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Fri, 23 May 2025 07:16:44 +0400 Subject: [PATCH] ajout func::withn --- php/src/php/func.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/php/src/php/func.php b/php/src/php/func.php index f2d2883..fcec77b 100644 --- a/php/src/php/func.php +++ b/php/src/php/func.php @@ -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()) {