diff --git a/lib/Event.php b/lib/Event.php index c5cb507..6ae5911 100644 --- a/lib/Event.php +++ b/lib/Event.php @@ -12,7 +12,7 @@ class Event { /** - * @var array Array containing all registered callbacks, indexked by event name. + * @var array Array containing all registered callbacks, indexed by event name. */ private static $events = array(); @@ -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) @@ -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) diff --git a/lib/FailureHandler.php b/lib/FailureHandler.php index c2c2038..771402e 100644 --- a/lib/FailureHandler.php +++ b/lib/FailureHandler.php @@ -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; @@ -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) { diff --git a/lib/JobHandler.php b/lib/JobHandler.php index 94326f9..b836c21 100755 --- a/lib/JobHandler.php +++ b/lib/JobHandler.php @@ -16,6 +16,8 @@ * @package Resque/JobHandler * @author Chris Boulton * @license http://www.opensource.org/licenses/mit-license.php + * + * @phpstan-import-type Args from Scheduler */ class JobHandler { @@ -30,7 +32,7 @@ class JobHandler public ResqueWorker $worker; /** - * @var array Array containing details of the job. + * @var array Array containing details of the job. */ public array $payload; @@ -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 $payload array containing details of the job. */ public function __construct($queue, $payload) { @@ -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 = "") { @@ -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) { @@ -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) { @@ -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 { @@ -249,7 +251,7 @@ public function perform() /** * Mark the current job as having failed. * - * @param $exception + * @param \Throwable $exception */ public function fail($exception) { @@ -282,7 +284,7 @@ public function fail($exception) /** * Re-queue the current job. - * @return string + * @return string new Job ID */ public function recreate() { diff --git a/lib/Manager.php b/lib/Manager.php index 57a32db..5c988cc 100644 --- a/lib/Manager.php +++ b/lib/Manager.php @@ -8,6 +8,8 @@ * @package Resque * @author Heinz Wiesinger * @license http://www.opensource.org/licenses/mit-license.php + * + * @phpstan-import-type Args from Scheduler */ class Manager { @@ -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 * @@ -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()) { @@ -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()) { @@ -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) @@ -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) diff --git a/lib/Redis.php b/lib/Redis.php index 8378e2b..443a0a3 100644 --- a/lib/Redis.php +++ b/lib/Redis.php @@ -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( @@ -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 @@ -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) diff --git a/lib/Resque.php b/lib/Resque.php index e5158f4..0d2b1ce 100644 --- a/lib/Resque.php +++ b/lib/Resque.php @@ -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 $item Job description as an array to be JSON encoded. */ public static function push($queue, $item) { diff --git a/lib/Scheduler.php b/lib/Scheduler.php index 4863829..ae9c85c 100644 --- a/lib/Scheduler.php +++ b/lib/Scheduler.php @@ -13,6 +13,8 @@ * @author Chris Boulton * @copyright (c) 2012 Chris Boulton * @license http://www.opensource.org/licenses/mit-license.php +* +* @phpstan-type Args array */ class Scheduler { @@ -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()) { @@ -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()) { @@ -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) @@ -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) @@ -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) @@ -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 */