Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class Event
{
/**
* @var array Array containing all registered callbacks, indexked by event name.
* @var array<string, callable[]> Array containing all registered callbacks, indexed by event name.
*/
private static $events = array();

Expand Down Expand Up @@ -47,7 +47,7 @@ public static function trigger($event, $data = null)
* Listen in on a given event to have a specified callback fired.
*
* @param string $event Name of event to listen on.
* @param mixed $callback Any callback callable by call_user_func_array.
* @param callable $callback Any callback callable by call_user_func_array.
* @return true
*/
public static function listen($event, $callback)
Expand All @@ -64,7 +64,7 @@ public static function listen($event, $callback)
* Stop a given callback from listening on a specific event.
*
* @param string $event Name of event.
* @param mixed $callback The callback as defined when listen() was called.
* @param callable $callback The callback as defined when listen() was called.
* @return true
*/
public static function stopListening($event, $callback)
Expand Down
4 changes: 2 additions & 2 deletions lib/FailureHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class FailureHandler
{
/**
* @var string Class name representing the backend to pass failed jobs off to.
* @var class-string Class name representing the backend to pass failed jobs off to.
*/
private static $backend;

Expand Down Expand Up @@ -69,7 +69,7 @@ public static function getBackend()
* should be the name of a class to be instantiated when a job fails.
* It is your responsibility to have the backend class loaded (or autoloaded)
*
* @param string $backend The class name of the backend to pipe failures to.
* @param class-string $backend The class name of the backend to pipe failures to.
*/
public static function setBackend($backend)
{
Expand Down
22 changes: 12 additions & 10 deletions lib/JobHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* @package Resque/JobHandler
* @author Chris Boulton <chris@bigcommerce.com>
* @license http://www.opensource.org/licenses/mit-license.php
*
* @phpstan-import-type Args from Scheduler
*/
class JobHandler
{
Expand All @@ -30,7 +32,7 @@ class JobHandler
public ResqueWorker $worker;

/**
* @var array Array containing details of the job.
* @var array<string, mixed> Array containing details of the job.
*/
public array $payload;

Expand Down Expand Up @@ -63,7 +65,7 @@ class JobHandler
* Instantiate a new instance of a job.
*
* @param string $queue The queue that the job belongs to.
* @param array $payload array containing details of the job.
* @param array<string, mixed> $payload array containing details of the job.
*/
public function __construct($queue, $payload)
{
Expand All @@ -80,13 +82,13 @@ public function __construct($queue, $payload)
* Create a new job and save it to the specified queue.
*
* @param string $queue The name of the queue to place the job in.
* @param string $class The name of the class that contains the code to execute the job.
* @param array $args Any optional arguments that should be passed when the job is executed.
* @param class-string $class The name of the class that contains the code to execute the job.
* @param Args $args Any optional arguments that should be passed when the job is executed.
* @param boolean $monitor Set to true to be able to monitor the status of a job.
* @param string $id Unique identifier for tracking the job. Generated if not supplied.
* @param string $prefix The prefix needs to be set for the status key
*
* @return string
* @return string Job ID
*/
public static function create($queue, $class, array $args = [], $monitor = false, $id = null, $prefix = "")
{
Expand Down Expand Up @@ -114,7 +116,7 @@ public static function create($queue, $class, array $args = [], $monitor = false
* instance of JobHandler for it.
*
* @param string $queue The name of the queue to check for a job in.
* @return false|object Null when there aren't any waiting jobs, instance of Resque\JobHandler when a job was found.
* @return false|JobHandler False when there aren't any waiting jobs, instance of Resque\JobHandler when a job was found.
*/
public static function reserve($queue)
{
Expand All @@ -132,7 +134,7 @@ public static function reserve($queue)
*
* @param array $queues
* @param int $timeout
* @return false|object Null when there aren't any waiting jobs, instance of Resque\JobHandler when a job was found.
* @return false|JobHandler False when there aren't any waiting jobs, instance of Resque\JobHandler when a job was found.
*/
public static function reserveBlocking(array $queues, $timeout = null)
{
Expand Down Expand Up @@ -180,7 +182,7 @@ public function getStatus()
/**
* Get the arguments supplied to this job.
*
* @return array Array of arguments.
* @return Args Array of arguments.
*/
public function getArguments(): array
{
Expand Down Expand Up @@ -249,7 +251,7 @@ public function perform()
/**
* Mark the current job as having failed.
*
* @param $exception
* @param \Throwable $exception
*/
public function fail($exception)
{
Expand Down Expand Up @@ -282,7 +284,7 @@ public function fail($exception)

/**
* Re-queue the current job.
* @return string
* @return string new Job ID
*/
public function recreate()
{
Expand Down
28 changes: 15 additions & 13 deletions lib/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* @package Resque
* @author Heinz Wiesinger <pprkut@liwjatan.org>
* @license http://www.opensource.org/licenses/mit-license.php
*
* @phpstan-import-type Args from Scheduler
*/
class Manager
{
Expand Down Expand Up @@ -45,8 +47,8 @@ public function setBackend($server, $database = 0, $auth = null)
* Create a new job and save it to the specified queue.
*
* @param string $queue The name of the queue to place the job in.
* @param string $class The name of the class that contains the code to execute the job.
* @param array $args Any optional arguments that should be passed when the job is executed.
* @param class-string $class The name of the class that contains the code to execute the job.
* @param Args $args Any optional arguments that should be passed when the job is executed.
* @param boolean $trackStatus Set to true to be able to monitor the status of a job.
* @param string $prefix The prefix needs to be set for the status key
*
Expand Down Expand Up @@ -131,8 +133,8 @@ public function items($queue, $start = 0, $stop = -1)
*
* @param int $in Number of seconds from now when the job should be executed.
* @param string $queue The name of the queue to place the job in.
* @param string $class The name of the class that contains the code to execute the job.
* @param array $args Any optional arguments that should be passed when the job is executed.
* @param class-string $class The name of the class that contains the code to execute the job.
* @param Args $args Any optional arguments that should be passed when the job is executed.
*/
public function enqueueIn($in, $queue, $class, array $args = array())
{
Expand All @@ -148,8 +150,8 @@ public function enqueueIn($in, $queue, $class, array $args = array())
*
* @param \DateTime|int $at Instance of PHP DateTime object or int of UNIX timestamp.
* @param string $queue The name of the queue to place the job in.
* @param string $class The name of the class that contains the code to execute the job.
* @param array $args Any optional arguments that should be passed when the job is executed.
* @param class-string $class The name of the class that contains the code to execute the job.
* @param Args $args Any optional arguments that should be passed when the job is executed.
*/
public function enqueueAt($at, $queue, $class, $args = array())
{
Expand Down Expand Up @@ -187,9 +189,9 @@ public function getDelayedTimestampSize($timestamp)
* also, this is an expensive operation because all delayed keys have tobe
* searched
*
* @param $queue
* @param $class
* @param $args
* @param string $queue
* @param class-string $class
* @param Args $args
* @return int number of jobs that were removed
*/
public function removeDelayed($queue, $class, $args)
Expand All @@ -204,10 +206,10 @@ public function removeDelayed($queue, $class, $args)
* queue, class and arguments that you used when you added
* to the delayed queue
*
* @param $timestamp
* @param $queue
* @param $class
* @param $args
* @param \DateTime|int $timestamp
* @param string $queue
* @param class-string $class
* @param Args $args
* @return mixed
*/
public function removeDelayedJobFromTimestamp($timestamp, $queue, $class, $args)
Expand Down
6 changes: 3 additions & 3 deletions lib/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Redis
private $driver;

/**
* @var array List of all commands in Redis that supply a key as their
* @var string[] List of all commands in Redis that supply a key as their
* first argument. Used to prefix keys with the Resque namespace.
*/
private $keyCommands = array(
Expand Down Expand Up @@ -146,7 +146,7 @@ public static function prefix($namespace)
}

/**
* @param string|array $server A DSN or array
* @param string|string[] $server A DSN or array
* @param int $database A database number to select. However, if we find a valid database number in the DSN the
* DSN-supplied value will be used instead and this parameter is ignored.
* @param object $client Optional Credis_Cluster or Credis_Client instance instantiated by you
Expand Down Expand Up @@ -201,7 +201,7 @@ public function __construct($server, $database = null, $client = null)
* Note: the 'user' part of the DSN is not used.
*
* @param string $dsn A DSN string
* @return array An array of DSN compotnents, with 'false' values for any unknown components. e.g.
* @return string[] An array of DSN compotnents, with 'false' values for any unknown components. e.g.
* [host, port, db, user, pass, options]
*/
public static function parseDsn($dsn)
Expand Down
2 changes: 1 addition & 1 deletion lib/Resque.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public static function fork()
* exist, then create it as well.
*
* @param string $queue The name of the queue to add the job to.
* @param array $item Job description as an array to be JSON encoded.
* @param array<string,mixed> $item Job description as an array to be JSON encoded.
*/
public static function push($queue, $item)
{
Expand Down
30 changes: 16 additions & 14 deletions lib/Scheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @author Chris Boulton <chris@bigcommerce.com>
* @copyright (c) 2012 Chris Boulton
* @license http://www.opensource.org/licenses/mit-license.php
*
* @phpstan-type Args array<string, scalar|array>
*/
class Scheduler
{
Expand All @@ -26,8 +28,8 @@ class Scheduler
*
* @param int $in Number of seconds from now when the job should be executed.
* @param string $queue The name of the queue to place the job in.
* @param string $class The name of the class that contains the code to execute the job.
* @param array $args Any optional arguments that should be passed when the job is executed.
* @param class-string $class The name of the class that contains the code to execute the job.
* @param Args $args Any optional arguments that should be passed when the job is executed.
*/
public static function enqueueIn($in, $queue, $class, array $args = array())
{
Expand All @@ -43,8 +45,8 @@ public static function enqueueIn($in, $queue, $class, array $args = array())
*
* @param \DateTime|int $at Instance of PHP DateTime object or int of UNIX timestamp.
* @param string $queue The name of the queue to place the job in.
* @param string $class The name of the class that contains the code to execute the job.
* @param array $args Any optional arguments that should be passed when the job is executed.
* @param class-string $class The name of the class that contains the code to execute the job.
* @param Args $args Any optional arguments that should be passed when the job is executed.
*/
public static function enqueueAt($at, $queue, $class, $args = array())
{
Expand Down Expand Up @@ -108,9 +110,9 @@ public static function getDelayedTimestampSize($timestamp)
* also, this is an expensive operation because all delayed keys have tobe
* searched
*
* @param $queue
* @param $class
* @param $args
* @param string $queue
* @param class-string $class
* @param Args $args
* @return int number of jobs that were removed
*/
public static function removeDelayed($queue, $class, $args)
Expand All @@ -134,10 +136,10 @@ public static function removeDelayed($queue, $class, $args)
* queue, class and arguments that you used when you added
* to the delayed queue
*
* @param $timestamp
* @param $queue
* @param $class
* @param $args
* @param \DateTime|int $timestamp
* @param string $queue
* @param class-string $class
* @param Args $args
* @return mixed
*/
public static function removeDelayedJobFromTimestamp($timestamp, $queue, $class, $args)
Expand All @@ -155,8 +157,8 @@ public static function removeDelayedJobFromTimestamp($timestamp, $queue, $class,
* Generate hash of all job properties to be saved in the scheduled queue.
*
* @param string $queue Name of the queue the job will be placed on.
* @param string $class Name of the job class.
* @param array $args Array of job arguments.
* @param class-string $class Name of the job class.
* @param Args $args Array of job arguments.
*/

private static function jobToHash($queue, $class, $args)
Expand Down Expand Up @@ -258,7 +260,7 @@ public static function nextItemForTimestamp($timestamp)
/**
* Ensure that supplied job class/queue is valid.
*
* @param string $class Name of job class.
* @param class-string $class Name of job class.
* @param string $queue Name of queue.
* @throws \Resque\Exceptions\ResqueException
*/
Expand Down