Skip to content

Commit f0e3220

Browse files
authored
Improve weakClosure() signature (#452)
1 parent 7cf7fef commit f0e3220

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,9 +446,9 @@ time differences independent of wall-time.
446446

447447
```php
448448
/**
449-
* @template TReturn
450-
* @param Closure(...):TReturn $closure
451-
* @return Closure(...):TReturn
449+
* @template TClosure of \Closure
450+
* @param TClosure $closure
451+
* @return TClosure
452452
*/
453453
function weakClosure(Closure $closure): Closure
454454
```

src/functions.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@ function trapSignal(int|array $signals, bool $reference = true, ?Cancellation $c
129129
* prevent or delay automatic garbage collection.
130130
* Invoking the returned Closure after the object is destroyed will throw an instance of Error.
131131
*
132-
* @template TReturn
132+
* @template TClosure of \Closure
133133
*
134-
* @param \Closure(...):TReturn $closure
134+
* @param TClosure $closure
135135
*
136-
* @return \Closure(...):TReturn
136+
* @return TClosure
137137
*/
138138
function weakClosure(\Closure $closure): \Closure
139139
{
@@ -167,7 +167,7 @@ function weakClosure(\Closure $closure): \Closure
167167
throw new \RuntimeException('Unable to rebind closure scoped to ' . ($scope?->name ?? $that::class));
168168
}
169169

170-
/** @var \Closure(...):TReturn */
170+
/** @var TClosure */
171171
return static function (mixed ...$args) use ($reference, $closure, $useBindTo): mixed {
172172
$that = $reference->get();
173173
if (!$that) {

0 commit comments

Comments
 (0)