diff --git a/psalm.xml b/psalm.xml index 510148d..feccc34 100644 --- a/psalm.xml +++ b/psalm.xml @@ -14,4 +14,7 @@ + + + diff --git a/src/Crontab.php b/src/Crontab.php index d04acc4..7fd5901 100644 --- a/src/Crontab.php +++ b/src/Crontab.php @@ -41,6 +41,7 @@ private function __construct(Command $command, Job ...$jobs) /** * @return Attempt */ + #[\NoDiscard] public function __invoke(Server $server): Attempt { $installOn = Script::of($this->command); @@ -52,6 +53,7 @@ public function __invoke(Server $server): Attempt * @no-named-arguments * @psalm-pure */ + #[\NoDiscard] public static function forConnectedUser(Job ...$jobs): self { return new self(Command::foreground('crontab'), ...$jobs); @@ -63,6 +65,7 @@ public static function forConnectedUser(Job ...$jobs): self * * @param non-empty-string $user */ + #[\NoDiscard] public static function forUser(string $user, Job ...$jobs): self { return new self( diff --git a/src/Job.php b/src/Job.php index 8f3781e..bb7be70 100644 --- a/src/Job.php +++ b/src/Job.php @@ -32,6 +32,7 @@ public function __construct(Schedule $schedule, Command $command) * * @throws \DomainException */ + #[\NoDiscard] public static function of(string $value): self { return self::attempt($value)->unwrap(); @@ -42,6 +43,7 @@ public static function of(string $value): self * * @return Maybe */ + #[\NoDiscard] public static function maybe(string $value): Maybe { return self::attempt($value)->maybe(); @@ -52,6 +54,7 @@ public static function maybe(string $value): Maybe * * @return Attempt */ + #[\NoDiscard] public static function attempt(string $value): Attempt { $parts = Str::of($value) @@ -78,6 +81,7 @@ public static function attempt(string $value): Attempt ))); } + #[\NoDiscard] public function toString(): string { $command = $this->command->environment()->reduce( diff --git a/src/Job/Schedule.php b/src/Job/Schedule.php index 8a43ae3..51fbf2a 100644 --- a/src/Job/Schedule.php +++ b/src/Job/Schedule.php @@ -47,6 +47,7 @@ public function __construct( * * @throws \DomainException */ + #[\NoDiscard] public static function of(string $value): self { return self::maybe($value)->match( @@ -60,6 +61,7 @@ public static function of(string $value): self * * @return Maybe */ + #[\NoDiscard] public static function maybe(string $value): Maybe { $parts = Str::of($value)->split(' '); @@ -104,6 +106,7 @@ public static function maybe(string $value): Maybe /** * @psalm-pure */ + #[\NoDiscard] public static function everyMinute(): self { return new self( @@ -120,6 +123,7 @@ public static function everyMinute(): self * * @param int<0, 59> $minute */ + #[\NoDiscard] public static function everyHourAt(int $minute): self { return new self( @@ -137,6 +141,7 @@ public static function everyHourAt(int $minute): self * @param int<0, 23> $hour * @param int<0, 59> $minute */ + #[\NoDiscard] public static function everyDayAt(int $hour, int $minute): self { return new self( @@ -154,6 +159,7 @@ public static function everyDayAt(int $hour, int $minute): self * @param int<0, 23> $hour * @param int<0, 59> $minute */ + #[\NoDiscard] public static function everyMondayAt(int $hour, int $minute): self { return new self( @@ -171,6 +177,7 @@ public static function everyMondayAt(int $hour, int $minute): self * @param int<0, 23> $hour * @param int<0, 59> $minute */ + #[\NoDiscard] public static function everyTuesdayAt(int $hour, int $minute): self { return new self( @@ -188,6 +195,7 @@ public static function everyTuesdayAt(int $hour, int $minute): self * @param int<0, 23> $hour * @param int<0, 59> $minute */ + #[\NoDiscard] public static function everyWednesdayAt(int $hour, int $minute): self { return new self( @@ -205,6 +213,7 @@ public static function everyWednesdayAt(int $hour, int $minute): self * @param int<0, 23> $hour * @param int<0, 59> $minute */ + #[\NoDiscard] public static function everyThursdayAt(int $hour, int $minute): self { return new self( @@ -222,6 +231,7 @@ public static function everyThursdayAt(int $hour, int $minute): self * @param int<0, 23> $hour * @param int<0, 59> $minute */ + #[\NoDiscard] public static function everyFridayAt(int $hour, int $minute): self { return new self( @@ -239,6 +249,7 @@ public static function everyFridayAt(int $hour, int $minute): self * @param int<0, 23> $hour * @param int<0, 59> $minute */ + #[\NoDiscard] public static function everySaturdayAt(int $hour, int $minute): self { return new self( @@ -256,6 +267,7 @@ public static function everySaturdayAt(int $hour, int $minute): self * @param int<0, 23> $hour * @param int<0, 59> $minute */ + #[\NoDiscard] public static function everySundayAt(int $hour, int $minute): self { return new self( @@ -267,6 +279,7 @@ public static function everySundayAt(int $hour, int $minute): self ); } + #[\NoDiscard] public function toString(): string { return \sprintf( diff --git a/src/Job/Schedule/DaysOfMonth.php b/src/Job/Schedule/DaysOfMonth.php index 23f1e6c..455e588 100644 --- a/src/Job/Schedule/DaysOfMonth.php +++ b/src/Job/Schedule/DaysOfMonth.php @@ -24,6 +24,7 @@ private function __construct(string $value) * * @throws \DomainException */ + #[\NoDiscard] public static function of(string $value): self { return self::maybe($value)->match( @@ -37,6 +38,7 @@ public static function of(string $value): self * * @return Maybe */ + #[\NoDiscard] public static function maybe(string $value): Maybe { return Maybe::just($value) @@ -47,6 +49,7 @@ public static function maybe(string $value): Maybe /** * @psalm-pure */ + #[\NoDiscard] public static function each(): self { return new self('*'); @@ -57,11 +60,13 @@ public static function each(): self * * @param int<1, 31> $day */ + #[\NoDiscard] public static function at(int $day): self { return new self((string) $day); } + #[\NoDiscard] public function toString(): string { return $this->value; diff --git a/src/Job/Schedule/DaysOfWeek.php b/src/Job/Schedule/DaysOfWeek.php index 0361dbf..337062c 100644 --- a/src/Job/Schedule/DaysOfWeek.php +++ b/src/Job/Schedule/DaysOfWeek.php @@ -24,6 +24,7 @@ private function __construct(string $value) * * @throws \DomainException */ + #[\NoDiscard] public static function of(string $value): self { return self::maybe($value)->match( @@ -37,6 +38,7 @@ public static function of(string $value): self * * @return Maybe */ + #[\NoDiscard] public static function maybe(string $value): Maybe { return Maybe::just($value) @@ -47,6 +49,7 @@ public static function maybe(string $value): Maybe /** * @psalm-pure */ + #[\NoDiscard] public static function each(): self { return new self('*'); @@ -57,11 +60,13 @@ public static function each(): self * * @param int<0, 6> $day */ + #[\NoDiscard] public static function at(int $day): self { return new self((string) $day); } + #[\NoDiscard] public function toString(): string { return $this->value; diff --git a/src/Job/Schedule/Hours.php b/src/Job/Schedule/Hours.php index d8d5ca8..3b12a32 100644 --- a/src/Job/Schedule/Hours.php +++ b/src/Job/Schedule/Hours.php @@ -24,6 +24,7 @@ private function __construct(string $value) * * @throws \DomainException */ + #[\NoDiscard] public static function of(string $value): self { return self::maybe($value)->match( @@ -37,6 +38,7 @@ public static function of(string $value): self * * @return Maybe */ + #[\NoDiscard] public static function maybe(string $value): Maybe { return Maybe::just($value) @@ -47,6 +49,7 @@ public static function maybe(string $value): Maybe /** * @psalm-pure */ + #[\NoDiscard] public static function each(): self { return new self('*'); @@ -57,11 +60,13 @@ public static function each(): self * * @param int<0, 23> $hour */ + #[\NoDiscard] public static function at(int $hour): self { return new self((string) $hour); } + #[\NoDiscard] public function toString(): string { return $this->value; diff --git a/src/Job/Schedule/Minutes.php b/src/Job/Schedule/Minutes.php index e504485..b4da411 100644 --- a/src/Job/Schedule/Minutes.php +++ b/src/Job/Schedule/Minutes.php @@ -24,6 +24,7 @@ private function __construct(string $value) * * @throws \DomainException */ + #[\NoDiscard] public static function of(string $value): self { return self::maybe($value)->match( @@ -37,6 +38,7 @@ public static function of(string $value): self * * @return Maybe */ + #[\NoDiscard] public static function maybe(string $value): Maybe { return Maybe::just($value) @@ -47,6 +49,7 @@ public static function maybe(string $value): Maybe /** * @psalm-pure */ + #[\NoDiscard] public static function each(): self { return new self('*'); @@ -57,11 +60,13 @@ public static function each(): self * * @param int<0, 59> $minute */ + #[\NoDiscard] public static function at(int $minute): self { return new self((string) $minute); } + #[\NoDiscard] public function toString(): string { return $this->value; diff --git a/src/Job/Schedule/Months.php b/src/Job/Schedule/Months.php index 5976024..9c527d9 100644 --- a/src/Job/Schedule/Months.php +++ b/src/Job/Schedule/Months.php @@ -24,6 +24,7 @@ private function __construct(string $value) * * @throws \DomainException */ + #[\NoDiscard] public static function of(string $value): self { return self::maybe($value)->match( @@ -37,6 +38,7 @@ public static function of(string $value): self * * @return Maybe */ + #[\NoDiscard] public static function maybe(string $value): Maybe { return Maybe::just($value) @@ -47,6 +49,7 @@ public static function maybe(string $value): Maybe /** * @psalm-pure */ + #[\NoDiscard] public static function each(): self { return new self('*'); @@ -57,11 +60,13 @@ public static function each(): self * * @param int<1, 12> $month */ + #[\NoDiscard] public static function at(int $month): self { return new self((string) $month); } + #[\NoDiscard] public function toString(): string { return $this->value; diff --git a/src/Job/Schedule/Range.php b/src/Job/Schedule/Range.php index 72e34ca..8e147f7 100644 --- a/src/Job/Schedule/Range.php +++ b/src/Job/Schedule/Range.php @@ -18,6 +18,7 @@ public function __construct(string $pattern) $this->pattern = $pattern; } + #[\NoDiscard] public function __invoke(string $value): bool { if ($value === '*') { diff --git a/src/Read.php b/src/Read.php index de25d8d..4ba0a13 100644 --- a/src/Read.php +++ b/src/Read.php @@ -26,6 +26,7 @@ private function __construct(Command $command) /** * @return Attempt> */ + #[\NoDiscard] public function __invoke(Server $server): Attempt { return $server @@ -59,6 +60,7 @@ public function __invoke(Server $server): Attempt ); } + #[\NoDiscard] public static function forConnectedUser(): self { return new self( @@ -70,6 +72,7 @@ public static function forConnectedUser(): self /** * @param non-empty-string $user */ + #[\NoDiscard] public static function forUser(string $user): self { return new self(