From 0ac1b11c27d19a4b38f6ef757bdd0949bf64ee34 Mon Sep 17 00:00:00 2001 From: Paul <40315177+PAXANDDOS@users.noreply.github.com> Date: Thu, 23 Mar 2023 20:27:41 +0200 Subject: [PATCH] feat: phpdocs for static invocations callStatic() breaks the intellisense in IDE's, adding respectful @method declarations of all possible methods is the only thing to make it work --- src/Queue.php | 39 ++++++++++++++++++++------------------- src/Resque.php | 9 +++++++++ 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/Queue.php b/src/Queue.php index 465f635..6fb599e 100644 --- a/src/Queue.php +++ b/src/Queue.php @@ -30,7 +30,19 @@ final class Queue protected string $default; /** - * Get the Queue key + * Create a new queue instance + * + * @param string $default Name of default queue to add job to + */ + public function __construct(?string $default = null) + { + $this->redis = Redis::instance(); + + $this->default = $default ?: Config::read('default.jobs.queue', 'default'); + } + + /** + * Get the Queue key. * * @param string|null $queue the worker to get the key for * @param string|null $suffix to be appended to key @@ -47,19 +59,7 @@ public static function redisKey(?string $queue = null, ?string $suffix = null): } /** - * Create a new queue instance - * - * @param string $default Name of default queue to add job to - */ - public function __construct(?string $default = null) - { - $this->redis = Redis::instance(); - - $this->default = $default ?: Config::read('default.jobs.queue', 'default'); - } - - /** - * Get a job by id + * Get a job by id. * * @param string $id Job id * @@ -71,7 +71,7 @@ public function job(string $id): Job } /** - * Push a new job onto the queue + * Push a new job onto the queue. * * @param string|callable $job The job class * @param array $data The job data @@ -89,7 +89,8 @@ public function push($job, ?array $data = null, ?string $queue = null): Job } /** - * Queue a job for later retrieval. Jobs are unique per queue and + * Queue a job for later retrieval. + * Jobs are unique per queue and * are deleted upon retrieval. If a given job (payload) already exists, * it is updated with the new delay. * @@ -100,7 +101,7 @@ public function push($job, ?array $data = null, ?string $queue = null): Job * * @return Job job instance */ - public function later($delay, $job, array $data = [], ?string $queue = null) + public function later($delay, $job, array $data = [], ?string $queue = null): Job { // If it's a datetime object conver to unix time if ($delay instanceof \DateTime) { @@ -160,7 +161,7 @@ public function pop(array $queues, int $timeout = 10, bool $blocking = true) } /** - * Return the size (number of pending jobs) of the specified queue. + * Get the size (number of pending jobs) of the specified queue. * * @param string $queue name of the queue to be checked for pending jobs * @return int The size of the queue. @@ -171,7 +172,7 @@ public function size(string $queue): int } /** - * Return the size (number of delayed jobs) of the specified queue. + * Get the size (number of delayed jobs) of the specified queue. * * @param string $queue name of the queue to be checked for delayed jobs * @return int The size of the delayed queue. diff --git a/src/Resque.php b/src/Resque.php index 265a537..4d826af 100644 --- a/src/Resque.php +++ b/src/Resque.php @@ -16,6 +16,15 @@ * * @package Resque * @author Michael Haynes + * + * @method static string redisKey(?string $queue = null, ?string $suffix = null) Get the Queue key. + * @method static \Resque\Job job(string $id) Get a job by id. + * @method static \Resque\Job push($job, ?array $data = null, ?string $queue = null) Push a new job onto the queue. + * @method static \Resque\Job later($job, ?array $data = null, ?string $queue = null) Queue a job for later retrieval. + * @method static \Resque\Job|false pop(array $queues, int $timeout = 10, bool $blocking = true) Pop the next job off of the queue. + * @method static int size(string $queue) Get the size (number of pending jobs) of the specified queue. + * @method static int sizeDelayed(string $queue) Get the size (number of delayed jobs) of the specified queue. + * @method static string getQueue(?string $queue) Get the queue or return the default. */ class Resque {