Skip to content

Commit

Permalink
added @throws DatetimeException in DateTime and DateTimeImmutable
Browse files Browse the repository at this point in the history
  • Loading branch information
Kharhamel committed Jun 9, 2020
1 parent 1bcce53 commit 9c5aaf4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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
{
Expand All @@ -48,6 +50,7 @@ public function diff($datetime2, $absolute = false): DateInterval
/**
* @param string $modify A date/time string. Valid formats are explained in <a href="https://secure.php.net/manual/en/datetime.formats.php">Date and Time Formats</a>.
* @return DateTime Returns the DateTime object for method chaining.
* @throws DatetimeException
*/
public function modify($modify): self
{
Expand All @@ -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
{
Expand Down
13 changes: 13 additions & 0 deletions lib/DateTimeImmutable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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
{
Expand All @@ -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
{
Expand All @@ -89,6 +92,7 @@ public function diff($datetime2, $absolute = false): DateInterval
/**
* @param string $modify
* @return DateTimeImmutable
* @throws DatetimeException
*/
public function modify($modify): self
{
Expand All @@ -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
{
Expand All @@ -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
{
Expand All @@ -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
{
Expand All @@ -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
{
Expand All @@ -166,6 +174,7 @@ public function setTimestamp($unixtimestamp): self
/**
* @param DateTimeZone $timezone
* @return DateTimeImmutable
* @throws DatetimeException
*/
public function setTimezone($timezone): self
{
Expand All @@ -180,6 +189,7 @@ public function setTimezone($timezone): self
/**
* @param DateInterval $interval
* @return DateTimeImmutable
* @throws DatetimeException
*/
public function sub($interval): self
{
Expand All @@ -191,6 +201,9 @@ public function sub($interval): self
return self::createFromRegular($result);
}

/**
* @throws DatetimeException
*/
public function getOffset(): int
{
/** @var int|false $result */
Expand Down

0 comments on commit 9c5aaf4

Please sign in to comment.