88use Resque \Exceptions \DoNotPerformException ;
99use Resque \Job \FactoryInterface ;
1010use Resque \Job \Factory ;
11+ use Resque \Job \Job ;
1112use Error ;
1213
1314/**
@@ -50,7 +51,7 @@ class JobHandler
5051 public $ endTime ;
5152
5253 /**
53- * @var object|\Resque\ Job\JobInterface Instance of the class performing work for this job.
54+ * @var Job Instance of the class performing work for this job.
5455 */
5556 private $ instance ;
5657
@@ -194,10 +195,10 @@ public function getArguments()
194195
195196 /**
196197 * Get the instantiated object for this job that will be performing work.
197- * @return \Resque\Job\JobInterface Instance of the object that this job belongs to.
198+ * @return \Resque\Job\Job Instance of the object that this job belongs to.
198199 * @throws \Resque\Exceptions\ResqueException
199200 */
200- public function getInstance ()
201+ public function getInstance (): Job
201202 {
202203 if (!is_null ($ this ->instance )) {
203204 return $ this ->instance ;
@@ -212,9 +213,8 @@ public function getInstance()
212213 * Actually execute a job by calling the perform method on the class
213214 * associated with the job with the supplied arguments.
214215 *
215- * @return bool
216- * @throws Resque\Exceptions\ResqueException When the job's class could not be found
217- * or it does not contain a perform method.
216+ * @return mixed
217+ * @throws Resque\Exceptions\ResqueException When the job's class could not be found.
218218 */
219219 public function perform ()
220220 {
@@ -225,15 +225,12 @@ public function perform()
225225 $ this ->startTime = microtime (true );
226226
227227 $ instance = $ this ->getInstance ();
228- if (is_callable ([$ instance , 'setUp ' ])) {
229- $ instance ->setUp ();
230- }
228+
229+ $ instance ->setUp ();
231230
232231 $ result = $ instance ->perform ();
233232
234- if (is_callable ([$ instance , 'tearDown ' ])) {
235- $ instance ->tearDown ();
236- }
233+ $ instance ->tearDown ();
237234
238235 $ this ->endTime = microtime (true );
239236
@@ -343,7 +340,7 @@ public function setJobFactory(FactoryInterface $jobFactory)
343340 /**
344341 * @return Resque\Job\FactoryInterface
345342 */
346- public function getJobFactory ()
343+ public function getJobFactory (): FactoryInterface
347344 {
348345 if ($ this ->jobFactory === null ) {
349346 $ this ->jobFactory = new Factory ();
0 commit comments