Skip to content

Commit

Permalink
Fix for php 8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
gharlan committed Dec 6, 2024
1 parent 4787e85 commit 0a22e15
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
12 changes: 6 additions & 6 deletions src/AbstractDateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static function createFromDateTime(\DateTimeInterface $dateTime): self
/**
* @return static
*/
public static function createFromTimestamp(int $timestamp): self
public static function createFromTimestamp(int|float $timestamp): static
{
$class = static::getClass();

Expand Down Expand Up @@ -96,7 +96,7 @@ public function formatLocalized(string $format): string
return strftime($format, $this->getTimestamp());
}

public function formatIntl(int $format = null, int $timeFormat = null): string
public function formatIntl(?int $format = null, ?int $timeFormat = null): string
{
if (!class_exists(\IntlDateFormatter::class)) {
throw new \Exception(sprintf('%s can not be used without the intl extension.', __METHOD__));
Expand Down Expand Up @@ -167,21 +167,21 @@ public function addDays(int $days): DateTimeInterface
return $this->modify($days.' days');
}

public function isWorkday(HolidaysInterface $holidays = null): bool
public function isWorkday(?HolidaysInterface $holidays = null): bool
{
$holidays = $holidays ?: self::getDefaultHolidays();

return $holidays->isWorkday($this);
}

public function isHoliday(HolidaysInterface $holidays = null): bool
public function isHoliday(?HolidaysInterface $holidays = null): bool
{
$holidays = $holidays ?: self::getDefaultHolidays();

return $holidays->isHoliday($this);
}

public function addWorkdays(int $days, HolidaysInterface $holidays = null): DateTimeInterface
public function addWorkdays(int $days, ?HolidaysInterface $holidays = null): DateTimeInterface
{
$holidays = $holidays ?: self::getDefaultHolidays();

Expand All @@ -198,7 +198,7 @@ public function addWorkdays(int $days, HolidaysInterface $holidays = null): Date
return $date;
}

public function diffWorkdays(DateTimeInterface $date2, HolidaysInterface $holidays = null): int
public function diffWorkdays(DateTimeInterface $date2, ?HolidaysInterface $holidays = null): int
{
$holidays = $holidays ?: self::getDefaultHolidays();

Expand Down
6 changes: 3 additions & 3 deletions src/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class Date extends AbstractDateTime
{
public function __construct(string $date = 'today', \DateTimeZone $timezone = null)
public function __construct(string $date = 'today', ?\DateTimeZone $timezone = null)
{
parent::__construct(self::stripTime($date), $timezone);
}
Expand Down Expand Up @@ -51,7 +51,7 @@ public function formatIso(): string
return $this->format('Y-m-d');
}

public function formatIntl(int $format = null, int $timeFormat = null): string
public function formatIntl(?int $format = null, ?int $timeFormat = null): string
{
if (!class_exists(\IntlDateFormatter::class)) {
throw new \Exception(sprintf('%s can not be used without the intl extension.', __METHOD__));
Expand Down Expand Up @@ -109,7 +109,7 @@ public function sub(\DateInterval $interval): \DateTimeImmutable
return parent::sub($interval)->setTime(0, 0, 0);
}

public function modify(string $modify): \DateTimeImmutable|false
public function modify(string $modify): \DateTimeImmutable
{
return parent::modify($modify)->setTime(0, 0, 0);
}
Expand Down
4 changes: 2 additions & 2 deletions src/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function formatIsoTime(): string
return $this->format('H:i:s');
}

public function formatIntlDate(int $format = null): string
public function formatIntlDate(?int $format = null): string
{
if (!class_exists(\IntlDateFormatter::class)) {
throw new \Exception(sprintf('%s can not be used without the intl extension.', __METHOD__));
Expand All @@ -60,7 +60,7 @@ public function formatIntlDate(int $format = null): string
return static::formatIntl($format, \IntlDateFormatter::NONE);
}

public function formatIntlTime(int $format = null): string
public function formatIntlTime(?int $format = null): string
{
if (!class_exists(\IntlDateFormatter::class)) {
throw new \Exception(sprintf('%s can not be used without the intl extension.', __METHOD__));
Expand Down
10 changes: 5 additions & 5 deletions src/DateTimeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function formatIso(): string;

public function formatLocalized(string $format): string;

public function formatIntl(int $format = null, int $timeFormat = null): string;
public function formatIntl(?int $format = null, ?int $timeFormat = null): string;

public function toMutable(): \DateTime;

Expand Down Expand Up @@ -58,30 +58,30 @@ public function addDays(int $days): self;
*
* @return bool
*/
public function isWorkday(HolidaysInterface $holidays = null): bool;
public function isWorkday(?HolidaysInterface $holidays = null): bool;

/**
* @param null|HolidaysInterface $holidays
*
* @return bool
*/
public function isHoliday(HolidaysInterface $holidays = null): bool;
public function isHoliday(?HolidaysInterface $holidays = null): bool;

/**
* @param int $days
* @param null|HolidaysInterface $holidays
*
* @return static
*/
public function addWorkdays(int $days, HolidaysInterface $holidays = null): self;
public function addWorkdays(int $days, ?HolidaysInterface $holidays = null): self;

/**
* @param self $date
* @param null|HolidaysInterface $holidays
*
* @return int
*/
public function diffWorkdays(self $date, HolidaysInterface $holidays = null): int;
public function diffWorkdays(self $date, ?HolidaysInterface $holidays = null): int;

/**
* @param string $modify
Expand Down

0 comments on commit 0a22e15

Please sign in to comment.