Skip to content

Commit

Permalink
Drop use of DateTimeInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
juniwalk authored May 10, 2024
1 parent 1ac4f60 commit cea9577
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 19 deletions.
22 changes: 11 additions & 11 deletions src/Entity/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace JuniWalk\Calendar\Entity;

use DateTimeInterface;
use DateTime;
use JuniWalk\Calendar\Enums\Day;
use JuniWalk\Calendar\Event;
use JuniWalk\Calendar\EventDetail;
Expand All @@ -28,8 +28,8 @@ class Activity implements Event, EventDetail, EventLinkable, EventRecurring
public mixed $groupId;
public string $source;
public bool $allDay;
public DateTimeInterface $start;
public ?DateTimeInterface $end;
public DateTime $start;
public ?DateTime $end;
public string $title;
public Html $titleHtml;
/** @var string[] */
Expand All @@ -47,8 +47,8 @@ class Activity implements Event, EventDetail, EventLinkable, EventRecurring
// EventRecurring
/** @var DayNumber[] */
public array $daysOfWeek;
public ?DateTimeInterface $startRecur;
public ?DateTimeInterface $endRecur;
public ?DateTime $startRecur;
public ?DateTime $endRecur;
public string $startTime;
public string $endTime;

Expand Down Expand Up @@ -87,29 +87,29 @@ public function getSource(): string
}


public function setStart(DateTimeInterface $start): void
public function setStart(DateTime $start): void
{
$this->start = clone $start;
}


public function getStart(): DateTimeInterface
public function getStart(): DateTime
{
return $this->start;
}


public function setEnd(?DateTimeInterface $end): void
public function setEnd(?DateTime $end): void
{
if ($end instanceof DateTimeInterface) {
if ($end instanceof DateTime) {
$end = clone $end;
}

$this->end = $end;
}


public function getEnd(): ?DateTimeInterface
public function getEnd(): ?DateTime
{
return $this->end ?? null;
}
Expand Down Expand Up @@ -163,7 +163,7 @@ public function setParams(array $params): void
continue;
}

if ($value instanceof DateTimeInterface) {
if ($value instanceof DateTime) {
$value = clone $value;
}

Expand Down
5 changes: 2 additions & 3 deletions src/Entity/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
namespace JuniWalk\Calendar\Entity;

use DateTime;
use DateTimeInterface;
use JuniWalk\Calendar\Calendar;
use JuniWalk\Calendar\Config;
use JuniWalk\Calendar\Event;
Expand Down Expand Up @@ -392,7 +391,7 @@ public static function createSchema(): Schema
}


protected function startsTooSoon(DateTimeInterface $date): bool
protected function startsTooSoon(DateTime $date): bool
{
$dow = (int) $date->format('N');

Expand All @@ -405,7 +404,7 @@ protected function startsTooSoon(DateTimeInterface $date): bool
}


protected function endsTooLate(DateTimeInterface $date): bool
protected function endsTooLate(DateTime $date): bool
{
$dow = (int) $date->format('N');

Expand Down
2 changes: 1 addition & 1 deletion src/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace JuniWalk\Calendar;

use DateTimeInterface as DateTime;
use DateTime;
use JsonSerializable;

interface Event extends JsonSerializable
Expand Down
2 changes: 1 addition & 1 deletion src/Source.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace JuniWalk\Calendar;

use DateTimeInterface as DateTime;
use DateTime;
use DateTimeZone;
use JuniWalk\Calendar\Entity\Legend;
use Nette\Application\UI\SignalReceiver;
Expand Down
2 changes: 1 addition & 1 deletion src/SourceEditable.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace JuniWalk\Calendar;

use DateTimeInterface as DateTime;
use DateTime;

interface SourceEditable
{
Expand Down
3 changes: 1 addition & 2 deletions src/Sources/CzechHolidaysSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
namespace JuniWalk\Calendar\Sources;

use DateTime;
use DateTimeInterface;
use DateTimeZone;
use JuniWalk\Calendar\Calendar;
use JuniWalk\Calendar\Config;
Expand All @@ -34,7 +33,7 @@ public function getLegend(): array
/**
* @return Event[]
*/
public function fetchEvents(DateTimeInterface $start, DateTimeInterface $end, DateTimeZone $timeZone): array
public function fetchEvents(DateTime $start, DateTime $end, DateTimeZone $timeZone): array
{
$start = new DateTime($start->format(DateTime::ATOM));
$events = [];
Expand Down

0 comments on commit cea9577

Please sign in to comment.