Skip to content

Commit bcd653a

Browse files
committed
feature: apply rector
1 parent ca224f7 commit bcd653a

5 files changed

Lines changed: 12 additions & 22 deletions

File tree

src/Commands/CrontabTaskListCommand.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
3333

3434
$table = new Table($output);
3535
$table->setHeaders(array_keys($data[0]));
36-
$table->setRows(array_map(function (array $item) {
37-
return array_map(function ($value) {
38-
return is_array($value) ? json_encode($value) : $value;
39-
}, $item);
40-
}, $data));
36+
$table->setRows(array_map(fn(array $item) => array_map(fn($value) => is_array($value) ? json_encode($value) : $value, $item), $data));
4137
$table->render();
4238

4339
return self::SUCCESS;

src/Components/TaskViewer.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@
77

88
final class TaskViewer
99
{
10-
private array $processes;
1110
private array $config = [
1211
'with_next_due' => true,
1312
'next_due_limit' => 3,
1413
];
1514

16-
public function __construct(array $processes = [], array $config = [])
15+
public function __construct(private readonly array $processes = [], array $config = [])
1716
{
18-
$this->processes = $processes;
1917
$this->config = array_merge($this->config, $config);
2018
}
2119

src/Exceptions/TaskException.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@
77

88
class TaskException extends Exception implements TaskExceptionInterface
99
{
10-
protected array $data = [];
11-
12-
public function __construct(string $message = "Task Error", array $data = [], int $code = 0, ?Throwable $previous = null)
10+
public function __construct(string $message = "Task Error", protected array $data = [], int $code = 0, ?Throwable $previous = null)
1311
{
1412
parent::__construct($message, $code, $previous);
15-
$this->data = $data;
1613
}
1714

1815
public function getData(): array

src/TaskProcess.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@
66
use Workerman\Crontab\Crontab;
77
use Workerman\Crontab\Parser;
88

9-
final class TaskProcess
9+
final readonly class TaskProcess
1010
{
11-
/**
12-
* @var array [[$cron, $task]]
13-
*/
14-
private array $tasks;
15-
16-
public function __construct(array $tasks)
11+
public function __construct(
12+
/**
13+
* @var array [[$cron, $task]]
14+
*/
15+
private array $tasks
16+
)
1717
{
18-
$this->tasks = $tasks;
1918
}
2019

2120
/**
@@ -48,7 +47,7 @@ public function onWorkerStart(): void
4847
{
4948
foreach ($this->tasks as [$cron, $task]) {
5049
/** @var BaseTask $task */
51-
new Crontab($cron, [$task, 'taskExec']);
50+
new Crontab($cron, $task->taskExec(...));
5251
}
5352
}
5453
}

src/Traits/LogTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected function log(string $msg, ?string $type = null)
5454
}
5555
}
5656

57-
$type = $type ?? $this->logType ?? 'info';
57+
$type ??= $this->logType ?? 'info';
5858
if ($this->logClass) {
5959
$msg = static::class . ':' . $msg;
6060
}

0 commit comments

Comments
 (0)