diff --git a/src/Cron.php b/src/Cron.php index 639957b..517a5ab 100644 --- a/src/Cron.php +++ b/src/Cron.php @@ -56,11 +56,17 @@ public function isDue(DateTimeInterface $dateTime): bool public function getNextDue(DateTimeInterface $dateTime): DateTimeInterface { if ($this->isExpired($dateTime)) { - return $this->end; + /** @var DateTimeInterface $end */ + $end = $this->end; + + return $end; } if ($dateTime < $this->start) { - return $this->start; + /** @var DateTimeInterface $start */ + $start = $this->start; + + return $start; } return $this->cron->getNextRunDate($dateTime); @@ -187,6 +193,9 @@ public static function fromJson(string $json): Frequency return $self; } + /** + * @return array + */ public function jsonSerialize(): array { $data = ['expression' => $this->getExpression()]; diff --git a/src/RRule.php b/src/RRule.php index bfad0e5..3288532 100644 --- a/src/RRule.php +++ b/src/RRule.php @@ -158,7 +158,10 @@ public function isDue(DateTimeInterface $dateTime): bool public function getNextDue(DateTimeInterface $dateTime): DateTimeInterface { if ($this->isExpired($dateTime)) { - return $this->getEnd(); + /** @var DateTimeInterface $end */ + $end = $this->getEnd(); + + return $end; } $nextDue = $this->getNextRecurrences($dateTime, 1, false); @@ -194,7 +197,9 @@ public function startAt(DateTimeInterface $start): self // the transformer operates only up to seconds level. See also the upstream issue #155 $startDate->setTime($start->format('H'), $start->format('i'), $start->format('s')); // In case start time uses a different tz than what the rrule internally does, we force it to use the same - $startDate->setTimezone(new DateTimeZone($this->rrule->getTimezone())); + /** @var string $timeZone */ + $timeZone = $this->rrule->getTimezone(); + $startDate->setTimezone(new DateTimeZone($timeZone)); $this->rrule->setStartDate($startDate); @@ -267,7 +272,9 @@ public function getNextRecurrences( if (! $this->rrule->repeatsIndefinitely()) { // When accessing this method externally (not by using `getNextDue()`), the transformer may // generate recurrences beyond the configured end time. - $constraint = new BetweenConstraint($dateTime, $this->getEnd(), $include); + /** @var DateTimeInterface $end */ + $end = $this->getEnd(); + $constraint = new BetweenConstraint($dateTime, $end, $include); } // Setting the start date to a date time smaller than now causes the underlying library @@ -284,6 +291,9 @@ public function getNextRecurrences( } } + /** + * @return array + */ public function jsonSerialize(): array { $data = [ @@ -323,6 +333,9 @@ public function __call(string $methodName, array $args) ); } - return call_user_func_array([$this->rrule, $methodName], $args); + /** @var callable $callBack */ + $callBack = [$this->rrule, $methodName]; + + return call_user_func_array($callBack, $args); } } diff --git a/src/Scheduler.php b/src/Scheduler.php index 25ad3a1..a255019 100644 --- a/src/Scheduler.php +++ b/src/Scheduler.php @@ -10,6 +10,7 @@ use ipl\Scheduler\Contract\Task; use ipl\Stdlib\Events; use React\EventLoop\Loop; +use React\EventLoop\TimerInterface; use React\Promise; use React\Promise\ExtendedPromiseInterface; use SplObjectStorage; @@ -283,7 +284,9 @@ public function isValidEvent(string $event): bool */ protected function cancelTask(Task $task): void { - Loop::cancelTimer($this->detachTimer($task->getUuid())); + /** @var TimerInterface $timer */ + $timer = $this->detachTimer($task->getUuid()); + Loop::cancelTimer($timer); /** @var ExtendedPromiseInterface[] $promises */ $promises = $this->detachPromises($task->getUuid());