Skip to content

Commit f26c6a8

Browse files
committed
Use typed properties where possible
1 parent 081ec4d commit f26c6a8

File tree

5 files changed

+18
-72
lines changed

5 files changed

+18
-72
lines changed

src/Controllers/Api/FailedJobsController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace Dionera\BeanstalkdUI\Controllers\Api;
44

5-
use DB;
6-
use Artisan;
75
use Illuminate\Http\JsonResponse;
86
use Illuminate\Routing\Controller;
7+
use Illuminate\Support\Facades\DB;
8+
use Illuminate\Support\Facades\Artisan;
99

1010
class FailedJobsController extends Controller
1111
{

src/Controllers/Api/JobsController.php

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@
33
namespace Dionera\BeanstalkdUI\Controllers\Api;
44

55
use Pheanstalk\JobId;
6+
use Illuminate\Http\JsonResponse;
67
use Illuminate\Routing\Controller;
78
use Pheanstalk\Exception\ServerException;
89
use Pheanstalk\Contract\PheanstalkInterface;
910

1011
class JobsController extends Controller
1112
{
12-
/**
13-
* @var PheanstalkInterface
14-
*/
15-
private $pheanstalk;
13+
private PheanstalkInterface $pheanstalk;
1614

1715
/**
1816
* JobsController constructor.
@@ -24,12 +22,7 @@ public function __construct(PheanstalkInterface $pheanstalk)
2422
$this->pheanstalk = $pheanstalk;
2523
}
2624

27-
/**
28-
* @param $job
29-
*
30-
* @return \Illuminate\Http\JsonResponse
31-
*/
32-
public function delete(int $job)
25+
public function delete(int $job): JsonResponse
3326
{
3427
try {
3528
$instance = $this->pheanstalk->peek(new JobId($job));
@@ -48,12 +41,7 @@ public function delete(int $job)
4841
}
4942
}
5043

51-
/**
52-
* @param $job
53-
*
54-
* @return \Illuminate\Http\RedirectResponse
55-
*/
56-
public function kick(int $job)
44+
public function kick(int $job): JsonResponse
5745
{
5846
try {
5947
$instance = $this->pheanstalk->peek(new JobId($job));

src/Controllers/Api/StatsController.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,9 @@
99

1010
class StatsController extends Controller
1111
{
12-
/**
13-
* @var JobRepository
14-
*/
15-
private $jobs;
16-
/**
17-
* @var PheanstalkInterface
18-
*/
19-
private $pheanstalk;
12+
private JobRepository $jobs;
13+
14+
private PheanstalkInterface $pheanstalk;
2015

2116
public function __construct(PheanstalkInterface $pheanstalk, JobRepository $jobs)
2217
{

src/Models/Job.php

Lines changed: 8 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,38 @@
1-
<?php
1+
<?php declare(strict_types=1);
22

33
namespace Dionera\BeanstalkdUI\Models;
44

55
use Illuminate\Support\Arr;
66
use Pheanstalk\Job as PheanstalkJob;
77
use Illuminate\Contracts\Support\Jsonable;
8+
use Pheanstalk\Contract\ResponseInterface;
89

910
class Job implements Jsonable
1011
{
11-
/**
12-
* @var PheanstalkJob
13-
*/
14-
private $job;
12+
private PheanstalkJob $job;
13+
private ?ResponseInterface $stats;
1514

16-
/**
17-
* @var object
18-
*/
19-
private $stats;
20-
21-
/**
22-
* Job constructor.
23-
*
24-
* @param PheanstalkJob $job
25-
* @param object $stats
26-
*/
27-
public function __construct(PheanstalkJob $job, $stats = null)
15+
public function __construct(PheanstalkJob $job, ?ResponseInterface $stats = null)
2816
{
2917
$this->job = $job;
3018
$this->stats = $stats;
3119
}
3220

33-
/**
34-
* Returns the underlying job's id.
35-
*
36-
* @return int
37-
*/
38-
public function getId()
21+
public function getId(): int
3922
{
4023
return $this->job->getId();
4124
}
4225

43-
/**
44-
* Returns the underlying job's data.
45-
*
46-
* @return string
47-
*/
48-
public function getData()
26+
public function getData(): string
4927
{
5028
return $this->job->getData();
5129
}
5230

53-
/**
54-
* Returns a specific stat for the underlying job.
55-
*
56-
* @param string $name
57-
*
58-
* @return mixed
59-
*/
60-
public function getStat($name)
31+
public function getStat(string $name)
6132
{
6233
return Arr::get($this->stats, $name);
6334
}
6435

65-
/**
66-
* Convert the object to its JSON representation.
67-
*
68-
* @param int $options
69-
*
70-
* @return string
71-
*/
7236
public function toJson($options = 0)
7337
{
7438
return [

src/Repositories/JobRepository.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
class JobRepository
1212
{
13-
/** @var PheanstalkInterface */
14-
private $pheanstalk;
13+
private PheanstalkInterface $pheanstalk;
1514

1615
public function __construct(PheanstalkInterface $pheanstalk)
1716
{

0 commit comments

Comments
 (0)