From 585739d8cbf75d23615eb4ec436b67755b54fe45 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Sun, 15 Feb 2026 16:35:19 +0100 Subject: [PATCH 1/2] use promoted properties --- src/Job.php | 11 ++++------- src/Job/Schedule.php | 21 +++++---------------- src/Job/Schedule/DaysOfMonth.php | 5 +---- src/Job/Schedule/DaysOfWeek.php | 5 +---- src/Job/Schedule/Hours.php | 5 +---- src/Job/Schedule/Minutes.php | 5 +---- src/Job/Schedule/Months.php | 5 +---- src/Job/Schedule/Range.php | 5 +---- src/Read.php | 5 +---- 9 files changed, 16 insertions(+), 51 deletions(-) diff --git a/src/Job.php b/src/Job.php index bb7be70..d6e4779 100644 --- a/src/Job.php +++ b/src/Job.php @@ -16,13 +16,10 @@ */ final class Job { - private Schedule $schedule; - private Command $command; - - public function __construct(Schedule $schedule, Command $command) - { - $this->schedule = $schedule; - $this->command = $command; + public function __construct( + private Schedule $schedule, + private Command $command, + ) { } /** diff --git a/src/Job/Schedule.php b/src/Job/Schedule.php index 51fbf2a..3446ebd 100644 --- a/src/Job/Schedule.php +++ b/src/Job/Schedule.php @@ -20,24 +20,13 @@ */ final class Schedule { - private Minutes $minutes; - private Hours $hours; - private DaysOfMonth $daysOfMonth; - private Months $months; - private DaysOfWeek $daysOfWeek; - public function __construct( - Minutes $minutes, - Hours $hours, - DaysOfMonth $daysOfMonth, - Months $months, - DaysOfWeek $daysOfWeek, + private Minutes $minutes, + private Hours $hours, + private DaysOfMonth $daysOfMonth, + private Months $months, + private DaysOfWeek $daysOfWeek, ) { - $this->minutes = $minutes; - $this->hours = $hours; - $this->daysOfMonth = $daysOfMonth; - $this->months = $months; - $this->daysOfWeek = $daysOfWeek; } /** diff --git a/src/Job/Schedule/DaysOfMonth.php b/src/Job/Schedule/DaysOfMonth.php index 455e588..8d68628 100644 --- a/src/Job/Schedule/DaysOfMonth.php +++ b/src/Job/Schedule/DaysOfMonth.php @@ -10,11 +10,8 @@ */ final class DaysOfMonth { - private string $value; - - private function __construct(string $value) + private function __construct(private string $value) { - $this->value = $value; } /** diff --git a/src/Job/Schedule/DaysOfWeek.php b/src/Job/Schedule/DaysOfWeek.php index 337062c..349eb65 100644 --- a/src/Job/Schedule/DaysOfWeek.php +++ b/src/Job/Schedule/DaysOfWeek.php @@ -10,11 +10,8 @@ */ final class DaysOfWeek { - private string $value; - - private function __construct(string $value) + private function __construct(private string $value) { - $this->value = $value; } /** diff --git a/src/Job/Schedule/Hours.php b/src/Job/Schedule/Hours.php index 3b12a32..913c41f 100644 --- a/src/Job/Schedule/Hours.php +++ b/src/Job/Schedule/Hours.php @@ -10,11 +10,8 @@ */ final class Hours { - private string $value; - - private function __construct(string $value) + private function __construct(private string $value) { - $this->value = $value; } /** diff --git a/src/Job/Schedule/Minutes.php b/src/Job/Schedule/Minutes.php index b4da411..e2fe093 100644 --- a/src/Job/Schedule/Minutes.php +++ b/src/Job/Schedule/Minutes.php @@ -10,11 +10,8 @@ */ final class Minutes { - private string $value; - - private function __construct(string $value) + private function __construct(private string $value) { - $this->value = $value; } /** diff --git a/src/Job/Schedule/Months.php b/src/Job/Schedule/Months.php index 9c527d9..885e29e 100644 --- a/src/Job/Schedule/Months.php +++ b/src/Job/Schedule/Months.php @@ -10,11 +10,8 @@ */ final class Months { - private string $value; - - private function __construct(string $value) + private function __construct(private string $value) { - $this->value = $value; } /** diff --git a/src/Job/Schedule/Range.php b/src/Job/Schedule/Range.php index 8e147f7..8c9b200 100644 --- a/src/Job/Schedule/Range.php +++ b/src/Job/Schedule/Range.php @@ -11,11 +11,8 @@ */ final class Range { - private string $pattern; - - public function __construct(string $pattern) + public function __construct(private string $pattern) { - $this->pattern = $pattern; } #[\NoDiscard] diff --git a/src/Read.php b/src/Read.php index 4ba0a13..23fb528 100644 --- a/src/Read.php +++ b/src/Read.php @@ -16,11 +16,8 @@ final class Read { - private Command $command; - - private function __construct(Command $command) + private function __construct(private Command $command) { - $this->command = $command; } /** From 679dfd769d60ac113492ed08fafe88d43f4e8f0f Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Sun, 15 Feb 2026 16:36:17 +0100 Subject: [PATCH 2/2] remove dead code --- src/Read.php | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/Read.php b/src/Read.php index 23fb528..0d72422 100644 --- a/src/Read.php +++ b/src/Read.php @@ -10,7 +10,6 @@ use Innmind\Immutable\{ Sequence, Attempt, - Maybe, Monoid\Concat, }; @@ -44,17 +43,6 @@ public function __invoke(Server $server): Attempt ->map(static fn($line) => Job::attempt($line->toString())), ) ->flatMap(self::parse(...)); - - /** - * @psalm-suppress NamedArgumentNotAllowed - * @var Maybe> - */ - return $jobs->match( - static fn($first, $jobs) => Maybe::all($first, ...$jobs->toList())->map( - static fn(Job ...$jobs) => Sequence::of(...$jobs), - ), - static fn() => Maybe::just(Sequence::of()), - ); } #[\NoDiscard]