From 751933fc37994a6cc4e60845dbf7a3f3b5957eca Mon Sep 17 00:00:00 2001 From: Valentin Udaltsov Date: Fri, 2 May 2025 13:07:24 +0300 Subject: [PATCH] Improve weakClosure() signature --- README.md | 6 +++--- src/functions.php | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 15d2af30..66f1b24c 100644 --- a/README.md +++ b/README.md @@ -446,9 +446,9 @@ time differences independent of wall-time. ```php /** - * @template TReturn - * @param Closure(...):TReturn $closure - * @return Closure(...):TReturn + * @template TClosure of \Closure + * @param TClosure $closure + * @return TClosure */ function weakClosure(Closure $closure): Closure ``` diff --git a/src/functions.php b/src/functions.php index 0d3bfcce..bff06585 100644 --- a/src/functions.php +++ b/src/functions.php @@ -129,11 +129,11 @@ function trapSignal(int|array $signals, bool $reference = true, ?Cancellation $c * prevent or delay automatic garbage collection. * Invoking the returned Closure after the object is destroyed will throw an instance of Error. * - * @template TReturn + * @template TClosure of \Closure * - * @param \Closure(...):TReturn $closure + * @param TClosure $closure * - * @return \Closure(...):TReturn + * @return TClosure */ function weakClosure(\Closure $closure): \Closure { @@ -167,7 +167,7 @@ function weakClosure(\Closure $closure): \Closure throw new \RuntimeException('Unable to rebind closure scoped to ' . ($scope?->name ?? $that::class)); } - /** @var \Closure(...):TReturn */ + /** @var TClosure */ return static function (mixed ...$args) use ($reference, $closure, $useBindTo): mixed { $that = $reference->get(); if (!$that) {