Skip to content

Commit 1b5441b

Browse files
author
Chris Boulton
committed
Merge branch 'master' of github.com:chrisboulton/php-resque
2 parents ad7f4d1 + 76c06a1 commit 1b5441b

File tree

4 files changed

+24
-11
lines changed

4 files changed

+24
-11
lines changed

lib/Resque.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ class Resque
4141
* the redis server that Resque will talk to.
4242
*
4343
* @param mixed $server Host/port combination separated by a colon, or
44-
* a nested array of servers with host/port pairs.
44+
* a nested array of servers with host/port pairs.
45+
* @param int $database
4546
*/
4647
public static function setBackend($server, $database = 0)
4748
{
@@ -127,6 +128,8 @@ public static function pop($queue)
127128
/**
128129
* Return the size (number of pending jobs) of the specified queue.
129130
*
131+
* @param $queue name of the queue to be checked for pending jobs
132+
*
130133
* @return int The size of the queue.
131134
*/
132135
public static function size($queue)
@@ -140,7 +143,9 @@ public static function size($queue)
140143
* @param string $queue The name of the queue to place the job in.
141144
* @param string $class The name of the class that contains the code to execute the job.
142145
* @param array $args Any optional arguments that should be passed when the job is executed.
143-
* @param boolean $monitor Set to true to be able to monitor the status of a job.
146+
* @param boolean $trackStatus Set to true to be able to monitor the status of a job.
147+
*
148+
* @return string
144149
*/
145150
public static function enqueue($queue, $class, $args = null, $trackStatus = false)
146151
{

lib/Resque/Failure.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ class Resque_Failure
1919
/**
2020
* Create a new failed job on the backend.
2121
*
22-
* @param object $payload The contents of the job that has just failed.
23-
* @param object $exception The exception generated when the job failed to run.
24-
* @param object $worker Instance of Resque_Worker that was running this job when it failed.
25-
* @param string $queue The name of the queue that this job was fetched from.
22+
* @param object $payload The contents of the job that has just failed.
23+
* @param \Exception $exception The exception generated when the job failed to run.
24+
* @param \Resque_Worker $worker Instance of Resque_Worker that was running this job when it failed.
25+
* @param string $queue The name of the queue that this job was fetched from.
2626
*/
2727
public static function create($payload, Exception $exception, Resque_Worker $worker, $queue)
2828
{

lib/Resque/Job.php

100644100755
+8-1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public function __construct($queue, $payload)
5252
* @param string $class The name of the class that contains the code to execute the job.
5353
* @param array $args Any optional arguments that should be passed when the job is executed.
5454
* @param boolean $monitor Set to true to be able to monitor the status of a job.
55+
*
56+
* @return string
5557
*/
5658
public static function create($queue, $class, $args = null, $monitor = false)
5759
{
@@ -154,16 +156,18 @@ public function getInstance()
154156
);
155157
}
156158

157-
$this->instance = new $this->payload['class'];
159+
$this->instance = new $this->payload['class']();
158160
$this->instance->job = $this;
159161
$this->instance->args = $this->getArguments();
162+
$this->instance->queue = $this->queue;
160163
return $this->instance;
161164
}
162165

163166
/**
164167
* Actually execute a job by calling the perform method on the class
165168
* associated with the job with the supplied arguments.
166169
*
170+
* @return bool
167171
* @throws Resque_Exception When the job's class could not be found or it does not contain a perform method.
168172
*/
169173
public function perform()
@@ -194,6 +198,8 @@ public function perform()
194198

195199
/**
196200
* Mark the current job as having failed.
201+
*
202+
* @param $exception
197203
*/
198204
public function fail($exception)
199205
{
@@ -216,6 +222,7 @@ public function fail($exception)
216222

217223
/**
218224
* Re-queue the current job.
225+
* @return string
219226
*/
220227
public function recreate()
221228
{

lib/Resque/Worker.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class Resque_Worker
6161

6262
/**
6363
* Return all workers known to Resque as instantiated instances.
64+
* @return array
6465
*/
6566
public static function all()
6667
{
@@ -192,12 +193,12 @@ public function work($interval = 5)
192193
$this->child = $this->fork();
193194

194195
// Forked and we're the child. Run the job.
195-
if($this->child === 0 || $this->child === false) {
196+
if ($this->child === 0 || $this->child === false) {
196197
$status = 'Processing ' . $job->queue . ' since ' . strftime('%F %T');
197198
$this->updateProcLine($status);
198199
$this->log($status, self::LOG_VERBOSE);
199200
$this->perform($job);
200-
if($this->child === 0) {
201+
if ($this->child === 0) {
201202
exit(0);
202203
}
203204
}
@@ -228,7 +229,7 @@ public function work($interval = 5)
228229
/**
229230
* Process a single job.
230231
*
231-
* @param object|null $job The job to be processed.
232+
* @param Resque_Job $job The job to be processed.
232233
*/
233234
public function perform(Resque_Job $job)
234235
{
@@ -582,4 +583,4 @@ public function getStat($stat)
582583
return Resque_Stat::get($stat . ':' . $this);
583584
}
584585
}
585-
?>
586+
?>

0 commit comments

Comments
 (0)