From 8a36349dc2c1840b5014ac874553506629162d29 Mon Sep 17 00:00:00 2001 From: Michael Roterman Date: Sun, 7 Mar 2021 16:03:07 +0100 Subject: [PATCH] Fixes #229, do not set the datetime objects when there is no valid date given. --- lib/Tmdb/Model/Common/Change/Item.php | 6 +++--- lib/Tmdb/Model/Movie.php | 6 +++--- lib/Tmdb/Model/Movie/Release.php | 6 +++--- lib/Tmdb/Model/Movie/ReleaseDate.php | 6 +++--- lib/Tmdb/Model/Person/Credit.php | 6 +++--- lib/Tmdb/Model/Tv.php | 12 ++++++------ lib/Tmdb/Model/Tv/Episode.php | 6 +++--- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/Tmdb/Model/Common/Change/Item.php b/lib/Tmdb/Model/Common/Change/Item.php index a88377a4..df6c8a99 100644 --- a/lib/Tmdb/Model/Common/Change/Item.php +++ b/lib/Tmdb/Model/Common/Change/Item.php @@ -93,12 +93,12 @@ public function getTime() } /** - * @param string|DateTime $time + * @param string|DateTime|null $time * @return $this */ - public function setTime($time) + public function setTime($time = null) { - if (!$time instanceof DateTime) { + if (!$time instanceof DateTime && $time !== null) { $time = new DateTime($time); } diff --git a/lib/Tmdb/Model/Movie.php b/lib/Tmdb/Model/Movie.php index 83a49510..8f4b33d2 100644 --- a/lib/Tmdb/Model/Movie.php +++ b/lib/Tmdb/Model/Movie.php @@ -570,12 +570,12 @@ public function getReleaseDate() } /** - * @param string $releaseDate + * @param DateTime|string|null $releaseDate * @return $this */ - public function setReleaseDate($releaseDate) + public function setReleaseDate($releaseDate = null) { - if (!$releaseDate instanceof DateTime) { + if (!$releaseDate instanceof DateTime && $releaseDate !== null) { $releaseDate = new DateTime($releaseDate); } diff --git a/lib/Tmdb/Model/Movie/Release.php b/lib/Tmdb/Model/Movie/Release.php index 103a40f0..a0a37ab1 100644 --- a/lib/Tmdb/Model/Movie/Release.php +++ b/lib/Tmdb/Model/Movie/Release.php @@ -83,12 +83,12 @@ public function getReleaseDate() } /** - * @param string|DateTime $releaseDate + * @param string|DateTime|null $releaseDate * @return $this */ - public function setReleaseDate($releaseDate) + public function setReleaseDate($releaseDate = null) { - if (!$releaseDate instanceof DateTime) { + if (!$releaseDate instanceof DateTime && $releaseDate !== null) { $releaseDate = new DateTime($releaseDate); } diff --git a/lib/Tmdb/Model/Movie/ReleaseDate.php b/lib/Tmdb/Model/Movie/ReleaseDate.php index 2ed322d7..40bed8ee 100644 --- a/lib/Tmdb/Model/Movie/ReleaseDate.php +++ b/lib/Tmdb/Model/Movie/ReleaseDate.php @@ -112,12 +112,12 @@ public function getReleaseDate() } /** - * @param string|DateTime $releaseDate + * @param string|DateTime|null $releaseDate * @return $this */ - public function setReleaseDate($releaseDate) + public function setReleaseDate($releaseDate = null) { - if (!$releaseDate instanceof DateTime) { + if (!$releaseDate instanceof DateTime && $releaseDate !== null) { $releaseDate = new DateTime($releaseDate); } diff --git a/lib/Tmdb/Model/Person/Credit.php b/lib/Tmdb/Model/Person/Credit.php index d2575b13..b120cf45 100644 --- a/lib/Tmdb/Model/Person/Credit.php +++ b/lib/Tmdb/Model/Person/Credit.php @@ -248,12 +248,12 @@ public function getReleaseDate() } /** - * @param DateTime $releaseDate + * @param DateTime|string|null $releaseDate * @return $this */ - public function setReleaseDate($releaseDate) + public function setReleaseDate($releaseDate = null) { - if (!$releaseDate instanceof DateTime) { + if (!$releaseDate instanceof DateTime && $releaseDate !== null) { $releaseDate = new DateTime($releaseDate); } diff --git a/lib/Tmdb/Model/Tv.php b/lib/Tmdb/Model/Tv.php index 8acf01ed..5e7b032c 100644 --- a/lib/Tmdb/Model/Tv.php +++ b/lib/Tmdb/Model/Tv.php @@ -343,12 +343,12 @@ public function getFirstAirDate() } /** - * @param DateTime $firstAirDate + * @param DateTime|string|null $firstAirDate * @return $this */ - public function setFirstAirDate($firstAirDate) + public function setFirstAirDate($firstAirDate = null) { - if (!$firstAirDate instanceof DateTime) { + if (!$firstAirDate instanceof DateTime && $firstAirDate !== null) { $firstAirDate = new DateTime($firstAirDate); } @@ -461,12 +461,12 @@ public function getLastAirDate() } /** - * @param string $lastAirDate + * @param DateTime|string|null $lastAirDate * @return $this */ - public function setLastAirDate($lastAirDate) + public function setLastAirDate($lastAirDate = null) { - if (!$lastAirDate instanceof DateTime) { + if (!$lastAirDate instanceof DateTime && $lastAirDate !== null) { $lastAirDate = new DateTime($lastAirDate); } diff --git a/lib/Tmdb/Model/Tv/Episode.php b/lib/Tmdb/Model/Tv/Episode.php index 15e9ab93..0b2fa57f 100644 --- a/lib/Tmdb/Model/Tv/Episode.php +++ b/lib/Tmdb/Model/Tv/Episode.php @@ -159,12 +159,12 @@ public function getAirDate() } /** - * @param DateTime $airDate + * @param DateTime|string|null $airDate * @return $this */ - public function setAirDate($airDate) + public function setAirDate($airDate = null) { - if (!$airDate instanceof DateTime) { + if (!$airDate instanceof DateTime && $airDate !== null) { $airDate = new DateTime($airDate); }