Skip to content

Commit 76fa4db

Browse files
authored
[CHANGE] Updated dependency requirements (#48)
* [CHANGE] Updated dependency requirements
1 parent d971436 commit 76fa4db

11 files changed

Lines changed: 49 additions & 114 deletions

File tree

.github/workflows/phpcs.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ jobs:
99
name: PHPCS
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v2
13-
- name: PHPCS check
14-
uses: chekalsky/phpcs-action@v1
12+
- uses: actions/checkout@v4
13+
- name: Setup PHP
14+
uses: shivammathur/setup-php@v2
15+
with:
16+
php-version: '8.2'
17+
tools: cs2pr, phpcs
18+
- name: Run phpcs
19+
run: phpcs -q --report=checkstyle . | cs2pr

.github/workflows/tests.yml

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,27 @@ jobs:
1515
strategy:
1616
matrix:
1717
php-version:
18-
- "7.2"
19-
- "7.3"
2018
- "7.4"
21-
- "8.0"
2219
- "8.1"
20+
- "8.2"
21+
- "8.3"
2322
symfony-version:
24-
- "3.4.x"
25-
- "4.4.x"
26-
- "5.3.x"
2723
- "5.4.x"
24+
- "6.4.x"
25+
- "7.0.x"
2826
monolog-version:
29-
- "^1.25"
30-
- "^2.2"
31-
include:
32-
- php-version: "8.0"
33-
symfony-version: "6.0.x"
34-
monolog-version: "^1.25"
35-
- php-version: "8.1"
36-
symfony-version: "6.0.x"
37-
monolog-version: "^1.25"
38-
- php-version: "8.0"
39-
symfony-version: "6.0.x"
40-
monolog-version: "^2.2"
41-
- php-version: "8.1"
42-
symfony-version: "6.0.x"
43-
monolog-version: "^2.2"
27+
- "^2.9"
28+
exclude:
29+
- php-version: "7.4"
30+
symfony-version: "6.4.x"
31+
- php-version: "7.4"
32+
symfony-version: "7.0.x"
33+
- php-version: "8.1"
34+
symfony-version: "7.0.x"
4435

4536
steps:
4637
- name: "Checkout"
47-
uses: "actions/checkout@v2"
38+
uses: "actions/checkout@v4"
4839
with:
4940
fetch-depth: 2
5041

@@ -58,7 +49,7 @@ jobs:
5849
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
5950

6051
- name: Cache composer dependencies
61-
uses: actions/cache@v2
52+
uses: actions/cache@v3
6253
with:
6354
path: ${{ steps.composer-cache.outputs.dir }}
6455
# Use composer.json for key, if composer.lock is not committed.

Command/ListCommand.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ class ListCommand extends Command
1717
{
1818
private const NUMBER_OF_RUN_DATES = 3;
1919

20-
/**
21-
* @var Scheduler
22-
*/
23-
private $scheduler;
20+
private Scheduler $scheduler;
2421

2522
public function __construct(Scheduler $scheduler)
2623
{
@@ -70,6 +67,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7067

7168
$table->render();
7269

73-
return 0;
70+
return self::SUCCESS;
7471
}
7572
}

Command/RunCommand.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Rewieer\TaskSchedulerBundle\Command;
99

10+
use Exception;
1011
use Rewieer\TaskSchedulerBundle\Task\Scheduler;
1112
use Symfony\Component\Console\Command\Command;
1213
use Symfony\Component\Console\Input\InputArgument;
@@ -16,10 +17,7 @@
1617

1718
class RunCommand extends Command
1819
{
19-
/**
20-
* @var Scheduler
21-
*/
22-
private $scheduler;
20+
private Scheduler $scheduler;
2321

2422
public function __construct(Scheduler $scheduler)
2523
{
@@ -32,7 +30,11 @@ protected function configure(): void
3230
$this
3331
->setName("ts:run")
3432
->setDescription("Run due tasks")
35-
->setHelp("This command actually run the tasks that are due at the moment the command is called.\nThis command should not be called manually. Check the documentation to learn how to set CRON jobs.")
33+
->setHelp(<<<'EOF'
34+
This command actually run the tasks that are due at the moment the command is called.
35+
This command should not be called manually. Check the documentation to learn how to set CRON jobs.
36+
EOF
37+
)
3638
->addArgument("id", InputArgument::OPTIONAL, "The ID of the task. Check ts:list for IDs")
3739
->addOption("class", "c", InputOption::VALUE_OPTIONAL, "the class name of the task (without namespace)");
3840
}
@@ -42,29 +44,28 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4244
$id = $input->getArgument("id");
4345
$class = $input->getOption("class");
4446

45-
4647
if (!$id && !$class) {
4748
$this->scheduler->run();
4849
} elseif ($class) {
4950
$tasks = $this->scheduler->getTasks();
5051
foreach ($tasks as $task) {
5152
if (strpos(get_class($task), "\\$class")) {
5253
$this->scheduler->runTask($task);
53-
return 0;
54+
return self::SUCCESS;
5455
}
5556
}
56-
throw new \Exception("There are no tasks corresponding to this class name");
57+
throw new Exception("There are no tasks corresponding to this class name");
5758
} else {
5859
$tasks = $this->scheduler->getTasks();
5960
$id = (int)$id;
6061

6162
if (array_key_exists($id - 1, $tasks) === false) {
62-
throw new \Exception("There are no tasks corresponding to this ID");
63+
throw new Exception("There are no tasks corresponding to this ID");
6364
}
6465

6566
$this->scheduler->runTask($tasks[$id - 1]);
6667
}
6768

68-
return 0;
69+
return self::SUCCESS;
6970
}
7071
}

DependencyInjection/Configuration.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@ class Configuration implements ConfigurationInterface
2020
{
2121
public function getConfigTreeBuilder(): TreeBuilder
2222
{
23-
$treeBuilder = new TreeBuilder('rewieer_task_scheduler');
24-
25-
if (false === \method_exists($treeBuilder, 'getRootNode')) {
26-
// BC layer for symfony/config 4.1 and older
27-
$treeBuilder->root('rewieer_task_scheduler');
28-
}
29-
30-
return $treeBuilder;
23+
return new TreeBuilder('rewieer_task_scheduler');
3124
}
3225
}

Services/SchedulerLogger.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
*/
2222
class SchedulerLogger implements EventSubscriberInterface
2323
{
24-
private $logger;
25-
private $start;
26-
private $current;
24+
private LoggerInterface $logger;
25+
private ?float $start;
26+
private ?float $current;
2727

2828
public function __construct(LoggerInterface $logger)
2929
{

Task/AbstractScheduledTask.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@
1212

1313
abstract class AbstractScheduledTask implements TaskInterface
1414
{
15-
/**
16-
* @var Schedule
17-
*/
18-
private $schedule;
15+
private Schedule $schedule;
1916

2017
public function __construct()
2118
{
@@ -32,9 +29,6 @@ public function isDue($currentTime): bool
3229
return $this->schedule->isDue($currentTime);
3330
}
3431

35-
/**
36-
* @return Schedule
37-
*/
3832
public function getSchedule(): Schedule
3933
{
4034
return $this->schedule;

Task/Schedule.php

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@
1919
*/
2020
class Schedule
2121
{
22-
/**
23-
* @var CronExpression
24-
*/
25-
private $cron;
22+
private CronExpression $cron;
2623

2724
/**
2825
* Schedule constructor.
@@ -36,7 +33,6 @@ public function __construct(string $expr = "* * * * *")
3633
/**
3734
* Sets the cron to work at these months
3835
* @param string|int $months
39-
* @return $this
4036
*/
4137
public function months($months): self
4238
{
@@ -48,7 +44,6 @@ public function months($months): self
4844
* Sets the cron to work at these days of the week
4945
* ATTENTION: resets daysOfMonth
5046
* @param string|int $days
51-
* @return $this
5247
*/
5348
public function daysOfWeek($days): self
5449
{
@@ -61,7 +56,6 @@ public function daysOfWeek($days): self
6156
* Sets the cron to work at these days of the month
6257
* ATTENTION: resets daysOfWeek
6358
* @param string|int $days
64-
* @return $this
6559
*/
6660
public function daysOfMonth($days): self
6761
{
@@ -72,7 +66,6 @@ public function daysOfMonth($days): self
7266

7367
/**
7468
* Sets the cron to work every day
75-
* @return $this
7669
*/
7770
public function daily(): self
7871
{
@@ -83,7 +76,6 @@ public function daily(): self
8376
/**
8477
* Set the cron to work at these hours
8578
* @param string|int $hours
86-
* @return $this
8779
*/
8880
public function hours($hours): self
8981
{
@@ -94,7 +86,6 @@ public function hours($hours): self
9486
/**
9587
* Set the cron to work at these minutes
9688
* @param string|int $minutes
97-
* @return $this
9889
*/
9990
public function minutes($minutes): self
10091
{
@@ -105,7 +96,6 @@ public function minutes($minutes): self
10596
/**
10697
* Set the cron to work at every x minutes
10798
* @param int $minutes
108-
* @return $this
10999
*/
110100
public function everyMinutes(int $minutes = 1): self
111101
{
@@ -115,7 +105,6 @@ public function everyMinutes(int $minutes = 1): self
115105
/**
116106
* Set the cron to work at every x hours
117107
* @param int $hours
118-
* @return $this
119108
*/
120109
public function everyHours(int $hours = 1): self
121110
{
@@ -125,10 +114,6 @@ public function everyHours(int $hours = 1): self
125114
/**
126115
* Generic function to update a cron part as an "everyX" pattern
127116
* such as "every 3 hours" or "every 10 minutes"
128-
*
129-
* @param int $time
130-
* @param int $part
131-
* @return $this
132117
*/
133118
public function everyX(int $time = 1, int $part = CronExpression::MINUTE): self
134119
{
@@ -142,17 +127,11 @@ public function everyX(int $time = 1, int $part = CronExpression::MINUTE): self
142127
return $this;
143128
}
144129

145-
/**
146-
* @return CronExpression
147-
*/
148130
public function getCron(): CronExpression
149131
{
150132
return $this->cron;
151133
}
152134

153-
/**
154-
* @return string
155-
*/
156135
public function getExpression(): string
157136
{
158137
return $this->cron->getExpression();
@@ -161,20 +140,13 @@ public function getExpression(): string
161140
/**
162141
* Allows setting entire expression in string format like "0 * 2,7,12 * 7"
163142
* Exposes CronExpressions method directly
164-
* @param string $value
165-
* @return $this
166143
*/
167144
public function setExpression(string $value): self
168145
{
169146
$this->cron->setExpression($value);
170147
return $this;
171148
}
172149

173-
/**
174-
* @param int $position
175-
* @param string $value
176-
* @return $this
177-
*/
178150
public function setPart(int $position, string $value): self
179151
{
180152
$this->cron->setPart($position, $value);
@@ -184,7 +156,6 @@ public function setPart(int $position, string $value): self
184156
/**
185157
* Return true if the schedule is due to now
186158
* @param DateTimeInterface|string $currentTime
187-
* @return bool
188159
*/
189160
public function isDue($currentTime = 'now'): bool
190161
{

Task/Scheduler.php

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@
1313

1414
class Scheduler
1515
{
16-
/**
17-
* @var EventDispatcher
18-
*/
19-
private $dispatcher;
16+
private EventDispatcher $dispatcher;
2017

2118
public function __construct(EventDispatcher $dispatcher = null)
2219
{
@@ -32,19 +29,11 @@ public function __construct(EventDispatcher $dispatcher = null)
3229
*/
3330
private $tasks = [];
3431

35-
/**
36-
* Adds the task to the task stack
37-
* @param TaskInterface $task
38-
*/
3932
public function addTask(TaskInterface $task): void
4033
{
4134
$this->tasks[] = $task;
4235
}
4336

44-
/**
45-
* Run due tasks
46-
* @param DateTimeInterface|string $currentTime
47-
*/
4837
public function run($currentTime = "now"): void
4938
{
5039
$this->dispatcher->dispatch(SchedulerEvents::ON_START);
@@ -60,10 +49,6 @@ public function run($currentTime = "now"): void
6049
$this->dispatcher->dispatch(SchedulerEvents::ON_END);
6150
}
6251

63-
/**
64-
* Run the task
65-
* @param TaskInterface $task
66-
*/
6752
public function runTask(TaskInterface $task): void
6853
{
6954
$this->dispatcher->dispatch(SchedulerEvents::BEFORE_TASK_RUNS, [$task]);

0 commit comments

Comments
 (0)