Skip to content

Commit

Permalink
type-hint DeferredCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
shaedrich authored Dec 18, 2024
1 parent bf16f38 commit 45bd842
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Illuminate/Support/Defer/DeferredCallbackCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
use Closure;
use Countable;
use Illuminate\Support\Collection;
use Illuminate\Support\Defer\DeferredCallback;

class DeferredCallbackCollection implements ArrayAccess, Countable
{
/**
* All of the deferred callbacks.
*
* @var array
* @var \Illuminate\Support\Defer\DeferredCallback[]
*/
protected array $callbacks = [];

Expand Down Expand Up @@ -66,7 +67,7 @@ public function invokeWhen(?Closure $when = null): void
public function forget(string $name): void
{
$this->callbacks = (new Collection($this->callbacks))
->reject(fn ($callback) => $callback->name === $name)
->reject(fn (DeferredCallback $callback) => $callback->name === $name)
->values()
->all();
}
Expand All @@ -80,7 +81,7 @@ protected function forgetDuplicates(): self
{
$this->callbacks = (new Collection($this->callbacks))
->reverse()
->unique(fn ($c) => $c->name)
->unique(fn (DeferredCallback $c) => $c->name)
->reverse()
->values()
->all();
Expand Down Expand Up @@ -118,7 +119,7 @@ public function offsetGet(mixed $offset): mixed
* Set the callback with the given key.
*
* @param mixed $offset
* @param mixed $value
* @param \Illuminate\Support\Defer\DeferredCallback $value
* @return void
*/
public function offsetSet(mixed $offset, mixed $value): void
Expand Down

0 comments on commit 45bd842

Please sign in to comment.