Skip to content

Commit f4ca761

Browse files
committed
Don't use native union types yet
1 parent 05f8098 commit f4ca761

4 files changed

Lines changed: 14 additions & 6 deletions

File tree

lib/Tmdb/Factory/AbstractFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public function createResult(array $data = [])
212212
*
213213
* @return GenericCollection<S>
214214
*/
215-
protected function createGenericCollection(array $data = [], AbstractModel|string $class = null): GenericCollection
215+
protected function createGenericCollection(array $data = [], $class = null): GenericCollection
216216
{
217217
if (!$class) {
218218
throw new \Tmdb\Exception\RuntimeException('Expected a class to be present.');
@@ -244,7 +244,7 @@ protected function createGenericCollection(array $data = [], AbstractModel|strin
244244
*/
245245
protected function createCustomCollection(
246246
array $data,
247-
AbstractModel|string $class,
247+
$class,
248248
GenericCollection $collection
249249
) {
250250
if (!$class) {

lib/Tmdb/Repository/TvEpisodeRepository.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class TvEpisodeRepository extends AbstractRepository
5151
* @return null|AbstractModel
5252
* @throws RuntimeException
5353
*/
54-
public function load(Tv|int $tvShow, Season|int $season, Episode|int $episode, array $parameters = [], array $headers = [])
54+
public function load($tvShow, $season, $episode, array $parameters = [], array $headers = [])
5555
{
5656
if ($tvShow instanceof Tv) {
5757
$tvShow = $tvShow->getId();
@@ -65,6 +65,10 @@ public function load(Tv|int $tvShow, Season|int $season, Episode|int $episode, a
6565
$episode = $episode->getEpisodeNumber();
6666
}
6767

68+
if (is_null($tvShow) || is_null($season) || is_null($episode)) {
69+
throw new RuntimeException('Not all required parameters to load an tv episode are present.');
70+
}
71+
6872
if (!isset($parameters['append_to_response'])) {
6973
$parameters = array_merge($parameters, [
7074
new AppendToResponse([

lib/Tmdb/Repository/TvSeasonRepository.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ public function load(int|Tv $tvShow, int|Season $season, array $parameters = [],
5555
$season = $season->getSeasonNumber();
5656
}
5757

58+
if (null === $tvShow || null === $season) {
59+
throw new RuntimeException('Not all required parameters to load an tv season are present.');
60+
}
61+
5862
if (!isset($parameters['append_to_response'])) {
5963
$parameters = array_merge($parameters, [
6064
new AppendToResponse([
@@ -101,7 +105,7 @@ public function getFactory()
101105
* @param array $headers
102106
* @return CreditsCollection
103107
*/
104-
public function getCredits(Tv|int $tvShow, Season|int $season, array $parameters = [], array $headers = [])
108+
public function getCredits($tvShow, $season, array $parameters = [], array $headers = [])
105109
{
106110
if ($tvShow instanceof Tv) {
107111
$tvShow = $tvShow->getId();

test/Tmdb/Tests/Repository/TvEpisodeRepositoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ public function shouldRateModel()
247247
*/
248248
public function shouldThrowExceptionWhenConditionsNotMet()
249249
{
250-
$this->expectException(TypeError::class);
250+
$this->expectException(RuntimeException::class);
251251
$repository = $this->getRepositoryWithMockedHttpClient();
252252

253253
$tv = new Tv();
@@ -264,7 +264,7 @@ public function shouldThrowExceptionWhenConditionsNotMet()
264264
*/
265265
public function shouldThrowExceptionWhenConditionsNotMetAll()
266266
{
267-
$this->expectException(TypeError::class);
267+
$this->expectException(RuntimeException::class);
268268
$repository = $this->getRepositoryWithMockedHttpClient();
269269

270270
$repository->load(null, null, null);

0 commit comments

Comments
 (0)