From 6bd54926dfe1e46e17966d83a9338e31382be04d Mon Sep 17 00:00:00 2001 From: Dimitri Sitchet Tomkeu Date: Wed, 14 Oct 2026 20:39:53 +0100 Subject: [PATCH 1/3] patch: promotion de l'attribut `name` en propriete --- src/Task.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Task.php b/src/Task.php index 0286d9e..c516e3b 100644 --- a/src/Task.php +++ b/src/Task.php @@ -57,6 +57,11 @@ class Task */ protected array $environments = []; + /** + * L'alias sous lesquel cette tâche peut être exécutée + */ + protected string $name; + /** * Faut-il empêcher les exécutions simultanées de cette tâche ? */ @@ -102,7 +107,7 @@ public function __construct(protected string $type, protected mixed $action, pro */ public function named(string $name): self { - $this->attributes['name'] = $name; + $this->name = $name; return $this; } @@ -343,7 +348,7 @@ protected function buildName(): string */ public function __get(string $key) { - if ($key === 'name' && empty($this->attributes['name'])) { + if ($key === 'name' && (! isset($this->name) || ($this->name === ''))) { return $this->buildName(); } @@ -359,7 +364,11 @@ public function __get(string $key) */ public function __set(string $name, mixed $value): void { - $this->attributes[$name] = $value; + if ($name === 'name' && (! isset($this->name) || ($this->name === ''))) { + $this->name = $value; + } else { + $this->attributes[$name] = $value; + } } /** @@ -369,7 +378,7 @@ public function __set(string $name, mixed $value): void */ private function getLockKey(): string { - $name = $this->attributes['name'] ?? $this->buildName(); + $name = $this->name ?? $this->buildName(); return 'task_lock_' . $name; } From d3a2d20bc5413072fd01f4ddc73eabb6497b88b9 Mon Sep 17 00:00:00 2001 From: Dimitri Sitchet Tomkeu Date: Wed, 14 Oct 2026 20:41:58 +0100 Subject: [PATCH 2/3] patch: correction de bugs minimes --- src/Commands/Lister.php | 2 -- src/Commands/Run.php | 2 ++ src/HooksTrait.php | 4 ++-- src/RunResolver.php | 29 ++++++++--------------------- src/TaskRunner.php | 4 ++-- 5 files changed, 14 insertions(+), 27 deletions(-) diff --git a/src/Commands/Lister.php b/src/Commands/Lister.php index f86b23b..98820ed 100644 --- a/src/Commands/Lister.php +++ b/src/Commands/Lister.php @@ -39,8 +39,6 @@ class Lister extends TaskCommand */ public function execute(array $params) { - helper('preference'); - if (parametre('tasks.enabled') === false) { $this->writer->error('WARNING: L\'exécution de la tâche est actuellement désactivée.', true); $this->writer->write("Pour réactiver les tâches, exécutez\u{a0}: `tasks:enable`", true); diff --git a/src/Commands/Run.php b/src/Commands/Run.php index 6add613..0f05327 100644 --- a/src/Commands/Run.php +++ b/src/Commands/Run.php @@ -49,6 +49,8 @@ public function execute(array $params) $this->writer->error('WARNING: L\'exécution de la tâche est actuellement désactivée.', true); $this->writer->write("Pour réactiver les tâches, exécutez\u{a0}: `tasks:enable`", true); $this->newLine(); + + return EXIT_ERROR; } $this->task('Exécution de tâches...')->eol(); diff --git a/src/HooksTrait.php b/src/HooksTrait.php index 735529d..9d7294d 100644 --- a/src/HooksTrait.php +++ b/src/HooksTrait.php @@ -181,9 +181,9 @@ protected function process(ContainerInterface $container, string $method): mixed { ob_start(); - $result = $this->start($this->container, $method); + $result = $this->start($container, $method); - $result = $this->finish($this->container, $result); + $result = $this->finish($container, $result); ob_end_flush(); diff --git a/src/RunResolver.php b/src/RunResolver.php index eaf2f31..ce2b1fe 100644 --- a/src/RunResolver.php +++ b/src/RunResolver.php @@ -118,26 +118,13 @@ public function nextRun(string $expression, Date $next): Date */ protected function increment(Date $next, string $position): Date { - switch ($position) { - case 'minute': - $next = $next->addMinutes(1); - break; - - case 'hour': - $next = $next->addHours(1); - break; - - case 'monthDay': - case 'weekDay': - $next = $next->addDays(1); - break; - - case 'month': - $next = $next->addMonths(1); - break; - } - - return $next; + return match ($position) { + 'minute' => $next->addMinutes(1), + 'hour' => $next->addHours(1), + 'monthDay', 'weekDay' => $next->addDays(1), + 'month' => $next->addMonths(1), + default => $next, + }; } /** @@ -161,7 +148,7 @@ protected function isInList($value, string $list): bool { $list = explode(',', $list); - return in_array(trim($value), $list, true); + return in_array(trim((string) $value), $list, true); } /** diff --git a/src/TaskRunner.php b/src/TaskRunner.php index b5f7e04..a14e789 100644 --- a/src/TaskRunner.php +++ b/src/TaskRunner.php @@ -58,11 +58,11 @@ public function run(): void foreach ($tasks as $task) { // Si des tâches spécifiques ont été choisies, sauter l'exécution des tâches restantes. - if (! empty($this->only) && ! in_array($task->name, $this->only, true)) { + if ($this->only !== [] && ! in_array($task->name, $this->only, true)) { continue; } - if (! $task->shouldRun($this->testTime) && empty($this->only)) { + if (! $task->shouldRun($this->testTime) && $this->only === []) { continue; } From a1047199716d3b45f4025025c117736bf0d33ea6 Mon Sep 17 00:00:00 2001 From: dimtrovich <37987162+dimtrovich@users.noreply.github.com> Date: Wed, 14 Oct 2026 20:23:11 +0000 Subject: [PATCH 3/3] Fix styling --- src/RunResolver.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/RunResolver.php b/src/RunResolver.php index ce2b1fe..28a7658 100644 --- a/src/RunResolver.php +++ b/src/RunResolver.php @@ -119,11 +119,11 @@ public function nextRun(string $expression, Date $next): Date protected function increment(Date $next, string $position): Date { return match ($position) { - 'minute' => $next->addMinutes(1), - 'hour' => $next->addHours(1), + 'minute' => $next->addMinutes(1), + 'hour' => $next->addHours(1), 'monthDay', 'weekDay' => $next->addDays(1), - 'month' => $next->addMonths(1), - default => $next, + 'month' => $next->addMonths(1), + default => $next, }; }