Skip to content

Commit 4a29134

Browse files
author
quentin.schmick
committed
Updated typing
1 parent 78e833f commit 4a29134

32 files changed

+171
-140
lines changed

database/migrations/2019_09_25_103421_update_task_results_duration_type.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function down()
2828
}
2929

3030
/**
31-
* @param bool $toFloat
31+
* @param bool $toFloat
3232
*/
3333
private function migrateDurationValues(bool $toFloat = true)
3434
{

src/Console/Commands/ListSchedule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class ListSchedule extends Command
3232
/**
3333
* Create a new command instance.
3434
*
35-
* @param Schedule $schedule
35+
* @param Schedule $schedule
3636
* @return void
3737
*/
3838
public function __construct(Schedule $schedule)

src/Contracts/TaskInterface.php

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,65 +2,70 @@
22

33
namespace Studio\Totem\Contracts;
44

5+
use Illuminate\Database\Eloquent\Builder;
6+
use Illuminate\Database\Eloquent\Collection;
7+
use Studio\Totem\Task;
8+
59
interface TaskInterface
610
{
711
/**
812
* Returns Eloquent Builder.
913
*
10-
* @return \Illuminate\Database\Eloquent\Builder
14+
* @return Builder
1115
*/
12-
public function builder();
16+
public function builder(): Builder;
1317

1418
/**
1519
* Returns a task by its primary key.
1620
*
17-
* @param int|\Studio\Totem\Task $id
18-
* @return \Studio\Totem\Task
21+
* @param int|Task $id
22+
* @return Task
1923
*/
20-
public function find($id);
24+
public function find(Task|int $id): Task;
2125

2226
/**
2327
* Returns all tasks.
24-
* @return \Illuminate\Database\Eloquent\Collection
28+
* @return Collection
2529
*/
26-
public function findAll();
30+
public function findAll(): Collection;
2731

2832
/**
2933
* Returns all active tasks.
30-
* @return \Illuminate\Database\Eloquent\Collection
34+
*
35+
* @return Collection
3136
*/
32-
public function findAllActive();
37+
public function findAllActive(): Collection;
3338

3439
/**
3540
* Creates a new task with the given data.
3641
*
37-
* @param array $input
38-
* @return \Studio\Totem\Task
42+
* @param array $input
43+
* @return Task
3944
*/
4045
public function store(array $input);
4146

4247
/**
4348
* Updates the given task with the given data.
4449
*
45-
* @param array $input
46-
* @param \Studio\Totem\Task $task
47-
* @return \Studio\Totem\Task
50+
* @param array $input
51+
* @param Task $task
52+
* @return Task
4853
*/
49-
public function update(array $input, $task);
54+
public function update(array $input, Task $task): Task;
5055

5156
/**
5257
* Deletes the given task.
5358
*
54-
* @param int|\Studio\Totem\Task $id
59+
* @param int|Task $id
5560
* @return bool
5661
*/
57-
public function destroy($id);
62+
public function destroy(Task|int $id): bool;
5863

5964
/**
6065
* Executes the given task.
6166
*
62-
* @param int|\Studio\Totem\Task $id
67+
* @param int|Task $id
6368
* @return bool
6469
*/
65-
public function execute($id);
70+
public function execute(Task|int $id): bool;
6671
}

src/Events/BroadcastingEvent.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ class BroadcastingEvent extends TaskEvent implements ShouldBroadcast
1313
/**
1414
* Get the channels the event should broadcast on.
1515
*
16-
* @return \Illuminate\Broadcasting\Channel|\Illuminate\Broadcasting\Channel[]|PrivateChannel
16+
* @return PrivateChannel
1717
*/
18-
public function broadcastOn()
18+
public function broadcastOn(): PrivateChannel
1919
{
2020
return new PrivateChannel(config('totem.broadcasting.channel'));
2121
}
@@ -25,7 +25,7 @@ public function broadcastOn()
2525
*
2626
* @return bool
2727
*/
28-
public function broadcastWhen()
28+
public function broadcastWhen(): bool
2929
{
3030
return config('totem.broadcasting.enabled');
3131
}

src/Events/Creating.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Studio\Totem\Events;
44

5-
use Illuminate\Broadcasting\Channel;
65
use Illuminate\Broadcasting\InteractsWithSockets;
76
use Illuminate\Broadcasting\PrivateChannel;
87
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
@@ -16,7 +15,7 @@ class Creating implements ShouldBroadcast
1615
/**
1716
* @var array
1817
*/
19-
private $input;
18+
private array $input;
2019

2120
/**
2221
* Create a new event instance.
@@ -31,9 +30,9 @@ public function __construct(array $input)
3130
/**
3231
* Get the channels the event should broadcast on.
3332
*
34-
* @return Channel|array
33+
* @return PrivateChannel
3534
*/
36-
public function broadcastOn()
35+
public function broadcastOn(): PrivateChannel
3736
{
3837
return new PrivateChannel('channel-name');
3938
}

src/Events/Deleted.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ class Deleted extends Event
77
/**
88
* Create a new event instance.
99
*
10-
* @param array $input
11-
* @param Task $task
1210
*/
1311
public function __construct()
1412
{

src/Events/Executed.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ class Executed extends BroadcastingEvent
1111
* Executed constructor.
1212
*
1313
* @param Task $task
14-
* @param string $started
14+
* @param string|float|int $started
15+
* @param $output
1516
*/
1617
public function __construct(Task $task, $started, $output)
1718
{

src/Events/TaskEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class TaskEvent extends Event
1313
/**
1414
* @var Task
1515
*/
16-
public $task;
16+
public Task $task;
1717

1818
/**
1919
* Constructor.

src/Events/Updating.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Studio\Totem\Events;
44

5-
use Illuminate\Broadcasting\Channel;
65
use Illuminate\Broadcasting\PrivateChannel;
76
use Studio\Totem\Task;
87

@@ -11,7 +10,7 @@ class Updating extends BroadcastingEvent
1110
/**
1211
* @var array
1312
*/
14-
private $input;
13+
private array $input;
1514

1615
/**
1716
* Create a new event instance.
@@ -28,9 +27,9 @@ public function __construct(array $input, Task $task)
2827
/**
2928
* Get the channels the event should broadcast on.
3029
*
31-
* @return Channel|array
30+
* @return PrivateChannel
3231
*/
33-
public function broadcastOn()
32+
public function broadcastOn(): PrivateChannel
3433
{
3534
return new PrivateChannel('channel-name');
3635
}

src/Frequency.php

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

33
namespace Studio\Totem;
44

5+
use Illuminate\Database\Eloquent\Relations\BelongsTo;
56
use Studio\Totem\Traits\HasParameters;
67

78
class Frequency extends TotemModel
@@ -17,9 +18,9 @@ class Frequency extends TotemModel
1718
];
1819

1920
/**
20-
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
21+
* @return BelongsTo
2122
*/
22-
public function task()
23+
public function task(): BelongsTo
2324
{
2425
return $this->belongsTo(Task::class);
2526
}

src/Http/Controllers/ActiveTasksController.php

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

33
namespace Studio\Totem\Http\Controllers;
44

5+
use Illuminate\Http\JsonResponse;
56
use Illuminate\Http\Request;
67
use Studio\Totem\Contracts\TaskInterface;
78

@@ -10,7 +11,7 @@ class ActiveTasksController extends Controller
1011
/**
1112
* @var TaskInterface
1213
*/
13-
private $tasks;
14+
private TaskInterface $tasks;
1415

1516
/**
1617
* @param TaskInterface $tasks
@@ -25,10 +26,10 @@ public function __construct(TaskInterface $tasks)
2526
/**
2627
* Store a newly active task in storage.
2728
*
28-
* @param \Illuminate\Http\Request $request
29-
* @return \Illuminate\Http\Response
29+
* @param Request $request
30+
* @return JsonResponse
3031
*/
31-
public function store(Request $request)
32+
public function store(Request $request): JsonResponse
3233
{
3334
$task = $this->tasks->activate($request->all());
3435

@@ -39,9 +40,9 @@ public function store(Request $request)
3940
* Remove the specified resource from storage.
4041
*
4142
* @param int $id
42-
* @return \Illuminate\Http\Response
43+
* @return JsonResponse
4344
*/
44-
public function destroy($id)
45+
public function destroy(int $id): JsonResponse
4546
{
4647
$task = $this->tasks->deactivate($id);
4748

src/Http/Controllers/DashboardController.php

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

33
namespace Studio\Totem\Http\Controllers;
44

5+
use Illuminate\Http\RedirectResponse;
6+
57
class DashboardController extends Controller
68
{
79
/**
810
* Single page application catch-all route.
911
*
10-
* @return \Illuminate\Http\Response
12+
* @return RedirectResponse
1113
*/
12-
public function index()
14+
public function index(): RedirectResponse
1315
{
1416
return redirect()->route('totem.tasks.all');
1517
}

src/Http/Controllers/ExecuteTasksController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ class ExecuteTasksController extends Controller
1010
/**
1111
* @var TaskInterface
1212
*/
13-
private $tasks;
13+
private TaskInterface $tasks;
1414

1515
/**
1616
* @param TaskInterface $tasks
1717
*/
1818
public function __construct(TaskInterface $tasks)
1919
{
20+
parent::__construct();
21+
2022
$this->tasks = $tasks;
2123
}
2224

src/Http/Controllers/ExportTasksController.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
namespace Studio\Totem\Http\Controllers;
44

55
use Studio\Totem\Contracts\TaskInterface;
6+
use Symfony\Component\HttpFoundation\StreamedResponse;
67

78
class ExportTasksController extends Controller
89
{
910
/**
1011
* @var TaskInterface
1112
*/
12-
private $tasks;
13+
private TaskInterface $tasks;
1314

1415
/**
1516
* ExportTasksController constructor.
@@ -25,9 +26,9 @@ public function __construct(TaskInterface $tasks)
2526
/**
2627
* Export all tasks to a json file.
2728
*
28-
* @return \Symfony\Component\HttpFoundation\StreamedResponse
29+
* @return StreamedResponse
2930
*/
30-
public function index()
31+
public function index() : StreamedResponse
3132
{
3233
$headers = [
3334
'Content-Type' => 'text/json',

src/Http/Controllers/ImportTasksController.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Studio\Totem\Http\Controllers;
44

5+
use Illuminate\Contracts\Filesystem\FileNotFoundException;
56
use Studio\Totem\Contracts\TaskInterface;
67
use Studio\Totem\Http\Requests\ImportRequest;
78

@@ -10,7 +11,7 @@ class ImportTasksController extends Controller
1011
/**
1112
* @var TaskInterface
1213
*/
13-
private $tasks;
14+
private TaskInterface $tasks;
1415

1516
/**
1617
* ImportTasksController constructor.
@@ -25,8 +26,8 @@ public function __construct(TaskInterface $tasks)
2526

2627
/**
2728
* Import tasks from a json file.
28-
* @param \Studio\Totem\Http\Requests\ImportRequest $request
29-
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
29+
* @param ImportRequest $request
30+
* @throws FileNotFoundException
3031
*/
3132
public function index(ImportRequest $request)
3233
{

0 commit comments

Comments
 (0)