@@ -37,28 +37,28 @@ class Dispatcher implements DispatcherContract
3737 /**
3838 * The registered event listeners.
3939 *
40- * @var array
40+ * @var array<string, callable|array|class-string|null>
4141 */
4242 protected $ listeners = [];
4343
4444 /**
4545 * The wildcard listeners.
4646 *
47- * @var array
47+ * @var array<string, \Closure|string>
4848 */
4949 protected $ wildcards = [];
5050
5151 /**
5252 * The cached wildcard listeners.
5353 *
54- * @var array
54+ * @var array<string, \Closure|string>
5555 */
5656 protected $ wildcardsCache = [];
5757
5858 /**
5959 * The queue resolver instance.
6060 *
61- * @var callable
61+ * @var callable(): \Illuminate\Contracts\Queue\Queue
6262 */
6363 protected $ queueResolver ;
6464
@@ -86,7 +86,7 @@ class Dispatcher implements DispatcherContract
8686 /**
8787 * The specific events to defer (null means defer all events).
8888 *
89- * @var array |null
89+ * @var string[] |null
9090 */
9191 protected $ eventsToDefer = null ;
9292
@@ -231,8 +231,8 @@ public function subscribe($subscriber)
231231 /**
232232 * Resolve the subscriber instance.
233233 *
234- * @param object|string $subscriber
235- * @return mixed
234+ * @param object|class- string $subscriber
235+ * @return $subscriber is object ? object : mixed
236236 */
237237 protected function resolveSubscriber ($ subscriber )
238238 {
@@ -248,7 +248,7 @@ protected function resolveSubscriber($subscriber)
248248 *
249249 * @param string|object $event
250250 * @param mixed $payload
251- * @return mixed
251+ * @return array|null
252252 */
253253 public function until ($ event , $ payload = [])
254254 {
@@ -339,7 +339,7 @@ protected function invokeListeners($event, $payload, $halt = false)
339339 *
340340 * @param mixed $event
341341 * @param mixed $payload
342- * @return array
342+ * @return array{string, array}
343343 */
344344 protected function parseEventAndPayload ($ event , $ payload )
345345 {
@@ -466,7 +466,7 @@ protected function prepareListeners(string $eventName)
466466 /**
467467 * Register an event listener with the dispatcher.
468468 *
469- * @param \Closure|string|array $listener
469+ * @param \Closure|string|array{class-string, string} $listener
470470 * @param bool $wildcard
471471 * @return \Closure
472472 */
@@ -512,7 +512,7 @@ public function createClassListener($listener, $wildcard = false)
512512 /**
513513 * Create the class based event callable.
514514 *
515- * @param array|string $listener
515+ * @param array{class-string, string} |string $listener
516516 * @return callable
517517 */
518518 protected function createClassCallable ($ listener )
@@ -540,7 +540,7 @@ protected function createClassCallable($listener)
540540 * Parse the class listener into class and method.
541541 *
542542 * @param string $listener
543- * @return array
543+ * @return array{class-string, string}
544544 */
545545 protected function parseClassCallable ($ listener )
546546 {
@@ -550,8 +550,9 @@ protected function parseClassCallable($listener)
550550 /**
551551 * Determine if the event handler class should be queued.
552552 *
553- * @param string $class
553+ * @param class- string $class
554554 * @return bool
555+ * @phpstan-assert-if-true \Illuminate\Contracts\Queue\ShouldQueue $class
555556 */
556557 protected function handlerShouldBeQueued ($ class )
557558 {
@@ -567,9 +568,9 @@ protected function handlerShouldBeQueued($class)
567568 /**
568569 * Create a callable for putting an event handler on the queue.
569570 *
570- * @param string $class
571+ * @param class- string $class
571572 * @param string $method
572- * @return \Closure
573+ * @return \Closure(): void
573574 */
574575 protected function createQueuedHandlerCallable ($ class , $ method )
575576 {
@@ -620,7 +621,7 @@ function () use ($listener, $method, $payload) {
620621 /**
621622 * Determine if the event handler wants to be queued.
622623 *
623- * @param string $class
624+ * @param class- string $class
624625 * @param array $arguments
625626 * @return bool
626627 */
@@ -667,10 +668,11 @@ protected function queueHandler($class, $method, $arguments)
667668 /**
668669 * Create the listener and job for a queued listener.
669670 *
670- * @param string $class
671+ * @template TListener
672+ * @param class-string<TListener> $class
671673 * @param string $method
672674 * @param array $arguments
673- * @return array
675+ * @return array{TListener, mixed}
674676 */
675677 protected function createListenerAndJob ($ class , $ method , $ arguments )
676678 {
@@ -686,7 +688,7 @@ protected function createListenerAndJob($class, $method, $arguments)
686688 *
687689 * @param mixed $listener
688690 * @param \Illuminate\Events\CallQueuedListener $job
689- * @return mixed
691+ * @return \Illuminate\Events\CallQueuedListener
690692 */
691693 protected function propagateListenerOptions ($ listener , $ job )
692694 {
@@ -767,7 +769,7 @@ protected function resolveQueue()
767769 /**
768770 * Set the queue resolver implementation.
769771 *
770- * @param callable $resolver
772+ * @param callable(): \Illuminate\Contracts\Queue\Queue $resolver
771773 * @return $this
772774 */
773775 public function setQueueResolver (callable $ resolver )
@@ -790,7 +792,7 @@ protected function resolveTransactionManager()
790792 /**
791793 * Set the database transaction manager resolver implementation.
792794 *
793- * @param callable $resolver
795+ * @param ( callable(): \Illuminate\Database\DatabaseTransactionsManager|null) $resolver
794796 * @return $this
795797 */
796798 public function setTransactionManagerResolver (callable $ resolver )
@@ -803,9 +805,10 @@ public function setTransactionManagerResolver(callable $resolver)
803805 /**
804806 * Execute the given callback while deferring events, then dispatch all deferred events.
805807 *
806- * @param callable $callback
807- * @param array|null $events
808- * @return mixed
808+ * @template TResult
809+ * @param callable(): TResult $callback
810+ * @param string[]|null $events
811+ * @return TResult
809812 */
810813 public function defer (callable $ callback , ?array $ events = null )
811814 {
0 commit comments