Skip to content

Commit

Permalink
feat: phpdocs for static invocations
Browse files Browse the repository at this point in the history
callStatic() breaks the intellisense in IDE's, adding respectful @method declarations of all possible methods is the only thing to make it work
  • Loading branch information
PAXANDDOS committed Mar 23, 2023
1 parent d087db4 commit 0ac1b11
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
39 changes: 20 additions & 19 deletions src/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
*
Expand All @@ -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
Expand All @@ -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.
*
Expand All @@ -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) {
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down
9 changes: 9 additions & 0 deletions src/Resque.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit 0ac1b11

Please sign in to comment.