From 9c5aaf427e3901cec10b08a68b113d4ae503c146 Mon Sep 17 00:00:00 2001 From: Kharhamel Date: Tue, 9 Jun 2020 16:34:18 +0200 Subject: [PATCH] added @throws DatetimeException in DateTime and DateTimeImmutable --- lib/DateTime.php | 4 ++++ lib/DateTimeImmutable.php | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/lib/DateTime.php b/lib/DateTime.php index b3778d4b..581ef35c 100644 --- a/lib/DateTime.php +++ b/lib/DateTime.php @@ -20,6 +20,7 @@ private static function createFromRegular(\DateTime $datetime): self * @param string $format * @param string $time * @param DateTimeZone|null $timezone + * @throws DatetimeException */ public static function createFromFormat($format, $time, $timezone = null): self { @@ -34,6 +35,7 @@ public static function createFromFormat($format, $time, $timezone = null): self * @param DateTimeInterface $datetime2 The date to compare to. * @param boolean $absolute [optional] Whether to return absolute difference. * @return DateInterval The DateInterval object representing the difference between the two dates. + * @throws DatetimeException */ public function diff($datetime2, $absolute = false): DateInterval { @@ -48,6 +50,7 @@ public function diff($datetime2, $absolute = false): DateInterval /** * @param string $modify A date/time string. Valid formats are explained in Date and Time Formats. * @return DateTime Returns the DateTime object for method chaining. + * @throws DatetimeException */ public function modify($modify): self { @@ -64,6 +67,7 @@ public function modify($modify): self * @param int $month * @param int $day * @return DateTime + * @throws DatetimeException */ public function setDate($year, $month, $day): self { diff --git a/lib/DateTimeImmutable.php b/lib/DateTimeImmutable.php index 878f65a8..14e2aa54 100644 --- a/lib/DateTimeImmutable.php +++ b/lib/DateTimeImmutable.php @@ -47,6 +47,7 @@ private static function createFromRegular(\DateTimeImmutable $datetime): self * @param string $format * @param string $time * @param DateTimeZone|null $timezone + * @throws DatetimeException */ public static function createFromFormat($format, $time, $timezone = null): self { @@ -60,6 +61,7 @@ public static function createFromFormat($format, $time, $timezone = null): self /** * @param string $format * @return string + * @throws DatetimeException */ public function format($format): string { @@ -75,6 +77,7 @@ public function format($format): string * @param DateTimeInterface $datetime2 * @param bool $absolute * @return DateInterval + * @throws DatetimeException */ public function diff($datetime2, $absolute = false): DateInterval { @@ -89,6 +92,7 @@ public function diff($datetime2, $absolute = false): DateInterval /** * @param string $modify * @return DateTimeImmutable + * @throws DatetimeException */ public function modify($modify): self { @@ -105,6 +109,7 @@ public function modify($modify): self * @param int $month * @param int $day * @return DateTimeImmutable + * @throws DatetimeException */ public function setDate($year, $month, $day): self { @@ -121,6 +126,7 @@ public function setDate($year, $month, $day): self * @param int $week * @param int $day * @return DateTimeImmutable + * @throws DatetimeException */ public function setISODate($year, $week, $day = 1): self { @@ -138,6 +144,7 @@ public function setISODate($year, $week, $day = 1): self * @param int $second * @param int $microseconds * @return DateTimeImmutable + * @throws DatetimeException */ public function setTime($hour, $minute, $second = 0, $microseconds = 0): self { @@ -152,6 +159,7 @@ public function setTime($hour, $minute, $second = 0, $microseconds = 0): self /** * @param int $unixtimestamp * @return DateTimeImmutable + * @throws DatetimeException */ public function setTimestamp($unixtimestamp): self { @@ -166,6 +174,7 @@ public function setTimestamp($unixtimestamp): self /** * @param DateTimeZone $timezone * @return DateTimeImmutable + * @throws DatetimeException */ public function setTimezone($timezone): self { @@ -180,6 +189,7 @@ public function setTimezone($timezone): self /** * @param DateInterval $interval * @return DateTimeImmutable + * @throws DatetimeException */ public function sub($interval): self { @@ -191,6 +201,9 @@ public function sub($interval): self return self::createFromRegular($result); } + /** + * @throws DatetimeException + */ public function getOffset(): int { /** @var int|false $result */