From 3c11bdf1b62ed6b2f3d66d8df46ea860bc80a2ce Mon Sep 17 00:00:00 2001 From: Michael Roterman Date: Sun, 18 May 2025 15:44:40 +0200 Subject: [PATCH 01/14] Add support for Symfony 7 components and update GitHub workflows --- .github/workflows/coding-standards.yml | 8 +++--- .github/workflows/continuous-integration.yml | 28 +++++++++++++++++--- .github/workflows/static-analysis.yml | 2 ++ composer.json | 6 ++--- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 8c69385b..503a6588 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -5,16 +5,16 @@ on: ["pull_request"] jobs: coding-standards: name: "Coding Standards" - runs-on: "ubuntu-20.04" + runs-on: "ubuntu-latest" strategy: matrix: php-version: - - "7.4" + - "8.1" steps: - name: "Checkout" - uses: "actions/checkout@v2" + uses: "actions/checkout@v3" with: fetch-depth: 10 @@ -26,7 +26,7 @@ jobs: tools: "cs2pr" - name: "Cache dependencies installed with Composer" - uses: "actions/cache@v2" + uses: "actions/cache@v3" with: path: "~/.composer/cache" key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}" diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 349b15fd..cdf3fb75 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -8,7 +8,7 @@ env: jobs: phpunit: name: "PHPUnit" - runs-on: "ubuntu-20.04" + runs-on: "ubuntu-latest" strategy: matrix: @@ -16,6 +16,8 @@ jobs: - "7.4" - "8.0" - "8.1" + - "8.2" + - "8.3" deps: - "normal" symfony-require: @@ -49,10 +51,28 @@ jobs: - php-version: "8.1" deps: "dev" + + - php-version: "8.2" + deps: "normal" + + - php-version: "8.2" + deps: "low" + + - php-version: "8.2" + deps: "dev" + + - php-version: "8.3" + deps: "normal" + + - php-version: "8.3" + deps: "low" + + - php-version: "8.3" + deps: "dev" steps: - name: "Checkout" - uses: "actions/checkout@v2" + uses: "actions/checkout@v3" with: fetch-depth: 2 @@ -62,7 +82,7 @@ jobs: php-version: "${{ matrix.php-version }}" - name: "Cache dependencies installed with composer" - uses: "actions/cache@v2" + uses: "actions/cache@v3" with: path: "~/.composer/cache" key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}" @@ -89,6 +109,6 @@ jobs: name: "phpunit-${{ matrix.php-version }}-${{ matrix.deps }}-${{ hashFiles('composer.lock') }}.coverage" path: "coverage.xml" - - uses: codecov/codecov-action@v1 + - uses: codecov/codecov-action@v3 with: verbose: true diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 21edc6b6..470d8dbb 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -13,6 +13,8 @@ jobs: - "7.4" - "8.0" - "8.1" + - "8.2" + - "8.3" steps: - name: "Checkout code" diff --git a/composer.json b/composer.json index 79a56e52..2653abc7 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ "require": { "php": "^7.3 || ^8.0", "ext-json": "*", - "symfony/options-resolver": "^4.4 || ^5 || ^6", + "symfony/options-resolver": "^4.4 || ^5 || ^6 || ^7", "psr/cache": "^1 || ^2 || ^3", "psr/simple-cache": "^1 || ^2 || ^3", "psr/event-dispatcher": "^1", @@ -51,8 +51,8 @@ "php-http/mock-client": "^1.2", "slevomat/coding-standard": "^8.8", "squizlabs/php_codesniffer": "^3.5.8", - "symfony/cache": "^4.4 || ^5 || ^6", - "symfony/event-dispatcher": "^4.4 || ^5 || ^6", + "symfony/cache": "^4.4 || ^5 || ^6 || ^7", + "symfony/event-dispatcher": "^4.4 || ^5 || ^6 || ^7", "phpstan/phpstan": "^1.8.1", "phpstan/phpstan-deprecation-rules": "^1.1", "spaze/phpstan-disallowed-calls": "^2.11", From 066436296573f9907fbf330b5e95cb6fe0b6e541 Mon Sep 17 00:00:00 2001 From: Michael Roterman Date: Sun, 18 May 2025 15:47:42 +0200 Subject: [PATCH 02/14] Document Symfony 7 component support in UPGRADE-CURRENT.md --- UPGRADE-CURRENT.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 UPGRADE-CURRENT.md diff --git a/UPGRADE-CURRENT.md b/UPGRADE-CURRENT.md new file mode 100644 index 00000000..68d23b18 --- /dev/null +++ b/UPGRADE-CURRENT.md @@ -0,0 +1,6 @@ +# UPGRADE-CURRENT.md + +## Changes in this version + +- Removed `rtheunissen/guzzle-log-middleware` dependency due to compatibility issues with Guzzle 7.0. This middleware is temporarily removed and may be reintroduced in a future release once compatibility is resolved. +- Added support for Symfony 7 components. Note that Symfony 7 requires PHP 8.1 or higher. If you're using PHP < 8.1, Composer will automatically select a compatible Symfony version (4, 5, or 6). \ No newline at end of file From 83e87dd83460e5f6a9a13a48d191d57d343c6d9d Mon Sep 17 00:00:00 2001 From: Michael Roterman Date: Sun, 18 May 2025 15:50:50 +0200 Subject: [PATCH 03/14] Update PHP version badge in README.md to include PHP 8.1-8.3 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b3f3151f..c9aeffc3 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Build Status](https://img.shields.io/github/actions/workflow/status/php-tmdb/api/continuous-integration.yml?label=phpunit)](https://github.com/php-tmdb/api/actions/workflows/continuous-integration.yml) [![Build Status](https://img.shields.io/github/actions/workflow/status/php-tmdb/api/coding-standards.yml?label=phpcs)](https://github.com/php-tmdb/api/actions/workflows/coding-standards.yml) [![codecov](https://img.shields.io/codecov/c/github/php-tmdb/api?token=gTM9AiO5vH)](https://codecov.io/gh/php-tmdb/api) -[![PHP](https://img.shields.io/badge/php->=7.3,%20>=7.4,%20>=8.0-8892BF.svg)](https://packagist.org/packages/php-tmdb/api) +[![PHP](https://img.shields.io/badge/php->=7.3,%20>=8.0,%20>=8.1,%20>=8.2,%20>=8.3-8892BF.svg)](https://packagist.org/packages/php-tmdb/api) [![Total Downloads](https://poser.pugx.org/php-tmdb/api/downloads.svg)](https://packagist.org/packages/php-tmdb/api) Tests run with minimal, normal and development dependencies. From c71e6c0b907a8da94e7cf79ae03c3eab13ae2c58 Mon Sep 17 00:00:00 2001 From: Michael Roterman Date: Sun, 18 May 2025 16:01:41 +0200 Subject: [PATCH 04/14] Update GitHub workflow to test against multiple Symfony versions --- .github/workflows/continuous-integration.yml | 44 +++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index cdf3fb75..95a78ce0 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -25,6 +25,7 @@ jobs: symfony-deprecations-helper: - "" include: + # PHP 7.4 test matrix - php-version: "7.4" deps: "normal" @@ -33,7 +34,13 @@ jobs: - php-version: "7.4" deps: "dev" + + # Test Symfony 4 with PHP 7.4 + - php-version: "7.4" + deps: "normal" + symfony-require: "4.4.*" + # PHP 8.0 test matrix - php-version: "8.0" deps: "normal" @@ -42,7 +49,13 @@ jobs: - php-version: "8.0" deps: "dev" + + # Test Symfony 5 with PHP 8.0 + - php-version: "8.0" + deps: "normal" + symfony-require: "5.4.*" + # PHP 8.1 test matrix - php-version: "8.1" deps: "normal" @@ -52,6 +65,12 @@ jobs: - php-version: "8.1" deps: "dev" + # Test Symfony 6 with PHP 8.1 + - php-version: "8.1" + deps: "normal" + symfony-require: "6.4.*" + + # PHP 8.2 test matrix - php-version: "8.2" deps: "normal" @@ -61,6 +80,12 @@ jobs: - php-version: "8.2" deps: "dev" + # Test Symfony 7 with PHP 8.2 + - php-version: "8.2" + deps: "normal" + symfony-require: "7.0.*" + + # PHP 8.3 test matrix - php-version: "8.3" deps: "normal" @@ -69,6 +94,11 @@ jobs: - php-version: "8.3" deps: "dev" + + # Test latest Symfony with PHP 8.3 + - php-version: "8.3" + deps: "normal" + symfony-require: "7.*" steps: - name: "Checkout" @@ -80,6 +110,10 @@ jobs: uses: "shivammathur/setup-php@v2" with: php-version: "${{ matrix.php-version }}" + extensions: "json" + tools: "composer:2" + coverage: "pcov" + ini-values: "memory_limit=-1" - name: "Cache dependencies installed with composer" uses: "actions/cache@v3" @@ -88,6 +122,14 @@ jobs: key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}" restore-keys: "php-${{ matrix.php-version }}-composer-locked-" + - name: "Require specific Symfony version" + run: "composer global require --no-progress --no-scripts --no-plugins 'symfony/flex:^2.3'" + if: "${{ matrix.symfony-require != '' }}" + + - name: "Set Symfony version constraint" + run: "composer config extra.symfony.require ${{ matrix.symfony-require }}" + if: "${{ matrix.symfony-require != '' }}" + - name: "Install stable dependencies with composer" run: "composer update --no-interaction --prefer-dist --prefer-stable" if: "${{ matrix.deps == 'normal' }}" @@ -106,7 +148,7 @@ jobs: - name: "Upload coverage file" uses: "actions/upload-artifact@v4" with: - name: "phpunit-${{ matrix.php-version }}-${{ matrix.deps }}-${{ hashFiles('composer.lock') }}.coverage" + name: "phpunit-${{ matrix.php-version }}-${{ matrix.deps }}-${{ matrix.symfony-require }}-${{ hashFiles('composer.lock') }}.coverage" path: "coverage.xml" - uses: codecov/codecov-action@v3 From ae1f11ffd2a7bf425d933668ec0a26831af0b30c Mon Sep 17 00:00:00 2001 From: Michael Roterman Date: Sun, 18 May 2025 16:06:36 +0200 Subject: [PATCH 05/14] Drop support for PHP 7.4 and 8.0 (EOL), update requirements to PHP 8.1+ --- .github/workflows/continuous-integration.yml | 32 -------------------- .github/workflows/static-analysis.yml | 2 -- README.md | 2 +- composer.json | 10 +++--- 4 files changed, 6 insertions(+), 40 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 95a78ce0..b654b469 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -13,8 +13,6 @@ jobs: strategy: matrix: php-version: - - "7.4" - - "8.0" - "8.1" - "8.2" - "8.3" @@ -25,36 +23,6 @@ jobs: symfony-deprecations-helper: - "" include: - # PHP 7.4 test matrix - - php-version: "7.4" - deps: "normal" - - - php-version: "7.4" - deps: "low" - - - php-version: "7.4" - deps: "dev" - - # Test Symfony 4 with PHP 7.4 - - php-version: "7.4" - deps: "normal" - symfony-require: "4.4.*" - - # PHP 8.0 test matrix - - php-version: "8.0" - deps: "normal" - - - php-version: "8.0" - deps: "low" - - - php-version: "8.0" - deps: "dev" - - # Test Symfony 5 with PHP 8.0 - - php-version: "8.0" - deps: "normal" - symfony-require: "5.4.*" - # PHP 8.1 test matrix - php-version: "8.1" deps: "normal" diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 470d8dbb..a7eb6baf 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -10,8 +10,6 @@ jobs: strategy: matrix: php-version: - - "7.4" - - "8.0" - "8.1" - "8.2" - "8.3" diff --git a/README.md b/README.md index c9aeffc3..fb0265f6 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Build Status](https://img.shields.io/github/actions/workflow/status/php-tmdb/api/continuous-integration.yml?label=phpunit)](https://github.com/php-tmdb/api/actions/workflows/continuous-integration.yml) [![Build Status](https://img.shields.io/github/actions/workflow/status/php-tmdb/api/coding-standards.yml?label=phpcs)](https://github.com/php-tmdb/api/actions/workflows/coding-standards.yml) [![codecov](https://img.shields.io/codecov/c/github/php-tmdb/api?token=gTM9AiO5vH)](https://codecov.io/gh/php-tmdb/api) -[![PHP](https://img.shields.io/badge/php->=7.3,%20>=8.0,%20>=8.1,%20>=8.2,%20>=8.3-8892BF.svg)](https://packagist.org/packages/php-tmdb/api) +[![PHP](https://img.shields.io/badge/php->=8.1-8892BF.svg)](https://packagist.org/packages/php-tmdb/api) [![Total Downloads](https://poser.pugx.org/php-tmdb/api/downloads.svg)](https://packagist.org/packages/php-tmdb/api) Tests run with minimal, normal and development dependencies. diff --git a/composer.json b/composer.json index 2653abc7..5c443271 100644 --- a/composer.json +++ b/composer.json @@ -31,9 +31,8 @@ "license": "MIT", "name": "php-tmdb/api", "require": { - "php": "^7.3 || ^8.0", + "php": "^8.1", "ext-json": "*", - "symfony/options-resolver": "^4.4 || ^5 || ^6 || ^7", "psr/cache": "^1 || ^2 || ^3", "psr/simple-cache": "^1 || ^2 || ^3", "psr/event-dispatcher": "^1", @@ -51,8 +50,8 @@ "php-http/mock-client": "^1.2", "slevomat/coding-standard": "^8.8", "squizlabs/php_codesniffer": "^3.5.8", - "symfony/cache": "^4.4 || ^5 || ^6 || ^7", - "symfony/event-dispatcher": "^4.4 || ^5 || ^6 || ^7", + "symfony/cache": "^7.0", + "symfony/event-dispatcher": "^7.0", "phpstan/phpstan": "^1.8.1", "phpstan/phpstan-deprecation-rules": "^1.1", "spaze/phpstan-disallowed-calls": "^2.11", @@ -60,7 +59,8 @@ "php-http/guzzle7-adapter": "^1.0", "monolog/monolog": "^2.9.1 || ^3.0", "php-http/cache-plugin": "^1.7", - "jeroen/psr-log-test-doubles": "^2.1 || ^3" + "jeroen/psr-log-test-doubles": "^2.1 || ^3", + "symfony/options-resolver": "^7.0" }, "scripts": { "test": "vendor/bin/phpunit", From aa7295bf99272de510a2c33ed1666b10fc030060 Mon Sep 17 00:00:00 2001 From: Michael Roterman Date: Sun, 18 May 2025 16:07:24 +0200 Subject: [PATCH 06/14] Document PHP 7.4 and 8.0 EOL status in UPGRADE-CURRENT.md --- UPGRADE-CURRENT.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/UPGRADE-CURRENT.md b/UPGRADE-CURRENT.md index 68d23b18..784cd11b 100644 --- a/UPGRADE-CURRENT.md +++ b/UPGRADE-CURRENT.md @@ -3,4 +3,5 @@ ## Changes in this version - Removed `rtheunissen/guzzle-log-middleware` dependency due to compatibility issues with Guzzle 7.0. This middleware is temporarily removed and may be reintroduced in a future release once compatibility is resolved. -- Added support for Symfony 7 components. Note that Symfony 7 requires PHP 8.1 or higher. If you're using PHP < 8.1, Composer will automatically select a compatible Symfony version (4, 5, or 6). \ No newline at end of file +- Added support for Symfony 7 components. Note that Symfony 7 requires PHP 8.1 or higher. If you're using PHP < 8.1, Composer will automatically select a compatible Symfony version (4, 5, or 6). +- Dropped support for PHP 7.4 and 8.0 as they have reached End-of-Life (EOL). The minimum required PHP version is now 8.1. \ No newline at end of file From a9812598f52f249640f94b7845d39b9caac24b8a Mon Sep 17 00:00:00 2001 From: Michael Roterman Date: Sun, 18 May 2025 16:58:33 +0200 Subject: [PATCH 07/14] Update composer.json for Symfony 7 and PHPUnit 12 compatibility --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 5c443271..d140b3de 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "license": "MIT", "name": "php-tmdb/api", "require": { - "php": "^8.1", + "php": "^8.2", "ext-json": "*", "psr/cache": "^1 || ^2 || ^3", "psr/simple-cache": "^1 || ^2 || ^3", @@ -43,7 +43,8 @@ "psr/http-client-implementation": "^1", "psr/http-factory": "^1", "psr/http-factory-implementation": "^1", - "psr/http-message": "^1" + "psr/http-message": "^1", + "phpunit/phpunit": "^12.0" }, "require-dev": { "nyholm/psr7": "^1.2", @@ -55,7 +56,6 @@ "phpstan/phpstan": "^1.8.1", "phpstan/phpstan-deprecation-rules": "^1.1", "spaze/phpstan-disallowed-calls": "^2.11", - "phpunit/phpunit": "^9.6.3", "php-http/guzzle7-adapter": "^1.0", "monolog/monolog": "^2.9.1 || ^3.0", "php-http/cache-plugin": "^1.7", From 90f85200107752d464c4024e4652a08a1df26b0b Mon Sep 17 00:00:00 2001 From: Michael Roterman Date: Sun, 18 May 2025 16:58:50 +0200 Subject: [PATCH 08/14] Update GitHub workflow configurations for PHP 8.4 compatibility --- .github/workflows/coding-standards.yml | 2 +- .github/workflows/continuous-integration.yml | 16 ---------------- .github/workflows/static-analysis.yml | 1 - 3 files changed, 1 insertion(+), 18 deletions(-) diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 503a6588..ba8ca8f0 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -10,7 +10,7 @@ jobs: strategy: matrix: php-version: - - "8.1" + - "8.2" steps: - name: "Checkout" diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index b654b469..25b0b715 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -13,7 +13,6 @@ jobs: strategy: matrix: php-version: - - "8.1" - "8.2" - "8.3" deps: @@ -23,21 +22,6 @@ jobs: symfony-deprecations-helper: - "" include: - # PHP 8.1 test matrix - - php-version: "8.1" - deps: "normal" - - - php-version: "8.1" - deps: "low" - - - php-version: "8.1" - deps: "dev" - - # Test Symfony 6 with PHP 8.1 - - php-version: "8.1" - deps: "normal" - symfony-require: "6.4.*" - # PHP 8.2 test matrix - php-version: "8.2" deps: "normal" diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index a7eb6baf..13f9548f 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -10,7 +10,6 @@ jobs: strategy: matrix: php-version: - - "8.1" - "8.2" - "8.3" From 45a712e815179c2f0cc325a1c5a4245bd8ecc2df Mon Sep 17 00:00:00 2001 From: Michael Roterman Date: Sun, 18 May 2025 16:59:04 +0200 Subject: [PATCH 09/14] Update PHPUnit configuration schema to fix deprecation warning --- phpunit.xml.dist | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 7b2d6040..ade935db 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,13 +1,19 @@ - - - - lib - - + ./test/ + + + + + + + + + lib + + From 4ed3e8866e1edcffbbe7ccc0846705bdf12f0cca Mon Sep 17 00:00:00 2001 From: Michael Roterman Date: Sun, 18 May 2025 17:00:13 +0200 Subject: [PATCH 10/14] Fix: Add proper namespace to ObjectHydratorTest class for PHPUnit 12 compatibility --- test/Tmdb/Tests/Common/ObjectHydratorTest.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/test/Tmdb/Tests/Common/ObjectHydratorTest.php b/test/Tmdb/Tests/Common/ObjectHydratorTest.php index bb101172..c214e366 100644 --- a/test/Tmdb/Tests/Common/ObjectHydratorTest.php +++ b/test/Tmdb/Tests/Common/ObjectHydratorTest.php @@ -1,5 +1,8 @@ assertInstanceOf('TestModel', $subject); + $this->assertInstanceOf(TestModel::class, $subject); $this->assertEquals(15, $subject->getId()); $this->assertEquals('Michael', $subject->getName()); } - /** - * - * @test - */ + #[Test] public function callingNonExistingMethodThrowsException() { $this->expectException(\Tmdb\Exception\RuntimeException::class); From 7009f01ba11b1fe49c16fbd2c84473379713e4b4 Mon Sep 17 00:00:00 2001 From: Michael Roterman Date: Sun, 18 May 2025 17:03:18 +0200 Subject: [PATCH 11/14] Update for Symfony 7 and PHPUnit 12 compatibility --- README.md | 2 +- UPGRADE-CURRENT.md | 4 +- test/Tmdb/Tests/Api/AbstractApiTest.php | 26 ++--- test/Tmdb/Tests/Api/AccountTest.php | 42 +++++---- test/Tmdb/Tests/Api/AuthenticationTest.php | 14 +-- test/Tmdb/Tests/Api/CertificationsTest.php | 10 +- test/Tmdb/Tests/Api/ChangesTest.php | 14 +-- test/Tmdb/Tests/Api/CollectionsTest.php | 14 +-- test/Tmdb/Tests/Api/CompaniesTest.php | 10 +- test/Tmdb/Tests/Api/ConfigurationTest.php | 10 +- test/Tmdb/Tests/Api/CreditsTest.php | 6 +- test/Tmdb/Tests/Api/DiscoverTest.php | 10 +- test/Tmdb/Tests/Api/FindTest.php | 6 +- test/Tmdb/Tests/Api/GenresTest.php | 44 ++++----- test/Tmdb/Tests/Api/GuestSessionTest.php | 9 +- test/Tmdb/Tests/Api/JobsTest.php | 6 +- test/Tmdb/Tests/Api/KeywordsTest.php | 10 +- test/Tmdb/Tests/Api/ListsTest.php | 30 +++--- test/Tmdb/Tests/Api/MoviesTest.php | 90 +++++++++--------- test/Tmdb/Tests/Api/NetworksTest.php | 6 +- test/Tmdb/Tests/Api/PeopleTest.php | 42 +++++---- test/Tmdb/Tests/Api/ReviewsTest.php | 6 +- test/Tmdb/Tests/Api/SearchTest.php | 30 +++--- test/Tmdb/Tests/Api/TestCase.php | 6 +- test/Tmdb/Tests/Api/TimezonesTest.php | 6 +- test/Tmdb/Tests/Api/TvEpisodeTest.php | 38 ++++---- test/Tmdb/Tests/Api/TvSeasonTest.php | 26 ++--- test/Tmdb/Tests/Api/TvTest.php | 82 ++++++++-------- test/Tmdb/Tests/ClientTest.php | 22 +++-- .../Listener/AcceptJsonHeaderListenerTest.php | 6 +- .../Listener/AdultFilterListenerTest.php | 6 +- .../Event/Listener/ApiTokenListenerTest.php | 10 +- .../ContentTypeApplicationJsonTest.php | 6 +- .../Listener/LanguageFilterListenerTest.php | 6 +- .../Logger/LogApiErrorListenerTest.php | 6 +- .../Logger/LogHttpMessageListenerTest.php | 14 +-- .../Logger/LogHydrationListenerTest.php | 10 +- .../Psr6CachedRequestListenerTest.php | 14 +-- .../Listener/RegionFilterListenerTest.php | 6 +- .../Event/Listener/RequestListenerTest.php | 22 +++-- .../Listener/SessionTokenListenerTest.php | 18 ++-- .../Tests/Exception/TmdbApiExceptionTest.php | 6 +- .../Tmdb/Tests/Factory/AccountFactoryTest.php | 30 +++--- .../Factory/AuthenticationFactoryTest.php | 22 +++-- .../Factory/CertificationFactoryTest.php | 6 +- .../Tmdb/Tests/Factory/ChangesFactoryTest.php | 6 +- .../Tests/Factory/CollectionFactoryTest.php | 18 ++-- .../Tmdb/Tests/Factory/CompanyFactoryTest.php | 18 ++-- .../Factory/ConfigurationFactoryTest.php | 10 +- .../Tmdb/Tests/Factory/CreditsFactoryTest.php | 18 ++-- test/Tmdb/Tests/Factory/FindFactoryTest.php | 14 +-- test/Tmdb/Tests/Factory/GenreFactoryTest.php | 18 ++-- test/Tmdb/Tests/Factory/ImageFactoryTest.php | 47 +++++----- test/Tmdb/Tests/Factory/JobsFactoryTest.php | 30 +++--- .../Tmdb/Tests/Factory/KeywordFactoryTest.php | 6 +- test/Tmdb/Tests/Factory/ListFactoryTest.php | 30 +++--- .../Movie/AlternativeTitleFactoryTest.php | 10 +- test/Tmdb/Tests/Factory/MovieFactoryTest.php | 22 +++-- test/Tmdb/Tests/Factory/PeopleFactoryTest.php | 26 ++--- test/Tmdb/Tests/Factory/ReviewFactoryTest.php | 6 +- .../Tests/Factory/TimezoneFactoryTest.php | 6 +- .../Tests/Factory/TvEpisodeFactoryTest.php | 14 +-- test/Tmdb/Tests/Factory/TvFactoryTest.php | 19 ++-- .../Tests/Factory/TvSeasonFactoryTest.php | 14 +-- .../FullHttpMessageFormatterTest.php | 6 +- .../SimpleHttpMessageFormatterTest.php | 6 +- .../SimpleHydrationFormatterTest.php | 6 +- .../SimpleTmdbApiExceptionFormatterTest.php | 6 +- test/Tmdb/Tests/Helper/ImageHelperTest.php | 35 +++---- .../Tests/Helper/RequestQueryHelperTest.php | 6 +- test/Tmdb/Tests/HttpClient/HttpClientTest.php | 6 +- test/Tmdb/Tests/Model/ChangeTest.php | 6 +- .../Tests/Model/Collection/KeywordsTest.php | 6 +- .../Tests/Model/Collection/PeopleTest.php | 6 +- test/Tmdb/Tests/Model/Common/CountryTest.php | 6 +- .../Model/Common/GenericCollectionTest.php | 26 ++--- .../Tests/Model/Common/SpokenLanguageTest.php | 6 +- .../Model/Common/Trailer/YoutubeTest.php | 6 +- .../Tests/Model/Common/TranslationTest.php | 6 +- test/Tmdb/Tests/Model/ImageTest.php | 10 +- .../Tests/Model/Movie/ReleaseDateTest.php | 6 +- test/Tmdb/Tests/Model/Movie/ReleaseTest.php | 6 +- test/Tmdb/Tests/Model/MovieTest.php | 10 +- test/Tmdb/Tests/Model/NetworkTest.php | 6 +- .../Tests/Model/Person/CastMemberTest.php | 6 +- .../Tests/Model/Person/CrewMemberTest.php | 6 +- test/Tmdb/Tests/Model/PersonTest.php | 18 ++-- .../Tests/Model/Query/ChangesQueryTest.php | 6 +- .../Discover/DiscoverMoviesQueryTest.php | 14 +-- .../Query/Discover/DiscoverTvQueryTest.php | 6 +- test/Tmdb/Tests/Model/Tv/EpisodeTest.php | 10 +- test/Tmdb/Tests/Model/Tv/ExternalIdsTest.php | 6 +- test/Tmdb/Tests/Model/Tv/SeasonTest.php | 10 +- test/Tmdb/Tests/Model/TvTest.php | 6 +- test/Tmdb/Tests/Model/Watch/ProviderTest.php | 6 +- test/Tmdb/Tests/Model/Watch/ProvidersTest.php | 6 +- .../Repository/AccountRepositoryTest.php | 58 ++++++------ .../AuthenticationRepositoryTest.php | 10 +- .../CertificationRepositoryTest.php | 10 +- .../Repository/ChangesRepositoryTest.php | 14 +-- .../Repository/CollectionRepositoryTest.php | 18 ++-- .../Repository/CompanyRepositoryTest.php | 14 +-- .../ConfigurationRepositoryTest.php | 6 +- .../Repository/CreditsRepositoryTest.php | 6 +- .../Repository/DiscoverRepositoryTest.php | 15 ++- .../Tests/Repository/FindRepositoryTest.php | 6 +- .../Tests/Repository/GenreRepositoryTest.php | 26 ++--- .../Repository/GuestSessionRepositoryTest.php | 10 +- .../Tests/Repository/JobsRepositoryTest.php | 14 +-- .../Repository/KeywordRepositoryTest.php | 10 +- .../Tests/Repository/ListRepositoryTest.php | 30 +++--- .../Tests/Repository/MovieRepositoryTest.php | 94 ++++++++++--------- .../Repository/NetworkRepositoryTest.php | 6 +- .../Tests/Repository/PeopleRepositoryTest.php | 42 +++++---- .../Tests/Repository/ReviewRepositoryTest.php | 6 +- .../Tests/Repository/SearchRepositoryTest.php | 38 ++++---- .../Repository/TimezoneRepositoryTest.php | 6 +- .../Repository/TvEpisodeRepositoryTest.php | 50 +++++----- .../Tests/Repository/TvRepositoryTest.php | 74 ++++++++------- .../Repository/TvSeasonRepositoryTest.php | 34 +++---- test/Tmdb/Tests/Token/Api/ApiTokenTest.php | 10 +- .../Token/Session/GuestSessionTokenTest.php | 6 +- .../Tests/Token/Session/RequestTokenTest.php | 6 +- .../Tests/Token/Session/SessionTokenTest.php | 6 +- 124 files changed, 1137 insertions(+), 906 deletions(-) diff --git a/README.md b/README.md index fb0265f6..ed99390f 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Build Status](https://img.shields.io/github/actions/workflow/status/php-tmdb/api/continuous-integration.yml?label=phpunit)](https://github.com/php-tmdb/api/actions/workflows/continuous-integration.yml) [![Build Status](https://img.shields.io/github/actions/workflow/status/php-tmdb/api/coding-standards.yml?label=phpcs)](https://github.com/php-tmdb/api/actions/workflows/coding-standards.yml) [![codecov](https://img.shields.io/codecov/c/github/php-tmdb/api?token=gTM9AiO5vH)](https://codecov.io/gh/php-tmdb/api) -[![PHP](https://img.shields.io/badge/php->=8.1-8892BF.svg)](https://packagist.org/packages/php-tmdb/api) +[![PHP](https://img.shields.io/badge/php->=8.2-8892BF.svg)](https://packagist.org/packages/php-tmdb/api) [![Total Downloads](https://poser.pugx.org/php-tmdb/api/downloads.svg)](https://packagist.org/packages/php-tmdb/api) Tests run with minimal, normal and development dependencies. diff --git a/UPGRADE-CURRENT.md b/UPGRADE-CURRENT.md index 784cd11b..b84e4dda 100644 --- a/UPGRADE-CURRENT.md +++ b/UPGRADE-CURRENT.md @@ -4,4 +4,6 @@ - Removed `rtheunissen/guzzle-log-middleware` dependency due to compatibility issues with Guzzle 7.0. This middleware is temporarily removed and may be reintroduced in a future release once compatibility is resolved. - Added support for Symfony 7 components. Note that Symfony 7 requires PHP 8.1 or higher. If you're using PHP < 8.1, Composer will automatically select a compatible Symfony version (4, 5, or 6). -- Dropped support for PHP 7.4 and 8.0 as they have reached End-of-Life (EOL). The minimum required PHP version is now 8.1. \ No newline at end of file +- Dropped support for PHP 7.4 and 8.0 as they have reached End-of-Life (EOL). +- Dropped support for PHP 8.1 and updated minimum PHP version to 8.2 to accommodate PHPUnit 12. +- Upgraded PHPUnit from 9.x to 12.x. \ No newline at end of file diff --git a/test/Tmdb/Tests/Api/AbstractApiTest.php b/test/Tmdb/Tests/Api/AbstractApiTest.php index 2318e34e..70d3db74 100644 --- a/test/Tmdb/Tests/Api/AbstractApiTest.php +++ b/test/Tmdb/Tests/Api/AbstractApiTest.php @@ -14,13 +14,15 @@ namespace Tmdb\Tests\Api; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Api\AbstractApi; class AbstractApiTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldCallGet() { $api = $this->getApiWithMockedHttpAdapter(); @@ -30,8 +32,8 @@ public function shouldCallGet() } /** - * @test - */ + * */ + #[Test] public function shouldCallHead() { $api = $this->getApiWithMockedHttpAdapter(); @@ -41,8 +43,8 @@ public function shouldCallHead() } /** - * @test - */ + * */ + #[Test] public function shouldCallPost() { $api = $this->getApiWithMockedHttpAdapter(); @@ -52,8 +54,8 @@ public function shouldCallPost() } /** - * @test - */ + * */ + #[Test] public function shouldCallPut() { $api = $this->getApiWithMockedHttpAdapter(); @@ -63,8 +65,8 @@ public function shouldCallPut() } /** - * @test - */ + * */ + #[Test] public function shouldCallDelete() { $api = $this->getApiWithMockedHttpAdapter(); @@ -74,8 +76,8 @@ public function shouldCallDelete() } /** - * @test - */ + * */ + #[Test] public function shouldCallPatch() { $api = $this->getApiWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Api/AccountTest.php b/test/Tmdb/Tests/Api/AccountTest.php index 52063de5..db690403 100644 --- a/test/Tmdb/Tests/Api/AccountTest.php +++ b/test/Tmdb/Tests/Api/AccountTest.php @@ -14,14 +14,16 @@ namespace Tmdb\Tests\Api; +use PHPUnit\Framework\Attributes\Test; + class AccountTest extends TestCase { public const ACCOUNT_ID = 1; public const MEDIA_ID = 123; /** - * @test - */ + * */ + #[Test] public function shouldGetAccount() { $api = $this->getApiWithMockedHttpAdapter(); @@ -31,8 +33,8 @@ public function shouldGetAccount() } /** - * @test - */ + * */ + #[Test] public function shouldGetLists() { $api = $this->getApiWithMockedHttpAdapter(); @@ -42,8 +44,8 @@ public function shouldGetLists() } /** - * @test - */ + * */ + #[Test] public function shouldGetFavoriteMovies() { $api = $this->getApiWithMockedHttpAdapter(); @@ -53,8 +55,8 @@ public function shouldGetFavoriteMovies() } /** - * @test - */ + * */ + #[Test] public function shouldGetFavoriteTv() { $api = $this->getApiWithMockedHttpAdapter(); @@ -64,8 +66,8 @@ public function shouldGetFavoriteTv() } /** - * @test - */ + * */ + #[Test] public function shouldFavorite() { $api = $this->getApiWithMockedHttpAdapter(); @@ -82,8 +84,8 @@ public function shouldFavorite() } /** - * @test - */ + * */ + #[Test] public function shouldGetRatedMovies() { $api = $this->getApiWithMockedHttpAdapter(); @@ -93,8 +95,8 @@ public function shouldGetRatedMovies() } /** - * @test - */ + * */ + #[Test] public function shouldGetRatedTvShows() { $api = $this->getApiWithMockedHttpAdapter(); @@ -104,8 +106,8 @@ public function shouldGetRatedTvShows() } /** - * @test - */ + * */ + #[Test] public function shouldGetMovieWatchlist() { $api = $this->getApiWithMockedHttpAdapter(); @@ -115,8 +117,8 @@ public function shouldGetMovieWatchlist() } /** - * @test - */ + * */ + #[Test] public function shouldGetTvShowWatchlist() { $api = $this->getApiWithMockedHttpAdapter(); @@ -126,8 +128,8 @@ public function shouldGetTvShowWatchlist() } /** - * @test - */ + * */ + #[Test] public function shouldWatchlist() { $api = $this->getApiWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Api/AuthenticationTest.php b/test/Tmdb/Tests/Api/AuthenticationTest.php index 3fe9e09a..1992854b 100644 --- a/test/Tmdb/Tests/Api/AuthenticationTest.php +++ b/test/Tmdb/Tests/Api/AuthenticationTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Api; +use PHPUnit\Framework\Attributes\Test; + use InvalidArgumentException; use Tmdb\HttpClient\ResponseInterface; use Tmdb\Token\Session\RequestToken; @@ -21,8 +23,8 @@ class AuthenticationTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldGetNewToken() { $api = $this->getApiWithMockedHttpAdapter(); @@ -32,8 +34,8 @@ public function shouldGetNewToken() } /** - * @test - */ + * */ + #[Test] public function shouldGetNewSession() { $api = $this->getApiWithMockedHttpAdapter(); @@ -153,8 +155,8 @@ public function shouldThrowExceptionWhenNotValidated() } /** - * @test - */ + * */ + #[Test] public function shouldGetNewGuestSession() { $api = $this->getApiWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Api/CertificationsTest.php b/test/Tmdb/Tests/Api/CertificationsTest.php index 15238a88..ee34d294 100644 --- a/test/Tmdb/Tests/Api/CertificationsTest.php +++ b/test/Tmdb/Tests/Api/CertificationsTest.php @@ -14,11 +14,13 @@ namespace Tmdb\Tests\Api; +use PHPUnit\Framework\Attributes\Test; + class CertificationsTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldGetCertificationsListForMovies() { $api = $this->getApiWithMockedHttpAdapter(); @@ -28,8 +30,8 @@ public function shouldGetCertificationsListForMovies() } /** - * @test - */ + * */ + #[Test] public function shouldGetCertificationsListForTv() { $api = $this->getApiWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Api/ChangesTest.php b/test/Tmdb/Tests/Api/ChangesTest.php index 2cf89a3e..4eb047a3 100644 --- a/test/Tmdb/Tests/Api/ChangesTest.php +++ b/test/Tmdb/Tests/Api/ChangesTest.php @@ -14,11 +14,13 @@ namespace Tmdb\Tests\Api; +use PHPUnit\Framework\Attributes\Test; + class ChangesTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldGetMovieChanges() { $api = $this->getApiWithMockedHttpAdapter(); @@ -28,8 +30,8 @@ public function shouldGetMovieChanges() } /** - * @test - */ + * */ + #[Test] public function shouldGetPersonChanges() { $api = $this->getApiWithMockedHttpAdapter(); @@ -39,8 +41,8 @@ public function shouldGetPersonChanges() } /** - * @test - */ + * */ + #[Test] public function shouldGetTvChanges() { $api = $this->getApiWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Api/CollectionsTest.php b/test/Tmdb/Tests/Api/CollectionsTest.php index b93abbed..4400e523 100644 --- a/test/Tmdb/Tests/Api/CollectionsTest.php +++ b/test/Tmdb/Tests/Api/CollectionsTest.php @@ -14,13 +14,15 @@ namespace Tmdb\Tests\Api; +use PHPUnit\Framework\Attributes\Test; + class CollectionsTest extends TestCase { public const COLLECTION_ID = 120; /** - * @test - */ + * */ + #[Test] public function shouldGetCollection() { $api = $this->getApiWithMockedHttpAdapter(); @@ -30,8 +32,8 @@ public function shouldGetCollection() } /** - * @test - */ + * */ + #[Test] public function shouldGetImages() { $api = $this->getApiWithMockedHttpAdapter(); @@ -41,8 +43,8 @@ public function shouldGetImages() } /** - * @test - */ + * */ + #[Test] public function shouldGetTranslations() { $api = $this->getApiWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Api/CompaniesTest.php b/test/Tmdb/Tests/Api/CompaniesTest.php index 76715a30..a6869811 100644 --- a/test/Tmdb/Tests/Api/CompaniesTest.php +++ b/test/Tmdb/Tests/Api/CompaniesTest.php @@ -14,13 +14,15 @@ namespace Tmdb\Tests\Api; +use PHPUnit\Framework\Attributes\Test; + class CompaniesTest extends TestCase { public const COMPANY_ID = 1; /** - * @test - */ + * */ + #[Test] public function shouldGetCompany() { $api = $this->getApiWithMockedHttpAdapter(); @@ -30,8 +32,8 @@ public function shouldGetCompany() } /** - * @test - */ + * */ + #[Test] public function shouldGetMovies() { $api = $this->getApiWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Api/ConfigurationTest.php b/test/Tmdb/Tests/Api/ConfigurationTest.php index ade094e1..2c915819 100644 --- a/test/Tmdb/Tests/Api/ConfigurationTest.php +++ b/test/Tmdb/Tests/Api/ConfigurationTest.php @@ -14,11 +14,13 @@ namespace Tmdb\Tests\Api; +use PHPUnit\Framework\Attributes\Test; + class ConfigurationTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldGetConfiguration() { $api = $this->getApiWithMockedHttpAdapter(); @@ -28,8 +30,8 @@ public function shouldGetConfiguration() } /** - * @test - */ + * */ + #[Test] public function shouldGetLanguages() { $api = $this->getApiWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Api/CreditsTest.php b/test/Tmdb/Tests/Api/CreditsTest.php index e9e58b35..e6507441 100644 --- a/test/Tmdb/Tests/Api/CreditsTest.php +++ b/test/Tmdb/Tests/Api/CreditsTest.php @@ -14,13 +14,15 @@ namespace Tmdb\Tests\Api; +use PHPUnit\Framework\Attributes\Test; + class CreditsTest extends TestCase { public const CREDIT_ID = '5240760b5dbf5b0c2c0139db'; /** - * @test - */ + * */ + #[Test] public function shouldGetCredit() { $api = $this->getApiWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Api/DiscoverTest.php b/test/Tmdb/Tests/Api/DiscoverTest.php index 26f37c5e..bcfca9f0 100644 --- a/test/Tmdb/Tests/Api/DiscoverTest.php +++ b/test/Tmdb/Tests/Api/DiscoverTest.php @@ -14,11 +14,13 @@ namespace Tmdb\Tests\Api; +use PHPUnit\Framework\Attributes\Test; + class DiscoverTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldDiscoverMovies() { $api = $this->getApiWithMockedHttpAdapter(); @@ -28,8 +30,8 @@ public function shouldDiscoverMovies() } /** - * @test - */ + * */ + #[Test] public function shouldDiscoverTv() { $api = $this->getApiWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Api/FindTest.php b/test/Tmdb/Tests/Api/FindTest.php index a5de064a..762b7446 100644 --- a/test/Tmdb/Tests/Api/FindTest.php +++ b/test/Tmdb/Tests/Api/FindTest.php @@ -14,11 +14,13 @@ namespace Tmdb\Tests\Api; +use PHPUnit\Framework\Attributes\Test; + class FindTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldFind() { $api = $this->getApiWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Api/GenresTest.php b/test/Tmdb/Tests/Api/GenresTest.php index 535d7251..68b7a40e 100644 --- a/test/Tmdb/Tests/Api/GenresTest.php +++ b/test/Tmdb/Tests/Api/GenresTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Api; +use PHPUnit\Framework\Attributes\Test; + use Psr\Http\Message\RequestInterface; class GenresTest extends TestCase @@ -21,8 +23,8 @@ class GenresTest extends TestCase public const GENRE_ID = 28; /** - * @test - */ + * */ + #[Test] public function shouldGetGenre() { $api = $this->getApiWithMockedHttpAdapter(); @@ -41,8 +43,8 @@ public function shouldGetGenre() } /** - * @test - */ + * */ + #[Test] public function shouldGetGenres() { $api = $this->getApiWithMockedHttpAdapter(); @@ -62,8 +64,8 @@ public function shouldGetGenres() } /** - * @test - */ + * */ + #[Test] public function shouldGetMovieGenres() { $api = $this->getApiWithMockedHttpAdapter(); @@ -73,8 +75,8 @@ public function shouldGetMovieGenres() } /** - * @test - */ + * */ + #[Test] public function shouldGetTvGenres() { $api = $this->getApiWithMockedHttpAdapter(); @@ -84,8 +86,8 @@ public function shouldGetTvGenres() } /** - * @test - */ + * */ + #[Test] public function shouldGetMovies() { $api = $this->getApiWithMockedHttpAdapter(); @@ -95,21 +97,16 @@ public function shouldGetMovies() } /** - * @test + * Test getting a single genre */ + #[Test] public function shouldGetGenreAndReturnOne() { $api = $this->getMockedApi(['getGenres']); $api->expects($this->once()) ->method('getGenres') - ->will( - $this->returnCallback( - function () { - return ['genres' => [['id' => 28, 'name' => 'Action']]]; - } - ) - ); + ->willReturn(['genres' => [['id' => 28, 'name' => 'Action']]]); $genre = $api->getGenre(self::GENRE_ID); @@ -118,21 +115,16 @@ function () { } /** - * @test + * Test returning null when no genre is found */ + #[Test] public function shouldReturnNullWithNoData() { $api = $this->getMockedApi(['getGenres']); $api->expects($this->once()) ->method('getGenres') - ->will( - $this->returnCallback( - function () { - return ['genres' => []]; - } - ) - ); + ->willReturn(['genres' => []]); $genre = $api->getGenre(self::GENRE_ID); diff --git a/test/Tmdb/Tests/Api/GuestSessionTest.php b/test/Tmdb/Tests/Api/GuestSessionTest.php index 399d1197..7adc7b28 100644 --- a/test/Tmdb/Tests/Api/GuestSessionTest.php +++ b/test/Tmdb/Tests/Api/GuestSessionTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Api; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Api\GuestSession; use Tmdb\Exception\MissingSessionTokenException; use Tmdb\Token\Session\GuestSessionToken; @@ -21,9 +23,9 @@ class GuestSessionTest extends TestCase { /** - * @test - * + * Test that exception is thrown when no session token is provided */ + #[Test] public function shouldThrowExceptionGettingRatedMoviesWithNoSessionToken() { $this->expectException(MissingSessionTokenException::class); @@ -33,8 +35,9 @@ public function shouldThrowExceptionGettingRatedMoviesWithNoSessionToken() } /** - * @test + * Test getting rated movies */ + #[Test] public function shouldGetRatedMovies() { $sessionToken = new GuestSessionToken('xyz'); diff --git a/test/Tmdb/Tests/Api/JobsTest.php b/test/Tmdb/Tests/Api/JobsTest.php index 8057276a..56876fe0 100644 --- a/test/Tmdb/Tests/Api/JobsTest.php +++ b/test/Tmdb/Tests/Api/JobsTest.php @@ -14,11 +14,13 @@ namespace Tmdb\Tests\Api; +use PHPUnit\Framework\Attributes\Test; + class JobsTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldGetList() { $api = $this->getApiWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Api/KeywordsTest.php b/test/Tmdb/Tests/Api/KeywordsTest.php index de452df8..c211a122 100644 --- a/test/Tmdb/Tests/Api/KeywordsTest.php +++ b/test/Tmdb/Tests/Api/KeywordsTest.php @@ -14,13 +14,15 @@ namespace Tmdb\Tests\Api; +use PHPUnit\Framework\Attributes\Test; + class KeywordsTest extends TestCase { public const KEYWORD_ID = 1712; /** - * @test - */ + * */ + #[Test] public function shouldGetKeyword() { $api = $this->getApiWithMockedHttpAdapter(); @@ -30,8 +32,8 @@ public function shouldGetKeyword() } /** - * @test - */ + * */ + #[Test] public function shouldGetMovies() { $api = $this->getApiWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Api/ListsTest.php b/test/Tmdb/Tests/Api/ListsTest.php index 95af61ea..7298c4f8 100644 --- a/test/Tmdb/Tests/Api/ListsTest.php +++ b/test/Tmdb/Tests/Api/ListsTest.php @@ -14,14 +14,16 @@ namespace Tmdb\Tests\Api; +use PHPUnit\Framework\Attributes\Test; + class ListsTest extends TestCase { public const LIST_ID = '509ec17b19c2950a0600050d'; public const MOVIE_ID = 150; /** - * @test - */ + * */ + #[Test] public function shouldGetList() { $api = $this->getApiWithMockedHttpAdapter(); @@ -31,8 +33,8 @@ public function shouldGetList() } /** - * @test - */ + * */ + #[Test] public function shouldCreateList() { $api = $this->getApiWithMockedHttpAdapter(); @@ -48,8 +50,8 @@ public function shouldCreateList() } /** - * @test - */ + * */ + #[Test] public function shouldGetItemStatus() { $api = $this->getApiWithMockedHttpAdapter(); @@ -60,8 +62,8 @@ public function shouldGetItemStatus() } /** - * @test - */ + * */ + #[Test] public function shouldAddMediaToList() { $api = $this->getApiWithMockedHttpAdapter(); @@ -76,8 +78,8 @@ public function shouldAddMediaToList() } /** - * @test - */ + * */ + #[Test] public function shouldRemoveMediaFromList() { $api = $this->getApiWithMockedHttpAdapter(); @@ -92,8 +94,8 @@ public function shouldRemoveMediaFromList() } /** - * @test - */ + * */ + #[Test] public function shouldDeleteList() { $api = $this->getApiWithMockedHttpAdapter(); @@ -103,8 +105,8 @@ public function shouldDeleteList() } /** - * @test - */ + * */ + #[Test] public function shouldClearList() { $api = $this->getApiWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Api/MoviesTest.php b/test/Tmdb/Tests/Api/MoviesTest.php index b133cc6e..bc75ce90 100644 --- a/test/Tmdb/Tests/Api/MoviesTest.php +++ b/test/Tmdb/Tests/Api/MoviesTest.php @@ -14,13 +14,15 @@ namespace Tmdb\Tests\Api; +use PHPUnit\Framework\Attributes\Test; + class MoviesTest extends TestCase { public const MOVIE_ID = 120; /** - * @test - */ + * */ + #[Test] public function shouldGetMovie() { $api = $this->getApiWithMockedHttpAdapter(); @@ -30,8 +32,8 @@ public function shouldGetMovie() } /** - * @test - */ + * */ + #[Test] public function shouldGetAlternativeTitles() { $api = $this->getApiWithMockedHttpAdapter(); @@ -41,8 +43,8 @@ public function shouldGetAlternativeTitles() } /** - * @test - */ + * */ + #[Test] public function shouldGetExternalIds() { $api = $this->getApiWithMockedHttpAdapter(); @@ -52,8 +54,8 @@ public function shouldGetExternalIds() } /** - * @test - */ + * */ + #[Test] public function shouldGetCast() { $api = $this->getApiWithMockedHttpAdapter(); @@ -63,8 +65,8 @@ public function shouldGetCast() } /** - * @test - */ + * */ + #[Test] public function shouldGetImages() { $api = $this->getApiWithMockedHttpAdapter(); @@ -74,8 +76,8 @@ public function shouldGetImages() } /** - * @test - */ + * */ + #[Test] public function shouldGetKeywords() { $api = $this->getApiWithMockedHttpAdapter(); @@ -85,8 +87,8 @@ public function shouldGetKeywords() } /** - * @test - */ + * */ + #[Test] public function getReleases() { $api = $this->getApiWithMockedHttpAdapter(); @@ -96,8 +98,8 @@ public function getReleases() } /** - * @test - */ + * */ + #[Test] public function shouldGetTranslations() { $api = $this->getApiWithMockedHttpAdapter(); @@ -107,8 +109,8 @@ public function shouldGetTranslations() } /** - * @test - */ + * */ + #[Test] public function shouldGetSimilarMovies() { $api = $this->getApiWithMockedHttpAdapter(); @@ -118,8 +120,8 @@ public function shouldGetSimilarMovies() } /** - * @test - */ + * */ + #[Test] public function shouldGetRecommendedMovies() { $api = $this->getApiWithMockedHttpAdapter(); @@ -129,8 +131,8 @@ public function shouldGetRecommendedMovies() } /** - * @test - */ + * */ + #[Test] public function shouldGetReviews() { $api = $this->getApiWithMockedHttpAdapter(); @@ -140,8 +142,8 @@ public function shouldGetReviews() } /** - * @test - */ + * */ + #[Test] public function shouldGetLists() { $api = $this->getApiWithMockedHttpAdapter(); @@ -151,8 +153,8 @@ public function shouldGetLists() } /** - * @test - */ + * */ + #[Test] public function shouldGetChanges() { $api = $this->getApiWithMockedHttpAdapter(); @@ -162,8 +164,8 @@ public function shouldGetChanges() } /** - * @test - */ + * */ + #[Test] public function shouldGetLatest() { $api = $this->getApiWithMockedHttpAdapter(); @@ -173,8 +175,8 @@ public function shouldGetLatest() } /** - * @test - */ + * */ + #[Test] public function shouldGetUpcoming() { $api = $this->getApiWithMockedHttpAdapter(); @@ -184,8 +186,8 @@ public function shouldGetUpcoming() } /** - * @test - */ + * */ + #[Test] public function shouldGetNowPlaying() { $api = $this->getApiWithMockedHttpAdapter(); @@ -195,8 +197,8 @@ public function shouldGetNowPlaying() } /** - * @test - */ + * */ + #[Test] public function shouldGetPopular() { $api = $this->getApiWithMockedHttpAdapter(); @@ -206,8 +208,8 @@ public function shouldGetPopular() } /** - * @test - */ + * */ + #[Test] public function shouldGetTopRated() { $api = $this->getApiWithMockedHttpAdapter(); @@ -217,8 +219,8 @@ public function shouldGetTopRated() } /** - * @test - */ + * */ + #[Test] public function shouldGetAccountStates() { $api = $this->getApiWithMockedHttpAdapter(); @@ -228,8 +230,8 @@ public function shouldGetAccountStates() } /** - * @test - */ + * */ + #[Test] public function shouldRateMovie() { $api = $this->getApiWithMockedHttpAdapter(); @@ -244,8 +246,8 @@ public function shouldRateMovie() } /** - * @test - */ + * */ + #[Test] public function shouldGetVideos() { $api = $this->getApiWithMockedHttpAdapter(); @@ -255,8 +257,8 @@ public function shouldGetVideos() } /** - * @test - */ + * */ + #[Test] public function shouldGetWatchProviders() { $api = $this->getApiWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Api/NetworksTest.php b/test/Tmdb/Tests/Api/NetworksTest.php index 836b962e..92fede73 100644 --- a/test/Tmdb/Tests/Api/NetworksTest.php +++ b/test/Tmdb/Tests/Api/NetworksTest.php @@ -14,13 +14,15 @@ namespace Tmdb\Tests\Api; +use PHPUnit\Framework\Attributes\Test; + class NetworksTest extends TestCase { public const NETWORK_ID = 49; /** - * @test - */ + * */ + #[Test] public function shouldGetCredit() { $api = $this->getApiWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Api/PeopleTest.php b/test/Tmdb/Tests/Api/PeopleTest.php index 9a369d16..ad2c20e4 100644 --- a/test/Tmdb/Tests/Api/PeopleTest.php +++ b/test/Tmdb/Tests/Api/PeopleTest.php @@ -14,13 +14,15 @@ namespace Tmdb\Tests\Api; +use PHPUnit\Framework\Attributes\Test; + class PeopleTest extends TestCase { public const PERSON_ID = 287; /** - * @test - */ + * */ + #[Test] public function shouldGetPerson() { $api = $this->getApiWithMockedHttpAdapter(); @@ -30,8 +32,8 @@ public function shouldGetPerson() } /** - * @test - */ + * */ + #[Test] public function shouldGetCredits() { $api = $this->getApiWithMockedHttpAdapter(); @@ -41,8 +43,8 @@ public function shouldGetCredits() } /** - * @test - */ + * */ + #[Test] public function shouldGetMovieCredits() { $api = $this->getApiWithMockedHttpAdapter(); @@ -52,8 +54,8 @@ public function shouldGetMovieCredits() } /** - * @test - */ + * */ + #[Test] public function shouldGetTvCredits() { $api = $this->getApiWithMockedHttpAdapter(); @@ -63,8 +65,8 @@ public function shouldGetTvCredits() } /** - * @test - */ + * */ + #[Test] public function shouldGetImages() { $api = $this->getApiWithMockedHttpAdapter(); @@ -74,8 +76,8 @@ public function shouldGetImages() } /** - * @test - */ + * */ + #[Test] public function shouldGetChanges() { $api = $this->getApiWithMockedHttpAdapter(); @@ -85,8 +87,8 @@ public function shouldGetChanges() } /** - * @test - */ + * */ + #[Test] public function shouldGetExternalIds() { $api = $this->getApiWithMockedHttpAdapter(); @@ -96,8 +98,8 @@ public function shouldGetExternalIds() } /** - * @test - */ + * */ + #[Test] public function shouldGetPopular() { $api = $this->getApiWithMockedHttpAdapter(); @@ -107,8 +109,8 @@ public function shouldGetPopular() } /** - * @test - */ + * */ + #[Test] public function shouldGetLatest() { $api = $this->getApiWithMockedHttpAdapter(); @@ -118,8 +120,8 @@ public function shouldGetLatest() } /** - * @test - */ + * */ + #[Test] public function shouldGetTaggedImages() { $api = $this->getApiWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Api/ReviewsTest.php b/test/Tmdb/Tests/Api/ReviewsTest.php index 6af2eb14..410b808e 100644 --- a/test/Tmdb/Tests/Api/ReviewsTest.php +++ b/test/Tmdb/Tests/Api/ReviewsTest.php @@ -14,13 +14,15 @@ namespace Tmdb\Tests\Api; +use PHPUnit\Framework\Attributes\Test; + class ReviewsTest extends TestCase { public const REVIEW_ID = '5013bc76760ee372cb00253e'; /** - * @test - */ + * */ + #[Test] public function shouldGetReview() { $api = $this->getApiWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Api/SearchTest.php b/test/Tmdb/Tests/Api/SearchTest.php index d637c506..39236ba3 100644 --- a/test/Tmdb/Tests/Api/SearchTest.php +++ b/test/Tmdb/Tests/Api/SearchTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Api; +use PHPUnit\Framework\Attributes\Test; + class SearchTest extends TestCase { public const QUERY_MOVIE = 'resident evil'; @@ -24,8 +26,8 @@ class SearchTest extends TestCase public const QUERY_KEYWORD = 'horror'; /** - * @test - */ + * */ + #[Test] public function shouldSearchMovies() { $api = $this->getApiWithMockedHttpAdapter(); @@ -40,8 +42,8 @@ public function shouldSearchMovies() } /** - * @test - */ + * */ + #[Test] public function shouldSearchCollection() { $api = $this->getApiWithMockedHttpAdapter(); @@ -56,8 +58,8 @@ public function shouldSearchCollection() } /** - * @test - */ + * */ + #[Test] public function shouldSearchTv() { $api = $this->getApiWithMockedHttpAdapter(); @@ -72,8 +74,8 @@ public function shouldSearchTv() } /** - * @test - */ + * */ + #[Test] public function shouldPersonCollection() { $api = $this->getApiWithMockedHttpAdapter(); @@ -88,8 +90,8 @@ public function shouldPersonCollection() } /** - * @test - */ + * */ + #[Test] public function shouldSearchCompany() { $api = $this->getApiWithMockedHttpAdapter(); @@ -104,8 +106,8 @@ public function shouldSearchCompany() } /** - * @test - */ + * */ + #[Test] public function shouldSearchKeyword() { $api = $this->getApiWithMockedHttpAdapter(); @@ -120,8 +122,8 @@ public function shouldSearchKeyword() } /** - * @test - */ + * */ + #[Test] public function shouldSearchMulti() { $api = $this->getApiWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Api/TestCase.php b/test/Tmdb/Tests/Api/TestCase.php index d7f963b7..906e0226 100644 --- a/test/Tmdb/Tests/Api/TestCase.php +++ b/test/Tmdb/Tests/Api/TestCase.php @@ -14,7 +14,7 @@ namespace Tmdb\Tests\Api; -use PHPUnit_Framework_MockObject_MockObject; +use PHPUnit\Framework\MockObject\MockObject; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestInterface; use Tmdb\Token\Api\ApiToken; @@ -56,7 +56,7 @@ abstract protected function getApiClass(); * @param array $methods * @param array $clientMethods * @param GuestSessionToken|null $sessionToken - * @return PHPUnit_Framework_MockObject_MockObject + * @return MockObject */ protected function getMockedApi(array $methods = [], array $clientMethods = [], $guestSessionToken = null) { @@ -67,7 +67,7 @@ protected function getMockedApi(array $methods = [], array $clientMethods = [], } return $this->_api = $this->getMockBuilder($this->getApiClass()) - ->setMethods($methods) + ->onlyMethods($methods) ->setConstructorArgs([$this->_client]) ->getMock(); } diff --git a/test/Tmdb/Tests/Api/TimezonesTest.php b/test/Tmdb/Tests/Api/TimezonesTest.php index f318a3fc..c4c535bc 100644 --- a/test/Tmdb/Tests/Api/TimezonesTest.php +++ b/test/Tmdb/Tests/Api/TimezonesTest.php @@ -14,11 +14,13 @@ namespace Tmdb\Tests\Api; +use PHPUnit\Framework\Attributes\Test; + class TimezonesTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldGetTimezones() { $api = $this->getApiWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Api/TvEpisodeTest.php b/test/Tmdb/Tests/Api/TvEpisodeTest.php index b0cdb643..3b932365 100644 --- a/test/Tmdb/Tests/Api/TvEpisodeTest.php +++ b/test/Tmdb/Tests/Api/TvEpisodeTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Api; +use PHPUnit\Framework\Attributes\Test; + class TvEpisodeTest extends TestCase { public const TV_ID = 3572; @@ -21,8 +23,8 @@ class TvEpisodeTest extends TestCase public const EPISODE_ID = 1; /** - * @test - */ + * */ + #[Test] public function shouldGetEpisode() { $api = $this->getApiWithMockedHttpAdapter(); @@ -34,8 +36,8 @@ public function shouldGetEpisode() } /** - * @test - */ + * */ + #[Test] public function shouldGetEpisodeCredits() { $api = $this->getApiWithMockedHttpAdapter(); @@ -47,8 +49,8 @@ public function shouldGetEpisodeCredits() } /** - * @test - */ + * */ + #[Test] public function shouldGetEpisodeExternalIds() { $api = $this->getApiWithMockedHttpAdapter(); @@ -60,8 +62,8 @@ public function shouldGetEpisodeExternalIds() } /** - * @test - */ + * */ + #[Test] public function shouldGetEpisodeImages() { $api = $this->getApiWithMockedHttpAdapter(); @@ -73,8 +75,8 @@ public function shouldGetEpisodeImages() } /** - * @test - */ + * */ + #[Test] public function shouldGetEpisodeVideos() { $api = $this->getApiWithMockedHttpAdapter(); @@ -86,8 +88,8 @@ public function shouldGetEpisodeVideos() } /** - * @test - */ + * */ + #[Test] public function shouldGetEpisodeChanges() { $api = $this->getApiWithMockedHttpAdapter(); @@ -99,8 +101,8 @@ public function shouldGetEpisodeChanges() } /** - * @test - */ + * */ + #[Test] public function shouldGetEpisodeAccountStates() { $api = $this->getApiWithMockedHttpAdapter(); @@ -112,8 +114,8 @@ public function shouldGetEpisodeAccountStates() } /** - * @test - */ + * */ + #[Test] public function shouldGetEpisodeTranslations() { $api = $this->getApiWithMockedHttpAdapter(); @@ -125,8 +127,8 @@ public function shouldGetEpisodeTranslations() } /** - * @test - */ + * */ + #[Test] public function shouldRateTvEpisode() { $api = $this->getApiWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Api/TvSeasonTest.php b/test/Tmdb/Tests/Api/TvSeasonTest.php index 330809dd..8e92ffd6 100644 --- a/test/Tmdb/Tests/Api/TvSeasonTest.php +++ b/test/Tmdb/Tests/Api/TvSeasonTest.php @@ -14,14 +14,16 @@ namespace Tmdb\Tests\Api; +use PHPUnit\Framework\Attributes\Test; + class TvSeasonTest extends TestCase { public const TV_ID = 3572; public const SEASON_ID = 1; /** - * @test - */ + * */ + #[Test] public function shouldGetSeason() { $api = $this->getApiWithMockedHttpAdapter(); @@ -31,8 +33,8 @@ public function shouldGetSeason() } /** - * @test - */ + * */ + #[Test] public function shouldGetSeasonCredits() { $api = $this->getApiWithMockedHttpAdapter(); @@ -42,8 +44,8 @@ public function shouldGetSeasonCredits() } /** - * @test - */ + * */ + #[Test] public function shouldGetSeasonExternalIds() { $api = $this->getApiWithMockedHttpAdapter(); @@ -55,8 +57,8 @@ public function shouldGetSeasonExternalIds() } /** - * @test - */ + * */ + #[Test] public function shouldGetSeasonImages() { $api = $this->getApiWithMockedHttpAdapter(); @@ -66,8 +68,8 @@ public function shouldGetSeasonImages() } /** - * @test - */ + * */ + #[Test] public function shouldGetSeasonVideos() { $api = $this->getApiWithMockedHttpAdapter(); @@ -77,8 +79,8 @@ public function shouldGetSeasonVideos() } /** - * @test - */ + * */ + #[Test] public function shouldGetSeasonChanges() { $api = $this->getApiWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Api/TvTest.php b/test/Tmdb/Tests/Api/TvTest.php index 72ccb161..ea0704e4 100644 --- a/test/Tmdb/Tests/Api/TvTest.php +++ b/test/Tmdb/Tests/Api/TvTest.php @@ -14,13 +14,15 @@ namespace Tmdb\Tests\Api; +use PHPUnit\Framework\Attributes\Test; + class TvTest extends TestCase { public const TV_ID = 3572; /** - * @test - */ + * */ + #[Test] public function shouldGetTvshow() { $api = $this->getApiWithMockedHttpAdapter(); @@ -30,8 +32,8 @@ public function shouldGetTvshow() } /** - * @test - */ + * */ + #[Test] public function shouldGetCredits() { $api = $this->getApiWithMockedHttpAdapter(); @@ -41,8 +43,8 @@ public function shouldGetCredits() } /** - * @test - */ + * */ + #[Test] public function getExternalIds() { $api = $this->getApiWithMockedHttpAdapter(); @@ -52,8 +54,8 @@ public function getExternalIds() } /** - * @test - */ + * */ + #[Test] public function shouldGetImages() { $api = $this->getApiWithMockedHttpAdapter(); @@ -63,8 +65,8 @@ public function shouldGetImages() } /** - * @test - */ + * */ + #[Test] public function shouldGetTranslations() { $api = $this->getApiWithMockedHttpAdapter(); @@ -74,8 +76,8 @@ public function shouldGetTranslations() } /** - * @test - */ + * */ + #[Test] public function shouldGetPopular() { $api = $this->getApiWithMockedHttpAdapter(); @@ -85,8 +87,8 @@ public function shouldGetPopular() } /** - * @test - */ + * */ + #[Test] public function shouldGetTopRated() { $api = $this->getApiWithMockedHttpAdapter(); @@ -96,8 +98,8 @@ public function shouldGetTopRated() } /** - * @test - */ + * */ + #[Test] public function shouldGetOnTheAir() { $api = $this->getApiWithMockedHttpAdapter(); @@ -107,8 +109,8 @@ public function shouldGetOnTheAir() } /** - * @test - */ + * */ + #[Test] public function shouldGetAiringToday() { $api = $this->getApiWithMockedHttpAdapter(); @@ -118,8 +120,8 @@ public function shouldGetAiringToday() } /** - * @test - */ + * */ + #[Test] public function shouldGetVideos() { $api = $this->getApiWithMockedHttpAdapter(); @@ -129,8 +131,8 @@ public function shouldGetVideos() } /** - * @test - */ + * */ + #[Test] public function shouldGetChanges() { $api = $this->getApiWithMockedHttpAdapter(); @@ -140,8 +142,8 @@ public function shouldGetChanges() } /** - * @test - */ + * */ + #[Test] public function shouldGetKeywords() { $api = $this->getApiWithMockedHttpAdapter(); @@ -151,8 +153,8 @@ public function shouldGetKeywords() } /** - * @test - */ + * */ + #[Test] public function shouldGetSimilar() { $api = $this->getApiWithMockedHttpAdapter(); @@ -162,8 +164,8 @@ public function shouldGetSimilar() } /** - * @test - */ + * */ + #[Test] public function shouldGetRecommended() { $api = $this->getApiWithMockedHttpAdapter(); @@ -173,8 +175,8 @@ public function shouldGetRecommended() } /** - * @test - */ + * */ + #[Test] public function shouldRateTvEpisode() { $api = $this->getApiWithMockedHttpAdapter(); @@ -189,8 +191,8 @@ public function shouldRateTvEpisode() } /** - * @test - */ + * */ + #[Test] public function shouldGetLatest() { $api = $this->getApiWithMockedHttpAdapter(); @@ -200,8 +202,8 @@ public function shouldGetLatest() } /** - * @test - */ + * */ + #[Test] public function shouldGetAccountStates() { $api = $this->getApiWithMockedHttpAdapter(); @@ -211,8 +213,8 @@ public function shouldGetAccountStates() } /** - * @test - */ + * */ + #[Test] public function shouldGetContentRatings() { $api = $this->getApiWithMockedHttpAdapter(); @@ -222,8 +224,8 @@ public function shouldGetContentRatings() } /** - * @test - */ + * */ + #[Test] public function shouldGetWatchProviders() { $api = $this->getApiWithMockedHttpAdapter(); @@ -233,8 +235,8 @@ public function shouldGetWatchProviders() } /** - * @test - */ + * */ + #[Test] public function shouldGetEpisodeGroups() { $api = $this->getApiWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/ClientTest.php b/test/Tmdb/Tests/ClientTest.php index c88914cf..264d1b5c 100644 --- a/test/Tmdb/Tests/ClientTest.php +++ b/test/Tmdb/Tests/ClientTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests; +use PHPUnit\Framework\Attributes\Test; + use Symfony\Component\EventDispatcher\EventDispatcher; use Tmdb\Client; use Tmdb\Token\Api\ApiToken; @@ -50,16 +52,16 @@ public function setUp(): void } /** - * @test - */ + * */ + #[Test] public function shouldNotHaveToPassHttpClientToConstructor() { $this->assertInstanceOf('Tmdb\HttpClient\HttpClient', $this->client->getHttpClient()); } /** - * @test - */ + * */ + #[Test] public function shouldContainGuestSessionToken() { $this->assertInstanceOf('Tmdb\Token\Session\GuestSessionToken', $this->client->getGuestSessionToken()); @@ -67,8 +69,8 @@ public function shouldContainGuestSessionToken() } /** - * @test - */ + * */ + #[Test] public function assertInstances() { $this->assertInstancesOf( @@ -103,8 +105,8 @@ public function assertInstances() } /** - * @test - */ + * */ + #[Test] public function shouldRespectSecureClientOption() { $client = new Client( @@ -162,8 +164,8 @@ public function testShouldSwitchHttpScheme() } /** - * @test - */ + * */ + #[Test] public function shouldBeAbleGetOption() { $token = $this->client->getOption('api_token'); diff --git a/test/Tmdb/Tests/Event/Listener/AcceptJsonHeaderListenerTest.php b/test/Tmdb/Tests/Event/Listener/AcceptJsonHeaderListenerTest.php index 1023560a..547287c4 100644 --- a/test/Tmdb/Tests/Event/Listener/AcceptJsonHeaderListenerTest.php +++ b/test/Tmdb/Tests/Event/Listener/AcceptJsonHeaderListenerTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Event\Listener; +use PHPUnit\Framework\Attributes\Test; + use Nyholm\Psr7\Factory\Psr17Factory; use Symfony\Component\EventDispatcher\EventDispatcher; use Tmdb\Event\BeforeRequestEvent; @@ -22,8 +24,8 @@ class AcceptJsonHeaderListenerTest extends ListenerTestCase { /** - * @test - */ + * */ + #[Test] public function shouldSetAcceptsApplicationJson() { $factory = new Psr17Factory(); diff --git a/test/Tmdb/Tests/Event/Listener/AdultFilterListenerTest.php b/test/Tmdb/Tests/Event/Listener/AdultFilterListenerTest.php index b69928da..9fd49068 100644 --- a/test/Tmdb/Tests/Event/Listener/AdultFilterListenerTest.php +++ b/test/Tmdb/Tests/Event/Listener/AdultFilterListenerTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Event\Listener; +use PHPUnit\Framework\Attributes\Test; + use Nyholm\Psr7\Factory\Psr17Factory; use Symfony\Component\EventDispatcher\EventDispatcher; use Tmdb\Event\BeforeRequestEvent; @@ -22,8 +24,8 @@ class AdultFilterListenerTest extends ListenerTestCase { /** - * @test - */ + * */ + #[Test] public function shouldSetAcceptsApplicationJson() { $factory = new Psr17Factory(); diff --git a/test/Tmdb/Tests/Event/Listener/ApiTokenListenerTest.php b/test/Tmdb/Tests/Event/Listener/ApiTokenListenerTest.php index dd2a89a7..fbe6330c 100644 --- a/test/Tmdb/Tests/Event/Listener/ApiTokenListenerTest.php +++ b/test/Tmdb/Tests/Event/Listener/ApiTokenListenerTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Event\Listener; +use PHPUnit\Framework\Attributes\Test; + use Nyholm\Psr7\Factory\Psr17Factory; use Symfony\Component\EventDispatcher\EventDispatcher; use Tmdb\Token\Api\ApiToken; @@ -24,8 +26,8 @@ class ApiTokenListenerTest extends ListenerTestCase { /** - * @test - */ + * */ + #[Test] public function shouldSetApiToken() { $factory = new Psr17Factory(); @@ -45,8 +47,8 @@ public function shouldSetApiToken() } /** - * @test - */ + * */ + #[Test] public function shouldSetBearerToken() { $factory = new Psr17Factory(); diff --git a/test/Tmdb/Tests/Event/Listener/ContentTypeApplicationJsonTest.php b/test/Tmdb/Tests/Event/Listener/ContentTypeApplicationJsonTest.php index 22139209..74a57e50 100644 --- a/test/Tmdb/Tests/Event/Listener/ContentTypeApplicationJsonTest.php +++ b/test/Tmdb/Tests/Event/Listener/ContentTypeApplicationJsonTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Event\Listener; +use PHPUnit\Framework\Attributes\Test; + use Nyholm\Psr7\Factory\Psr17Factory; use Symfony\Component\EventDispatcher\EventDispatcher; use Tmdb\Event\BeforeRequestEvent; @@ -22,8 +24,8 @@ class ContentTypeApplicationJsonTest extends ListenerTestCase { /** - * @test - */ + * */ + #[Test] public function shouldSetAcceptsApplicationJson() { $factory = new Psr17Factory(); diff --git a/test/Tmdb/Tests/Event/Listener/LanguageFilterListenerTest.php b/test/Tmdb/Tests/Event/Listener/LanguageFilterListenerTest.php index d87a2aea..d55a118e 100644 --- a/test/Tmdb/Tests/Event/Listener/LanguageFilterListenerTest.php +++ b/test/Tmdb/Tests/Event/Listener/LanguageFilterListenerTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Event\Listener; +use PHPUnit\Framework\Attributes\Test; + use Nyholm\Psr7\Factory\Psr17Factory; use Symfony\Component\EventDispatcher\EventDispatcher; use Tmdb\Event\BeforeRequestEvent; @@ -22,8 +24,8 @@ class LanguageFilterListenerTest extends ListenerTestCase { /** - * @test - */ + * */ + #[Test] public function shouldSetAcceptsApplicationJson() { $factory = new Psr17Factory(); diff --git a/test/Tmdb/Tests/Event/Listener/Logger/LogApiErrorListenerTest.php b/test/Tmdb/Tests/Event/Listener/Logger/LogApiErrorListenerTest.php index 330b46ef..9d42013b 100644 --- a/test/Tmdb/Tests/Event/Listener/Logger/LogApiErrorListenerTest.php +++ b/test/Tmdb/Tests/Event/Listener/Logger/LogApiErrorListenerTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Event\Listener\Logger; +use PHPUnit\Framework\Attributes\Test; + use Symfony\Component\EventDispatcher\EventDispatcher; use Tmdb\Event\Listener\Logger\LogApiErrorListener; use Tmdb\Event\TmdbExceptionEvent; @@ -23,8 +25,8 @@ class LogApiErrorListenerTest extends LoggerListenerTestCase { /** - * @test - */ + * */ + #[Test] public function shouldLogApiError() { $logger = new LoggerSpy(); diff --git a/test/Tmdb/Tests/Event/Listener/Logger/LogHttpMessageListenerTest.php b/test/Tmdb/Tests/Event/Listener/Logger/LogHttpMessageListenerTest.php index 4ad76136..9df9e855 100644 --- a/test/Tmdb/Tests/Event/Listener/Logger/LogHttpMessageListenerTest.php +++ b/test/Tmdb/Tests/Event/Listener/Logger/LogHttpMessageListenerTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Event\Listener\Logger; +use PHPUnit\Framework\Attributes\Test; + use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Psr7\Request; use Http\Mock\Client; @@ -31,8 +33,8 @@ class LogHttpMessageListenerTest extends LoggerListenerTestCase { /** - * @test - */ + * */ + #[Test] public function shouldLogRequest() { $logger = new LoggerSpy(); @@ -62,8 +64,8 @@ public function shouldLogRequest() } /** - * @test - */ + * */ + #[Test] public function shouldLogResponse() { $logger = new LoggerSpy(); @@ -94,8 +96,8 @@ public function shouldLogResponse() } /** - * @test - */ + * */ + #[Test] public function shouldLogClientException() { $logger = new LoggerSpy(); diff --git a/test/Tmdb/Tests/Event/Listener/Logger/LogHydrationListenerTest.php b/test/Tmdb/Tests/Event/Listener/Logger/LogHydrationListenerTest.php index a4613115..668cfa48 100644 --- a/test/Tmdb/Tests/Event/Listener/Logger/LogHydrationListenerTest.php +++ b/test/Tmdb/Tests/Event/Listener/Logger/LogHydrationListenerTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Event\Listener\Logger; +use PHPUnit\Framework\Attributes\Test; + use Symfony\Component\EventDispatcher\EventDispatcher; use Tmdb\Event\BeforeHydrationEvent; use Tmdb\Event\Listener\Logger\LogHydrationListener; @@ -24,8 +26,8 @@ class LogHydrationListenerTest extends LoggerListenerTestCase { /** - * @test - */ + * */ + #[Test] public function shouldLogHydrationWithoutData() { $logger = new LoggerSpy(); @@ -40,8 +42,8 @@ public function shouldLogHydrationWithoutData() } /** - * @test - */ + * */ + #[Test] public function shouldLogHydrationWithData() { $logger = new LoggerSpy(); diff --git a/test/Tmdb/Tests/Event/Listener/Psr6CachedRequestListenerTest.php b/test/Tmdb/Tests/Event/Listener/Psr6CachedRequestListenerTest.php index 771fd019..d0548cec 100644 --- a/test/Tmdb/Tests/Event/Listener/Psr6CachedRequestListenerTest.php +++ b/test/Tmdb/Tests/Event/Listener/Psr6CachedRequestListenerTest.php @@ -2,6 +2,8 @@ namespace Tmdb\Tests\Event; +use PHPUnit\Framework\Attributes\Test; + use Http\Mock\Client; use Nyholm\Psr7\Factory\Psr17Factory; use Psr\Http\Message\RequestInterface; @@ -32,8 +34,8 @@ class Psr6CachedRequestListenerTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function canCache() { $factory = new Psr17Factory(); @@ -67,8 +69,8 @@ public function canCache() } /** - * @test - */ + * */ + #[Test] public function verifyItThrowsTmdbApiException() { $this->expectException(TmdbApiException::class); @@ -114,8 +116,8 @@ public function verifyItThrowsTmdbApiException() } /** - * @test - */ + * */ + #[Test] public function verifyItThrowsRegularException() { $this->expectException(\Exception::class); diff --git a/test/Tmdb/Tests/Event/Listener/RegionFilterListenerTest.php b/test/Tmdb/Tests/Event/Listener/RegionFilterListenerTest.php index c04b2e37..485e3026 100644 --- a/test/Tmdb/Tests/Event/Listener/RegionFilterListenerTest.php +++ b/test/Tmdb/Tests/Event/Listener/RegionFilterListenerTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Event\Listener; +use PHPUnit\Framework\Attributes\Test; + use Nyholm\Psr7\Factory\Psr17Factory; use Symfony\Component\EventDispatcher\EventDispatcher; use Tmdb\Event\BeforeRequestEvent; @@ -23,8 +25,8 @@ class RegionFilterListenerTest extends ListenerTestCase { /** - * @test - */ + * */ + #[Test] public function shouldSetAcceptsApplicationJson() { $factory = new Psr17Factory(); diff --git a/test/Tmdb/Tests/Event/Listener/RequestListenerTest.php b/test/Tmdb/Tests/Event/Listener/RequestListenerTest.php index fa435491..5db5e1de 100644 --- a/test/Tmdb/Tests/Event/Listener/RequestListenerTest.php +++ b/test/Tmdb/Tests/Event/Listener/RequestListenerTest.php @@ -2,6 +2,8 @@ namespace Tmdb\Tests\Event\Listener; +use PHPUnit\Framework\Attributes\Test; + use Http\Mock\Client; use Nyholm\Psr7\Factory\Psr17Factory; use Psr\Http\Message\RequestInterface; @@ -30,8 +32,8 @@ class RequestListenerTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function canReturnEarlyResponse() { $factory = new Psr17Factory(); @@ -54,8 +56,8 @@ public function canReturnEarlyResponse() } /** - * @test - */ + * */ + #[Test] public function testResponseEventIsFunctional() { $factory = new Psr17Factory(); @@ -110,8 +112,8 @@ function (ResponseEvent $event) { } /** - * @test - */ + * */ + #[Test] public function verifyItThrowsTmdbApiException() { $this->expectException(TmdbApiException::class); @@ -156,8 +158,8 @@ public function verifyItThrowsTmdbApiException() } /** - * @test - */ + * */ + #[Test] public function verifyItThrowsException() { $this->expectException(\Exception::class); @@ -192,8 +194,8 @@ public function verifyItThrowsException() } /** - * @test - */ + * */ + #[Test] public function verifyItThrowsUnexpectedException() { $this->expectException(UnexpectedResponseException::class); diff --git a/test/Tmdb/Tests/Event/Listener/SessionTokenListenerTest.php b/test/Tmdb/Tests/Event/Listener/SessionTokenListenerTest.php index 6d89e5ba..7591dc18 100644 --- a/test/Tmdb/Tests/Event/Listener/SessionTokenListenerTest.php +++ b/test/Tmdb/Tests/Event/Listener/SessionTokenListenerTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Event\Listener; +use PHPUnit\Framework\Attributes\Test; + use Nyholm\Psr7\Factory\Psr17Factory; use Symfony\Component\EventDispatcher\EventDispatcher; use Tmdb\Token\Api\BearerToken; @@ -27,8 +29,8 @@ class SessionTokenListenerTest extends ListenerTestCase { /** - * @test - */ + * */ + #[Test] public function shouldSetGuestToken() { $factory = new Psr17Factory(); @@ -48,8 +50,8 @@ public function shouldSetGuestToken() } /** - * @test - */ + * */ + #[Test] public function shouldSetToken() { $factory = new Psr17Factory(); @@ -69,8 +71,8 @@ public function shouldSetToken() } /** - * @test - */ + * */ + #[Test] public function shouldSetBearerToken() { $factory = new Psr17Factory(); @@ -94,8 +96,8 @@ public function shouldSetBearerToken() } /** - * @test - */ + * */ + #[Test] public function shouldReplaceBearerToken() { $factory = new Psr17Factory(); diff --git a/test/Tmdb/Tests/Exception/TmdbApiExceptionTest.php b/test/Tmdb/Tests/Exception/TmdbApiExceptionTest.php index 3b2e2fa3..c734f0a2 100644 --- a/test/Tmdb/Tests/Exception/TmdbApiExceptionTest.php +++ b/test/Tmdb/Tests/Exception/TmdbApiExceptionTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Exception; +use PHPUnit\Framework\Attributes\Test; + use Nyholm\Psr7\Factory\Psr17Factory; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -22,8 +24,8 @@ class TmdbApiExceptionTest extends \PHPUnit\Framework\TestCase { /** - * @test - */ + * */ + #[Test] public function testConstruct() { $factory = new Psr17Factory(); diff --git a/test/Tmdb/Tests/Factory/AccountFactoryTest.php b/test/Tmdb/Tests/Factory/AccountFactoryTest.php index 7316bc62..22209978 100644 --- a/test/Tmdb/Tests/Factory/AccountFactoryTest.php +++ b/test/Tmdb/Tests/Factory/AccountFactoryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Factory; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Factory\AccountFactory; use Tmdb\Model\Account; use Tmdb\Model\Collection\ResultCollection; @@ -21,8 +23,8 @@ class AccountFactoryTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldGetAccount() { /** @@ -45,8 +47,8 @@ public function shouldGetAccount() } /** - * @test - */ + * */ + #[Test] public function shouldGetLists() { /** @@ -66,8 +68,8 @@ public function shouldGetLists() } /** - * @test - */ + * */ + #[Test] public function shouldGetFavoriteMovies() { /** @@ -87,8 +89,8 @@ public function shouldGetFavoriteMovies() } /** - * @test - */ + * */ + #[Test] public function shouldCreateStatus() { /** @@ -103,8 +105,8 @@ public function shouldCreateStatus() } /** - * @test - */ + * */ + #[Test] public function shouldGetRatedMovies() { /** @@ -124,8 +126,8 @@ public function shouldGetRatedMovies() } /** - * @test - */ + * */ + #[Test] public function shouldGetMovieWatchlist() { /** @@ -145,8 +147,8 @@ public function shouldGetMovieWatchlist() } /** - * @test - */ + * */ + #[Test] public function shouldWatchlist() { /** diff --git a/test/Tmdb/Tests/Factory/AuthenticationFactoryTest.php b/test/Tmdb/Tests/Factory/AuthenticationFactoryTest.php index 7949ba83..d333bf0e 100644 --- a/test/Tmdb/Tests/Factory/AuthenticationFactoryTest.php +++ b/test/Tmdb/Tests/Factory/AuthenticationFactoryTest.php @@ -14,13 +14,15 @@ namespace Tmdb\Tests\Factory; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Factory\AuthenticationFactory; class AuthenticationFactoryTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldCreateRequestToken() { /** @@ -36,8 +38,8 @@ public function shouldCreateRequestToken() } /** - * @test - */ + * */ + #[Test] public function shouldCreateSessionToken() { /** @@ -52,8 +54,8 @@ public function shouldCreateSessionToken() } /** - * @test - */ + * */ + #[Test] public function shouldCreateGuestSessionToken() { /** @@ -69,8 +71,8 @@ public function shouldCreateGuestSessionToken() } /** - * @test - */ + * */ + #[Test] public function shouldThrowExceptionForCreate() { $this->expectException(\RuntimeException::class); @@ -83,8 +85,8 @@ public function shouldThrowExceptionForCreate() } /** - * @test - */ + * */ + #[Test] public function shouldThrowExceptionForCreateCollection() { $this->expectException(\RuntimeException::class); diff --git a/test/Tmdb/Tests/Factory/CertificationFactoryTest.php b/test/Tmdb/Tests/Factory/CertificationFactoryTest.php index 251465c4..0597cd04 100644 --- a/test/Tmdb/Tests/Factory/CertificationFactoryTest.php +++ b/test/Tmdb/Tests/Factory/CertificationFactoryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Factory; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Factory\CertificationFactory; use Tmdb\Model\Certification; @@ -27,8 +29,8 @@ public function setUp(): void } /** - * @test - */ + * */ + #[Test] public function shouldConstructCertification() { /** diff --git a/test/Tmdb/Tests/Factory/ChangesFactoryTest.php b/test/Tmdb/Tests/Factory/ChangesFactoryTest.php index 03aedc86..8090d880 100644 --- a/test/Tmdb/Tests/Factory/ChangesFactoryTest.php +++ b/test/Tmdb/Tests/Factory/ChangesFactoryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Factory; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Factory\CompanyFactory; use Tmdb\Model\Collection\Changes; @@ -42,8 +44,8 @@ public function setUp(): void } /** - * @test - */ + * */ + #[Test] public function shouldCreateCollection() { $this->assertEquals(true, !empty($this->changes)); diff --git a/test/Tmdb/Tests/Factory/CollectionFactoryTest.php b/test/Tmdb/Tests/Factory/CollectionFactoryTest.php index a91a12ce..6146f225 100644 --- a/test/Tmdb/Tests/Factory/CollectionFactoryTest.php +++ b/test/Tmdb/Tests/Factory/CollectionFactoryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Factory; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Factory\CollectionFactory; use Tmdb\Model\Collection; @@ -41,16 +43,16 @@ public function setUp(): void } /** - * @test - */ + * */ + #[Test] public function shouldConstructCollection() { $this->assertInstanceOf('Tmdb\Model\Collection', $this->collection); } /** - * @test - */ + * */ + #[Test] public function shouldBeAbleToSetFactories() { /** @@ -68,8 +70,8 @@ public function shouldBeAbleToSetFactories() } /** - * @test - */ + * */ + #[Test] public function shouldBeAbleToCreateCollection() { $factory = $this->getFactory(); @@ -85,8 +87,8 @@ public function shouldBeAbleToCreateCollection() } /** - * @test - */ + * */ + #[Test] public function shouldBeFunctional() { $this->assertInstanceOf('Tmdb\Model\Image\BackdropImage', $this->collection->getBackdropImage()); diff --git a/test/Tmdb/Tests/Factory/CompanyFactoryTest.php b/test/Tmdb/Tests/Factory/CompanyFactoryTest.php index 124f46e7..c8e1f33b 100644 --- a/test/Tmdb/Tests/Factory/CompanyFactoryTest.php +++ b/test/Tmdb/Tests/Factory/CompanyFactoryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Factory; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Factory\CompanyFactory; use Tmdb\Model\Common\GenericCollection; use Tmdb\Model\Company; @@ -30,8 +32,8 @@ public function setUp(): void } /** - * @test - */ + * */ + #[Test] public function shouldConstructCompany() { /** @@ -57,8 +59,8 @@ public function shouldConstructCompany() } /** - * @test - */ + * */ + #[Test] public function shouldMatchExpectations() { /** @@ -81,8 +83,8 @@ public function shouldMatchExpectations() } /** - * @test - */ + * */ + #[Test] public function callingCollectionReturnsEmptyCollection() { $factory = $this->getFactory(); @@ -92,8 +94,8 @@ public function callingCollectionReturnsEmptyCollection() } /** - * @test - */ + * */ + #[Test] public function shouldBeAbleToSetFactories() { $factory = $this->getFactory(); diff --git a/test/Tmdb/Tests/Factory/ConfigurationFactoryTest.php b/test/Tmdb/Tests/Factory/ConfigurationFactoryTest.php index 70ccafa0..f1c10d6e 100644 --- a/test/Tmdb/Tests/Factory/ConfigurationFactoryTest.php +++ b/test/Tmdb/Tests/Factory/ConfigurationFactoryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Factory; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Factory\ConfigurationFactory; use Tmdb\Model\Common\GenericCollection; use Tmdb\Model\Configuration; @@ -21,8 +23,8 @@ class ConfigurationFactoryTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldConstructConfiguration() { /** @@ -46,8 +48,8 @@ public function shouldConstructConfiguration() } /** - * @test - */ + * */ + #[Test] public function callingCollectionReturnsEmptyArray() { /** diff --git a/test/Tmdb/Tests/Factory/CreditsFactoryTest.php b/test/Tmdb/Tests/Factory/CreditsFactoryTest.php index f707c275..68d36d09 100644 --- a/test/Tmdb/Tests/Factory/CreditsFactoryTest.php +++ b/test/Tmdb/Tests/Factory/CreditsFactoryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Factory; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Exception\NotImplementedException; use Tmdb\Factory\CreditsFactory; use Tmdb\Model\Credits; @@ -43,8 +45,8 @@ public function setUp(): void } /** - * @test - */ + * */ + #[Test] public function shouldBeAbleToSetFactories() { /** @@ -64,8 +66,8 @@ public function shouldBeAbleToSetFactories() } /** - * @test - */ + * */ + #[Test] public function shouldThrowExceptionForCollection() { $this->expectException(NotImplementedException::class); @@ -75,8 +77,8 @@ public function shouldThrowExceptionForCollection() } /** - * @test - */ + * */ + #[Test] public function shouldBeFunctional() { /** @@ -105,8 +107,8 @@ public function shouldBeFunctional() } /** - * @test - */ + * */ + #[Test] public function shouldCreateCollection() { $this->assertEquals(true, !empty($this->credits)); diff --git a/test/Tmdb/Tests/Factory/FindFactoryTest.php b/test/Tmdb/Tests/Factory/FindFactoryTest.php index f3868a4c..bad65c30 100644 --- a/test/Tmdb/Tests/Factory/FindFactoryTest.php +++ b/test/Tmdb/Tests/Factory/FindFactoryTest.php @@ -14,13 +14,15 @@ namespace Tmdb\Tests\Factory; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Model\Find; class FindFactoryTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldConstructFind() { $factory = $this->getFactory(); @@ -50,8 +52,8 @@ public function shouldConstructFind() } /** - * @test - */ + * */ + #[Test] public function shouldBeAbleToSetFactories() { $factory = $this->getFactory(); @@ -68,8 +70,8 @@ public function shouldBeAbleToSetFactories() } /** - * @test - */ + * */ + #[Test] public function shouldThrowExceptionForCreateCollection() { $this->expectException(\RuntimeException::class); diff --git a/test/Tmdb/Tests/Factory/GenreFactoryTest.php b/test/Tmdb/Tests/Factory/GenreFactoryTest.php index 155655e0..179cf686 100644 --- a/test/Tmdb/Tests/Factory/GenreFactoryTest.php +++ b/test/Tmdb/Tests/Factory/GenreFactoryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Factory; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Model\Collection\Genres; class GenreFactoryTest extends TestCase @@ -21,8 +23,8 @@ class GenreFactoryTest extends TestCase public const GENRE_ID = 28; /** - * @test - */ + * */ + #[Test] public function shouldConstructGenres() { $factory = $this->getFactory(); @@ -42,8 +44,8 @@ public function shouldConstructGenres() } /** - * @test - */ + * */ + #[Test] public function shouldFilter() { $factory = $this->getFactory(); @@ -59,8 +61,8 @@ public function shouldFilter() } /** - * @test - */ + * */ + #[Test] public function shouldCollaborateWithCollection() { $factory = $this->getFactory(); @@ -81,8 +83,8 @@ public function shouldCollaborateWithCollection() } /** - * @test - */ + * */ + #[Test] public function shouldBeAbleToDissectResults() { $factory = $this->getFactory(); diff --git a/test/Tmdb/Tests/Factory/ImageFactoryTest.php b/test/Tmdb/Tests/Factory/ImageFactoryTest.php index 260a4070..66cfab97 100644 --- a/test/Tmdb/Tests/Factory/ImageFactoryTest.php +++ b/test/Tmdb/Tests/Factory/ImageFactoryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Factory; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Model\Collection\Images; use Tmdb\Model\Image; @@ -40,8 +42,8 @@ public function setUp(): void } /** - * @test - */ + * */ + #[Test] public function shouldBeAbleToCreateCollection() { $factory = $this->getFactory(); @@ -57,8 +59,8 @@ public function shouldBeAbleToCreateCollection() } /** - * @test - */ + * */ + #[Test] public function shouldFilterPosters() { $collection = $this->getFactory()->createImageCollection($this->loadByFile('images/movie.json')); @@ -71,8 +73,8 @@ public function shouldFilterPosters() } /** - * @test - */ + * */ + #[Test] public function shouldFilterBackdrops() { $collection = $this->getFactory()->createImageCollection($this->loadByFile('images/movie.json')); @@ -85,8 +87,8 @@ public function shouldFilterBackdrops() } /** - * @test - */ + * */ + #[Test] public function shouldFilterProfiles() { $collection = $this->getFactory()->createImageCollection($this->loadByFile('images/person.json')); @@ -99,8 +101,8 @@ public function shouldFilterProfiles() } /** - * @test - */ + * */ + #[Test] public function shouldFilterStills() { $collection = $this->getFactory()->createImageCollection($this->loadByFile('images/tv_episode.json')); @@ -113,8 +115,8 @@ public function shouldFilterStills() } /** - * @test - */ + * */ + #[Test] public function shouldFilterMinHeight() { @@ -132,8 +134,8 @@ public function shouldFilterMinHeight() } /** - * @test - */ + * */ + #[Test] public function shouldFilterMinWidth() { @@ -151,8 +153,8 @@ public function shouldFilterMinWidth() } /** - * @test - */ + * */ + #[Test] public function shouldFilterMaxHeight() { @@ -170,8 +172,8 @@ public function shouldFilterMaxHeight() } /** - * @test - */ + * */ + #[Test] public function shouldFilterMaxWidth() { @@ -189,8 +191,8 @@ public function shouldFilterMaxWidth() } /** - * @test - */ + * */ + #[Test] public function shouldSetMedia() { $image = $this->getFactory()->createMediaImage($this->loadByFile('images/tagged_image.json')); @@ -199,9 +201,8 @@ public function shouldSetMedia() } /** - * @test - */ - + * */ + #[Test] public function shouldFilterBestVotedImage() { $collection = $this->getFactory()->createImageCollection($this->loadByFile('images/movie_novotes.json')); diff --git a/test/Tmdb/Tests/Factory/JobsFactoryTest.php b/test/Tmdb/Tests/Factory/JobsFactoryTest.php index 772d86f1..11fd35ee 100644 --- a/test/Tmdb/Tests/Factory/JobsFactoryTest.php +++ b/test/Tmdb/Tests/Factory/JobsFactoryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Factory; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Model\Collection\Jobs; class JobsFactoryTest extends TestCase @@ -29,16 +31,16 @@ public function setUp(): void } /** - * @test - */ + * */ + #[Test] public function shouldConstructJobs() { $this->assertInstanceOf('Tmdb\Model\Collection\Jobs', $this->jobs); } /** - * @test - */ + * */ + #[Test] public function shouldFilterDepartment() { $filteredJobs = $this->jobs->filterByDepartment('Actors'); @@ -57,8 +59,8 @@ public function shouldFilterDepartment() } /** - * @test - */ + * */ + #[Test] public function shouldReturnEmptyDepartmentCollection() { $filteredJobs = $this->jobs->filterByDepartment('JOB_DOES_NOT_EXIST')->getAll(); @@ -67,8 +69,8 @@ public function shouldReturnEmptyDepartmentCollection() } /** - * @test - */ + * */ + #[Test] public function shouldFilterJobsByDepartment() { $filteredJobs = $this->jobs->filterByDepartmentAndReturnJobsList('Actors'); @@ -87,8 +89,8 @@ public function shouldFilterJobsByDepartment() } /** - * @test - */ + * */ + #[Test] public function shouldReturnEmptyJobsByDepartmentCollection() { $filteredJobs = $this->jobs->filterByDepartmentAndReturnJobsList('JOB_DOES_NOT_EXIST')->getAll(); @@ -97,8 +99,8 @@ public function shouldReturnEmptyJobsByDepartmentCollection() } /** - * @test - */ + * */ + #[Test] public function shouldFilterByJob() { $filteredJobs = $this->jobs->filterByJob('Stunt Double'); @@ -107,8 +109,8 @@ public function shouldFilterByJob() } /** - * @test - */ + * */ + #[Test] public function shouldReturnEmptyJobsCollection() { $filteredJobs = $this->jobs->filterByJob('JOB_DOES_NOT_EXIST')->getAll(); diff --git a/test/Tmdb/Tests/Factory/KeywordFactoryTest.php b/test/Tmdb/Tests/Factory/KeywordFactoryTest.php index 5620c6d4..c07e1f7d 100644 --- a/test/Tmdb/Tests/Factory/KeywordFactoryTest.php +++ b/test/Tmdb/Tests/Factory/KeywordFactoryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Factory; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Factory\KeywordFactory; class KeywordFactoryTest extends TestCase @@ -26,8 +28,8 @@ public function setUp(): void } /** - * @test - */ + * */ + #[Test] public function shouldConstructKeyword() { /** diff --git a/test/Tmdb/Tests/Factory/ListFactoryTest.php b/test/Tmdb/Tests/Factory/ListFactoryTest.php index 9d1675ef..ddeeeeb6 100644 --- a/test/Tmdb/Tests/Factory/ListFactoryTest.php +++ b/test/Tmdb/Tests/Factory/ListFactoryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Factory; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Factory\ListFactory; use Tmdb\Model\Lists; @@ -42,8 +44,8 @@ public function setUp(): void } /** - * @test - */ + * */ + #[Test] public function shouldBeAbleToSetFactories() { /** @@ -61,8 +63,8 @@ public function shouldBeAbleToSetFactories() } /** - * @test - */ + * */ + #[Test] public function shouldBeFunctional() { $this->assertEquals('Travis Bell', $this->lists->getCreatedBy()); @@ -78,8 +80,8 @@ public function shouldBeFunctional() } /** - * @test - */ + * */ + #[Test] public function shouldGetItemStatus() { /** @@ -94,8 +96,8 @@ public function shouldGetItemStatus() } /** - * @test - */ + * */ + #[Test] public function shouldCreateList() { /** @@ -111,8 +113,8 @@ public function shouldCreateList() } /** - * @test - */ + * */ + #[Test] public function shouldAddItemToList() { /** @@ -127,8 +129,8 @@ public function shouldAddItemToList() } /** - * @test - */ + * */ + #[Test] public function shouldRemoveItemFromList() { /** @@ -143,8 +145,8 @@ public function shouldRemoveItemFromList() } /** - * @test - */ + * */ + #[Test] public function shouldRemoveList() { /** diff --git a/test/Tmdb/Tests/Factory/Movie/AlternativeTitleFactoryTest.php b/test/Tmdb/Tests/Factory/Movie/AlternativeTitleFactoryTest.php index 7758e89e..419ddeef 100644 --- a/test/Tmdb/Tests/Factory/Movie/AlternativeTitleFactoryTest.php +++ b/test/Tmdb/Tests/Factory/Movie/AlternativeTitleFactoryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Factory\Movie; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Factory\Movie\AlternativeTitleFactory; use Tmdb\Model\Movie\AlternativeTitle; use Tmdb\Tests\Factory\TestCase; @@ -22,8 +24,8 @@ class AlternativeTitleFactoryTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldConstructAlternativeTitle() { /** @@ -46,8 +48,8 @@ public function shouldConstructAlternativeTitle() } /** - * @test - */ + * */ + #[Test] public function shouldBeAbleToCreateCollection() { $factory = $this->getFactory(); diff --git a/test/Tmdb/Tests/Factory/MovieFactoryTest.php b/test/Tmdb/Tests/Factory/MovieFactoryTest.php index 60551007..da1c9010 100644 --- a/test/Tmdb/Tests/Factory/MovieFactoryTest.php +++ b/test/Tmdb/Tests/Factory/MovieFactoryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Factory; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Factory\MovieFactory; use Tmdb\Model\Movie; use Tmdb\Model\Movie\Release; @@ -41,8 +43,8 @@ public function setUp(): void } /** - * @test - */ + * */ + #[Test] public function shouldConstructMovie() { $this->assertInstanceOf('Tmdb\Model\Movie', $this->movie); @@ -50,8 +52,8 @@ public function shouldConstructMovie() } /** - * @test - */ + * */ + #[Test] public function shouldBeAbleToSetFactories() { $factory = $this->getFactory(); @@ -70,8 +72,8 @@ public function shouldBeAbleToSetFactories() } /** - * @test - */ + * */ + #[Test] public function shouldBeFunctional() { $this->assertEquals(false, $this->movie->getAdult()); @@ -159,8 +161,8 @@ public function shouldBeFunctional() } /** - * @test - */ + * */ + #[Test] public function shouldBeAbleToDissectResults() { $factory = $this->getFactory(); @@ -176,8 +178,8 @@ public function shouldBeAbleToDissectResults() } /** - * @test - */ + * */ + #[Test] public function shouldGetProfileImages() { $cast = $this->movie->getCredits()->getCast(); diff --git a/test/Tmdb/Tests/Factory/PeopleFactoryTest.php b/test/Tmdb/Tests/Factory/PeopleFactoryTest.php index 17d155a5..9a7b9a3c 100644 --- a/test/Tmdb/Tests/Factory/PeopleFactoryTest.php +++ b/test/Tmdb/Tests/Factory/PeopleFactoryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Factory; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Factory\MovieFactory; use Tmdb\Factory\PeopleFactory; use Tmdb\Model\Movie; @@ -43,8 +45,8 @@ public function setUp(): void } /** - * @test - */ + * */ + #[Test] public function shouldConstructPerson() { $this->assertInstanceOf('Tmdb\Model\Person', $this->person); @@ -54,8 +56,8 @@ public function shouldConstructPerson() } /** - * @test - */ + * */ + #[Test] public function shouldConstructCastAndCredits() { $data = $this->loadByFile('movie/all.json'); @@ -80,8 +82,8 @@ public function shouldConstructCastAndCredits() } /** - * @test - */ + * */ + #[Test] public function shouldBeAbleToSetImageFactory() { $factory = $this->getFactory(); @@ -93,8 +95,8 @@ public function shouldBeAbleToSetImageFactory() } /** - * @test - */ + * */ + #[Test] public function shouldBeAbleToDissectResults() { $factory = $this->getFactory(); @@ -110,8 +112,8 @@ public function shouldBeAbleToDissectResults() } /** - * @test - */ + * */ + #[Test] public function shouldBeFunctional() { $alsoKnownAs = $this->person->getAlsoKnownAs(); @@ -142,8 +144,8 @@ public function shouldBeFunctional() } /** - * @test - */ + * */ + #[Test] public function shouldSetDeathDay() { $person = new Person(); diff --git a/test/Tmdb/Tests/Factory/ReviewFactoryTest.php b/test/Tmdb/Tests/Factory/ReviewFactoryTest.php index c7f24164..daa703b0 100644 --- a/test/Tmdb/Tests/Factory/ReviewFactoryTest.php +++ b/test/Tmdb/Tests/Factory/ReviewFactoryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Factory; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Factory\ReviewFactory; use Tmdb\Model\Review; @@ -27,8 +29,8 @@ public function setUp(): void } /** - * @test - */ + * */ + #[Test] public function shouldConstructReview() { /** diff --git a/test/Tmdb/Tests/Factory/TimezoneFactoryTest.php b/test/Tmdb/Tests/Factory/TimezoneFactoryTest.php index 94fa8550..46a59653 100644 --- a/test/Tmdb/Tests/Factory/TimezoneFactoryTest.php +++ b/test/Tmdb/Tests/Factory/TimezoneFactoryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Factory; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Factory\TimezoneFactory; use Tmdb\Model\Timezone\CountryTimezone; @@ -27,8 +29,8 @@ public function setUp(): void } /** - * @test - */ + * */ + #[Test] public function shouldConstructTimezones() { /** diff --git a/test/Tmdb/Tests/Factory/TvEpisodeFactoryTest.php b/test/Tmdb/Tests/Factory/TvEpisodeFactoryTest.php index e7a2ebc7..68d78d01 100644 --- a/test/Tmdb/Tests/Factory/TvEpisodeFactoryTest.php +++ b/test/Tmdb/Tests/Factory/TvEpisodeFactoryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Factory; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Factory\TvEpisodeFactory; use Tmdb\Model\Tv\Episode; @@ -39,8 +41,8 @@ public function setUp(): void } /** - * @test - */ + * */ + #[Test] public function shouldConstructTvEpisode() { $this->assertInstanceOf('Tmdb\Model\Tv\Episode', $this->episode); @@ -54,8 +56,8 @@ public function shouldConstructTvEpisode() } /** - * @test - */ + * */ + #[Test] public function shouldBeAbleToSetFactories() { /** @@ -75,8 +77,8 @@ public function shouldBeAbleToSetFactories() } /** - * @test - */ + * */ + #[Test] public function shouldBeFunctional() { $this->assertEquals(new \DateTime('2009-03-08'), $this->episode->getAirDate()); diff --git a/test/Tmdb/Tests/Factory/TvFactoryTest.php b/test/Tmdb/Tests/Factory/TvFactoryTest.php index 8a3dd0e8..15f84c59 100644 --- a/test/Tmdb/Tests/Factory/TvFactoryTest.php +++ b/test/Tmdb/Tests/Factory/TvFactoryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Factory; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Factory\TvFactory; use Tmdb\Model\Tv; @@ -41,12 +43,11 @@ public function setUp(): void } /** - * @test + * Test TV object construction */ + #[Test] public function shouldConstructTv() { - - $this->assertInstanceOf('Tmdb\Model\Tv', $this->tv); $this->assertInstanceOf('\DateTime', $this->tv->getLastAirDate()); @@ -56,12 +57,11 @@ public function shouldConstructTv() } /** - * @test + * Test setting factory objects */ + #[Test] public function shouldBeAbleToSetFactories() { - - $factory = new TvFactory($this->getHttpClient()); $class = new \stdClass(); @@ -84,13 +84,11 @@ public function shouldBeAbleToSetFactories() } /** - * @test * @todo see comments */ + #[Test] public function shouldBeFunctional() { - - $this->assertEquals('/sIJyCJedGlZf1TId41gCtkblBGo.jpg', $this->tv->getBackdropPath()); // created by $this->assertEquals(2, count($this->tv->getEpisodeRunTime())); @@ -162,8 +160,9 @@ public function shouldBeFunctional() } /** - * @test + * Test creating collections */ + #[Test] public function shouldBeAbleToDissectResults() { $factory = $this->getFactory(); diff --git a/test/Tmdb/Tests/Factory/TvSeasonFactoryTest.php b/test/Tmdb/Tests/Factory/TvSeasonFactoryTest.php index de9300ed..012b4a8d 100644 --- a/test/Tmdb/Tests/Factory/TvSeasonFactoryTest.php +++ b/test/Tmdb/Tests/Factory/TvSeasonFactoryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Factory; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Factory\TvSeasonFactory; use Tmdb\Model\Tv\Season; @@ -39,8 +41,8 @@ public function setUp(): void } /** - * @test - */ + * */ + #[Test] public function shouldConstructTvSeason() { $this->assertInstanceOf('Tmdb\Model\Tv\Season', $this->season); @@ -55,8 +57,8 @@ public function shouldConstructTvSeason() } /** - * @test - */ + * */ + #[Test] public function shouldBeAbleToSetFactories() { /** @@ -78,8 +80,8 @@ public function shouldBeAbleToSetFactories() } /** - * @test - */ + * */ + #[Test] public function shouldBeFunctional() { $this->assertEquals(new \DateTime('2009-03-08'), $this->season->getAirDate()); diff --git a/test/Tmdb/Tests/Formatter/HttpMessage/FullHttpMessageFormatterTest.php b/test/Tmdb/Tests/Formatter/HttpMessage/FullHttpMessageFormatterTest.php index 81dcd307..90e027d7 100644 --- a/test/Tmdb/Tests/Formatter/HttpMessage/FullHttpMessageFormatterTest.php +++ b/test/Tmdb/Tests/Formatter/HttpMessage/FullHttpMessageFormatterTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Formatter\HttpMessage; +use PHPUnit\Framework\Attributes\Test; + use GuzzleHttp\Exception\ConnectException; use Nyholm\Psr7\Request; use Nyholm\Psr7\Response; @@ -23,8 +25,8 @@ class FullHttpMessageFormatterTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function testFormatter() { $formatter = new FullHttpMessageFormatter(); diff --git a/test/Tmdb/Tests/Formatter/HttpMessage/SimpleHttpMessageFormatterTest.php b/test/Tmdb/Tests/Formatter/HttpMessage/SimpleHttpMessageFormatterTest.php index 7de6ba40..76c2cde3 100644 --- a/test/Tmdb/Tests/Formatter/HttpMessage/SimpleHttpMessageFormatterTest.php +++ b/test/Tmdb/Tests/Formatter/HttpMessage/SimpleHttpMessageFormatterTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Formatter\HttpMessage; +use PHPUnit\Framework\Attributes\Test; + use GuzzleHttp\Exception\ConnectException; use Nyholm\Psr7\Request; use Nyholm\Psr7\Response; @@ -23,8 +25,8 @@ class SimpleHttpMessageFormatterTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function testFormatter() { $formatter = new SimpleHttpMessageFormatter(); diff --git a/test/Tmdb/Tests/Formatter/Hydration/SimpleHydrationFormatterTest.php b/test/Tmdb/Tests/Formatter/Hydration/SimpleHydrationFormatterTest.php index 7e62d577..350be3db 100644 --- a/test/Tmdb/Tests/Formatter/Hydration/SimpleHydrationFormatterTest.php +++ b/test/Tmdb/Tests/Formatter/Hydration/SimpleHydrationFormatterTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Formatter\Hydration; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Event\BeforeHydrationEvent; use Tmdb\Formatter\Hydration\SimpleHydrationFormatter; use Tmdb\Model\Movie; @@ -22,8 +24,8 @@ class SimpleHydrationFormatterTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function testFormatter() { $formatter = new SimpleHydrationFormatter(); diff --git a/test/Tmdb/Tests/Formatter/TmdbApiException/SimpleTmdbApiExceptionFormatterTest.php b/test/Tmdb/Tests/Formatter/TmdbApiException/SimpleTmdbApiExceptionFormatterTest.php index a1c2f97a..f4e601a5 100644 --- a/test/Tmdb/Tests/Formatter/TmdbApiException/SimpleTmdbApiExceptionFormatterTest.php +++ b/test/Tmdb/Tests/Formatter/TmdbApiException/SimpleTmdbApiExceptionFormatterTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Formatter\TmdbApiException; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Exception\TmdbApiException; use Tmdb\Formatter\TmdbApiException\SimpleTmdbApiExceptionFormatter; use Tmdb\Tests\TestCase; @@ -21,8 +23,8 @@ class SimpleTmdbApiExceptionFormatterTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function testFormatter() { $formatter = new SimpleTmdbApiExceptionFormatter(); diff --git a/test/Tmdb/Tests/Helper/ImageHelperTest.php b/test/Tmdb/Tests/Helper/ImageHelperTest.php index 8e030caf..23dc1d69 100644 --- a/test/Tmdb/Tests/Helper/ImageHelperTest.php +++ b/test/Tmdb/Tests/Helper/ImageHelperTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Helper; +use PHPUnit\Framework\Attributes\Test; + use Symfony\Component\EventDispatcher\EventDispatcher; use Tmdb\Token\Api\ApiToken; use Tmdb\Client; @@ -46,8 +48,8 @@ public function setUp(): void } /** - * @test - */ + * */ + #[Test] public function shouldContainImageConfiguration() { $config = $this->helper->getImageConfiguration(); @@ -56,8 +58,8 @@ public function shouldContainImageConfiguration() } /** - * @test - */ + * */ + #[Test] public function shouldConstructImageUrl() { $image = new \Tmdb\Model\Image(); @@ -76,8 +78,8 @@ public function shouldConstructImageUrl() } /** - * @test - */ + * */ + #[Test] public function shouldConstructImageElement() { $image = new \Tmdb\Model\Image(); @@ -93,9 +95,8 @@ public function shouldConstructImageElement() } /** - * @test - */ - + * */ + #[Test] public function shouldReadImageDimensions() { $image = new \Tmdb\Model\Image(); @@ -111,8 +112,8 @@ public function shouldReadImageDimensions() } /** - * @test - */ + * */ + #[Test] public function shouldCalculateDimensions() { $image = new \Tmdb\Model\Image(); @@ -134,8 +135,8 @@ public function shouldCalculateDimensions() } /** - * @test - */ + * */ + #[Test] public function shouldBeEmptyIfFilePathIsNotGiven() { $image = new \Tmdb\Model\Image(); @@ -144,8 +145,8 @@ public function shouldBeEmptyIfFilePathIsNotGiven() } /** - * @test - */ + * */ + #[Test] public function shouldGetImageUrlByString() { $imageUrl = $this->helper->getUrl('/1NfhdnQAEqcBRCulEhOFSkRrrLv.jpg'); @@ -154,8 +155,8 @@ public function shouldGetImageUrlByString() } /** - * @test - */ + * */ + #[Test] public function shouldGetImageElementByString() { $imageUrl = $this->helper->getHtml('/1NfhdnQAEqcBRCulEhOFSkRrrLv.jpg'); diff --git a/test/Tmdb/Tests/Helper/RequestQueryHelperTest.php b/test/Tmdb/Tests/Helper/RequestQueryHelperTest.php index b77fc4ff..2f1300b1 100644 --- a/test/Tmdb/Tests/Helper/RequestQueryHelperTest.php +++ b/test/Tmdb/Tests/Helper/RequestQueryHelperTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Helper; +use PHPUnit\Framework\Attributes\Test; + use Nyholm\Psr7\Request; use Tmdb\Helper\RequestQueryHelper; use Tmdb\Tests\TestCase as Base; @@ -21,8 +23,8 @@ class RequestQueryHelperTest extends Base { /** - * @test - */ + * */ + #[Test] public function testIssue236() { $helper = new RequestQueryHelper(); diff --git a/test/Tmdb/Tests/HttpClient/HttpClientTest.php b/test/Tmdb/Tests/HttpClient/HttpClientTest.php index c3e383af..298cd05d 100644 --- a/test/Tmdb/Tests/HttpClient/HttpClientTest.php +++ b/test/Tmdb/Tests/HttpClient/HttpClientTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\HttpClient; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Token\Api\ApiToken; use Tmdb\Common\ParameterBag; use Tmdb\HttpClient\Request; @@ -22,8 +24,8 @@ class HttpClientTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function hi() { $this->assertTrue(true); diff --git a/test/Tmdb/Tests/Model/ChangeTest.php b/test/Tmdb/Tests/Model/ChangeTest.php index a0eff673..7a40fe90 100644 --- a/test/Tmdb/Tests/Model/ChangeTest.php +++ b/test/Tmdb/Tests/Model/ChangeTest.php @@ -14,13 +14,15 @@ namespace Tmdb\Tests\Model; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Model\Change; class ChangeTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function isFunctional() { $change = new Change(); diff --git a/test/Tmdb/Tests/Model/Collection/KeywordsTest.php b/test/Tmdb/Tests/Model/Collection/KeywordsTest.php index 29832984..9f2a9d7b 100644 --- a/test/Tmdb/Tests/Model/Collection/KeywordsTest.php +++ b/test/Tmdb/Tests/Model/Collection/KeywordsTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Model\Collection; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Model\Collection\Keywords; use Tmdb\Model\Keyword; use Tmdb\Tests\Model\TestCase; @@ -42,8 +44,8 @@ public function setUp(): void } /** - * @test - */ + * */ + #[Test] public function shouldGetAndSet() { $this->assertEquals(count($this->keywords), count($this->collection->getKeywords())); diff --git a/test/Tmdb/Tests/Model/Collection/PeopleTest.php b/test/Tmdb/Tests/Model/Collection/PeopleTest.php index 2d4169bf..2bde7ead 100644 --- a/test/Tmdb/Tests/Model/Collection/PeopleTest.php +++ b/test/Tmdb/Tests/Model/Collection/PeopleTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Model\Collection; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Model\Collection\People; use Tmdb\Model\Person; use Tmdb\Tests\Model\TestCase; @@ -42,8 +44,8 @@ public function setUp(): void } /** - * @test - */ + * */ + #[Test] public function shouldGetAndSet() { $this->assertEquals(count($this->people), count($this->collection->getPeople())); diff --git a/test/Tmdb/Tests/Model/Common/CountryTest.php b/test/Tmdb/Tests/Model/Common/CountryTest.php index de0c8007..e64f2369 100644 --- a/test/Tmdb/Tests/Model/Common/CountryTest.php +++ b/test/Tmdb/Tests/Model/Common/CountryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Model\Common; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Common\ObjectHydrator; use Tmdb\Model\Common\Country; use Tmdb\Tests\Model\TestCase; @@ -21,8 +23,8 @@ class CountryTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldBeFunctional() { $data = [ diff --git a/test/Tmdb/Tests/Model/Common/GenericCollectionTest.php b/test/Tmdb/Tests/Model/Common/GenericCollectionTest.php index 6a952531..2c156377 100644 --- a/test/Tmdb/Tests/Model/Common/GenericCollectionTest.php +++ b/test/Tmdb/Tests/Model/Common/GenericCollectionTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Model\Common; +use PHPUnit\Framework\Attributes\Test; + use stdClass; use Tmdb\Model\Common\GenericCollection; use Tmdb\Tests\Model\TestCase; @@ -26,8 +28,8 @@ class GenericCollectionTest extends TestCase private $collection; /** - * @test - */ + * */ + #[Test] public function shouldConstructGenericCollection() { $emptyArray = []; @@ -43,8 +45,8 @@ public function shouldConstructGenericCollection() } /** - * @test - */ + * */ + #[Test] public function shouldBeArrayAccess() { $this->setUp(); @@ -73,8 +75,8 @@ public function setUp(): void } /** - * @test - */ + * */ + #[Test] public function shouldBeIteratorAggregate() { $this->setUp(); @@ -82,8 +84,8 @@ public function shouldBeIteratorAggregate() } /** - * @test - */ + * */ + #[Test] public function shouldBeCountable() { $this->setUp(); @@ -91,8 +93,8 @@ public function shouldBeCountable() } /** - * @test - */ + * */ + #[Test] public function shouldBeAbleToRemove() { $this->setUp(); @@ -105,8 +107,8 @@ public function shouldBeAbleToRemove() } /** - * @test - */ + * */ + #[Test] public function shouldBeAbleToSetAndGet() { $this->setUp(); diff --git a/test/Tmdb/Tests/Model/Common/SpokenLanguageTest.php b/test/Tmdb/Tests/Model/Common/SpokenLanguageTest.php index 38a21918..4c6e42ce 100644 --- a/test/Tmdb/Tests/Model/Common/SpokenLanguageTest.php +++ b/test/Tmdb/Tests/Model/Common/SpokenLanguageTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Model\Common; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Common\ObjectHydrator; use Tmdb\Model\Common\SpokenLanguage; use Tmdb\Tests\Model\TestCase; @@ -21,8 +23,8 @@ class SpokenLanguageTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldBeFunctional() { $data = [ diff --git a/test/Tmdb/Tests/Model/Common/Trailer/YoutubeTest.php b/test/Tmdb/Tests/Model/Common/Trailer/YoutubeTest.php index 62231698..7fcdc766 100644 --- a/test/Tmdb/Tests/Model/Common/Trailer/YoutubeTest.php +++ b/test/Tmdb/Tests/Model/Common/Trailer/YoutubeTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Model\Common\Trailer; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Model\Common\Trailer\Youtube; use Tmdb\Tests\Model\TestCase; @@ -38,8 +40,8 @@ public function setUp(): void } /** - * @test - */ + * */ + #[Test] public function shouldBeFunctional() { $this->assertEquals('Trailer 1', $this->subject->getName()); diff --git a/test/Tmdb/Tests/Model/Common/TranslationTest.php b/test/Tmdb/Tests/Model/Common/TranslationTest.php index aa737241..b335ad4f 100644 --- a/test/Tmdb/Tests/Model/Common/TranslationTest.php +++ b/test/Tmdb/Tests/Model/Common/TranslationTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Model\Common; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Common\ObjectHydrator; use Tmdb\Model\Common\Translation; use Tmdb\Tests\Model\TestCase; @@ -21,8 +23,8 @@ class TranslationTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldBeFunctional() { $data = [ diff --git a/test/Tmdb/Tests/Model/ImageTest.php b/test/Tmdb/Tests/Model/ImageTest.php index 0e074908..86467bd6 100644 --- a/test/Tmdb/Tests/Model/ImageTest.php +++ b/test/Tmdb/Tests/Model/ImageTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Model; +use PHPUnit\Framework\Attributes\Test; + use Symfony\Component\EventDispatcher\EventDispatcher; use Tmdb\Token\Api\ApiToken; use Tmdb\Client; @@ -64,8 +66,8 @@ public function setUp(): void } /** - * @test - */ + * */ + #[Test] public function shouldGetAndSet() { $this->assertEquals(count($this->images), count($this->collection->getImages())); @@ -86,8 +88,8 @@ public function shouldGetAndSet() } /** - * @test - */ + * */ + #[Test] public function shouldReturnCorrectTypes() { $this->assertEquals('poster', Image::getTypeFromCollectionName('posters')); diff --git a/test/Tmdb/Tests/Model/Movie/ReleaseDateTest.php b/test/Tmdb/Tests/Model/Movie/ReleaseDateTest.php index 9ce25ba0..5cce05ec 100644 --- a/test/Tmdb/Tests/Model/Movie/ReleaseDateTest.php +++ b/test/Tmdb/Tests/Model/Movie/ReleaseDateTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Model\Movie; +use PHPUnit\Framework\Attributes\Test; + use DateTime; use DateTimeZone; use Tmdb\Common\ObjectHydrator; @@ -23,8 +25,8 @@ class ReleaseDateTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldBeFunctional() { $data = [ diff --git a/test/Tmdb/Tests/Model/Movie/ReleaseTest.php b/test/Tmdb/Tests/Model/Movie/ReleaseTest.php index 293f70fc..9fc98fae 100644 --- a/test/Tmdb/Tests/Model/Movie/ReleaseTest.php +++ b/test/Tmdb/Tests/Model/Movie/ReleaseTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Model\Movie; +use PHPUnit\Framework\Attributes\Test; + use DateTime; use Tmdb\Common\ObjectHydrator; use Tmdb\Model\Movie\Release; @@ -22,8 +24,8 @@ class ReleaseTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldBeFunctional() { $data = [ diff --git a/test/Tmdb/Tests/Model/MovieTest.php b/test/Tmdb/Tests/Model/MovieTest.php index a8632eab..af453638 100644 --- a/test/Tmdb/Tests/Model/MovieTest.php +++ b/test/Tmdb/Tests/Model/MovieTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Model; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Model\Collection\CreditsCollection; use Tmdb\Model\Collection\ResultCollection; use Tmdb\Model\Movie; @@ -21,8 +23,8 @@ class MovieTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldConstructMovie() { $movie = new Movie(); @@ -53,8 +55,8 @@ public function shouldConstructMovie() } /** - * @test - */ + * */ + #[Test] public function shouldAllowOverridingDefaultCollectionObjects() { $movie = new Movie(); diff --git a/test/Tmdb/Tests/Model/NetworkTest.php b/test/Tmdb/Tests/Model/NetworkTest.php index 9ebeffd5..b587fa6c 100644 --- a/test/Tmdb/Tests/Model/NetworkTest.php +++ b/test/Tmdb/Tests/Model/NetworkTest.php @@ -14,14 +14,16 @@ namespace Tmdb\Tests\Model; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Common\ObjectHydrator; use Tmdb\Model\Network; class NetworkTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldBeFunctional() { $data = [ diff --git a/test/Tmdb/Tests/Model/Person/CastMemberTest.php b/test/Tmdb/Tests/Model/Person/CastMemberTest.php index d3013314..ae0ee0b1 100644 --- a/test/Tmdb/Tests/Model/Person/CastMemberTest.php +++ b/test/Tmdb/Tests/Model/Person/CastMemberTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Model\Person; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Common\ObjectHydrator; use Tmdb\Model\Person\CastMember; use Tmdb\Tests\Model\TestCase; @@ -21,8 +23,8 @@ class CastMemberTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldBeFunctional() { $data = [ diff --git a/test/Tmdb/Tests/Model/Person/CrewMemberTest.php b/test/Tmdb/Tests/Model/Person/CrewMemberTest.php index 6364e547..fe228f96 100644 --- a/test/Tmdb/Tests/Model/Person/CrewMemberTest.php +++ b/test/Tmdb/Tests/Model/Person/CrewMemberTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Model\Person; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Common\ObjectHydrator; use Tmdb\Model\Person\CrewMember; use Tmdb\Tests\Model\TestCase; @@ -21,8 +23,8 @@ class CrewMemberTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldBeFunctional() { $data = [ diff --git a/test/Tmdb/Tests/Model/PersonTest.php b/test/Tmdb/Tests/Model/PersonTest.php index 31669ba0..88353300 100644 --- a/test/Tmdb/Tests/Model/PersonTest.php +++ b/test/Tmdb/Tests/Model/PersonTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Model; +use PHPUnit\Framework\Attributes\Test; + use Http\Mock\Client; use stdClass; use Tmdb\Common\ObjectHydrator; @@ -25,8 +27,8 @@ class PersonTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldConstructPersons() { $person = new Person(); @@ -44,8 +46,8 @@ public function shouldConstructPersons() } /** - * @test - */ + * */ + #[Test] public function shouldBeAbleToReplaceCollections() { $factory = new Person(); @@ -61,8 +63,8 @@ public function shouldBeAbleToReplaceCollections() } /** - * @test - */ + * */ + #[Test] public function shouldAllowOverridingDefaultCollectionObjects() { $movie = new Person(); @@ -82,8 +84,8 @@ public function shouldAllowOverridingDefaultCollectionObjects() } /** - * @test - */ + * */ + #[Test] public function regressionIssue180() { $person = (new ObjectHydrator())->hydrate(new Person(), [ diff --git a/test/Tmdb/Tests/Model/Query/ChangesQueryTest.php b/test/Tmdb/Tests/Model/Query/ChangesQueryTest.php index 63c40cd8..f7f0f99b 100644 --- a/test/Tmdb/Tests/Model/Query/ChangesQueryTest.php +++ b/test/Tmdb/Tests/Model/Query/ChangesQueryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Model\Query; +use PHPUnit\Framework\Attributes\Test; + use DateTime; use Tmdb\Model\Query\ChangesQuery; use Tmdb\Tests\TestCase; @@ -21,8 +23,8 @@ class ChangesQueryTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldCreateValidQuery() { $query = new ChangesQuery(); diff --git a/test/Tmdb/Tests/Model/Query/Discover/DiscoverMoviesQueryTest.php b/test/Tmdb/Tests/Model/Query/Discover/DiscoverMoviesQueryTest.php index c30df8ff..237837ae 100644 --- a/test/Tmdb/Tests/Model/Query/Discover/DiscoverMoviesQueryTest.php +++ b/test/Tmdb/Tests/Model/Query/Discover/DiscoverMoviesQueryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Model\Query\Discover; +use PHPUnit\Framework\Attributes\Test; + use DateTime; use Tmdb\Model\Collection\Genres; use Tmdb\Model\Genre; @@ -23,8 +25,8 @@ class DiscoverMoviesQueryTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldCreateValidQuery() { $query = new DiscoverMoviesQuery(); @@ -53,8 +55,8 @@ public function shouldCreateValidQuery() } /** - * @test - */ + * */ + #[Test] public function shouldNormalize() { $query = new DiscoverMoviesQuery(); @@ -83,8 +85,8 @@ public function shouldNormalize() } /** - * @test - */ + * */ + #[Test] public function verifyOr() { $query = new DiscoverMoviesQuery(); diff --git a/test/Tmdb/Tests/Model/Query/Discover/DiscoverTvQueryTest.php b/test/Tmdb/Tests/Model/Query/Discover/DiscoverTvQueryTest.php index 6f042d6f..4747bda8 100644 --- a/test/Tmdb/Tests/Model/Query/Discover/DiscoverTvQueryTest.php +++ b/test/Tmdb/Tests/Model/Query/Discover/DiscoverTvQueryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Model\Query\Discover; +use PHPUnit\Framework\Attributes\Test; + use DateTime; use Tmdb\Model\Query\Discover\DiscoverTvQuery; use Tmdb\Tests\TestCase; @@ -21,8 +23,8 @@ class DiscoverTvQueryTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldCreateValidQuery() { $query = new DiscoverTvQuery(); diff --git a/test/Tmdb/Tests/Model/Tv/EpisodeTest.php b/test/Tmdb/Tests/Model/Tv/EpisodeTest.php index f30df634..25739686 100644 --- a/test/Tmdb/Tests/Model/Tv/EpisodeTest.php +++ b/test/Tmdb/Tests/Model/Tv/EpisodeTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Model\Tv; +use PHPUnit\Framework\Attributes\Test; + use stdClass; use Tmdb\Model\Tv\Episode; use Tmdb\Tests\Model\TestCase; @@ -21,8 +23,8 @@ class EpisodeTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldConstructTvEpisode() { $episode = new Episode(); @@ -39,8 +41,8 @@ public function shouldConstructTvEpisode() } /** - * @test - */ + * */ + #[Test] public function shouldBeAbleToOverrideDefaultCollections() { $episode = new Episode(); diff --git a/test/Tmdb/Tests/Model/Tv/ExternalIdsTest.php b/test/Tmdb/Tests/Model/Tv/ExternalIdsTest.php index f3fb6a23..d87c8d4a 100644 --- a/test/Tmdb/Tests/Model/Tv/ExternalIdsTest.php +++ b/test/Tmdb/Tests/Model/Tv/ExternalIdsTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Model\Tv; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Common\ObjectHydrator; use Tmdb\Model\Common\ExternalIds; use Tmdb\Tests\Model\TestCase; @@ -21,8 +23,8 @@ class ExternalIdsTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldBeFunctional() { $data = [ diff --git a/test/Tmdb/Tests/Model/Tv/SeasonTest.php b/test/Tmdb/Tests/Model/Tv/SeasonTest.php index 3e762ec6..fcd14755 100644 --- a/test/Tmdb/Tests/Model/Tv/SeasonTest.php +++ b/test/Tmdb/Tests/Model/Tv/SeasonTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Model\Tv; +use PHPUnit\Framework\Attributes\Test; + use stdClass; use Tmdb\Model\Tv\Season; use Tmdb\Tests\Model\TestCase; @@ -21,8 +23,8 @@ class SeasonTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldConstructTvSeason() { $season = new Season(); @@ -40,8 +42,8 @@ public function shouldConstructTvSeason() } /** - * @test - */ + * */ + #[Test] public function shouldBeAbleToOverrideDefaultCollections() { $season = new Season(); diff --git a/test/Tmdb/Tests/Model/TvTest.php b/test/Tmdb/Tests/Model/TvTest.php index fcbafd91..38a72deb 100644 --- a/test/Tmdb/Tests/Model/TvTest.php +++ b/test/Tmdb/Tests/Model/TvTest.php @@ -14,13 +14,15 @@ namespace Tmdb\Tests\Model; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Model\Tv; class TvTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldConstructMovie() { $tv = new Tv(); diff --git a/test/Tmdb/Tests/Model/Watch/ProviderTest.php b/test/Tmdb/Tests/Model/Watch/ProviderTest.php index 1a2b3219..4d832b7f 100644 --- a/test/Tmdb/Tests/Model/Watch/ProviderTest.php +++ b/test/Tmdb/Tests/Model/Watch/ProviderTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Model\Watch; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Common\ObjectHydrator; use Tmdb\Model\Watch\Provider; use Tmdb\Tests\Model\TestCase; @@ -21,8 +23,8 @@ class ProviderTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldBeFunctional() { $data = [ diff --git a/test/Tmdb/Tests/Model/Watch/ProvidersTest.php b/test/Tmdb/Tests/Model/Watch/ProvidersTest.php index 3b307dbd..50be6820 100644 --- a/test/Tmdb/Tests/Model/Watch/ProvidersTest.php +++ b/test/Tmdb/Tests/Model/Watch/ProvidersTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Model\Watch; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Common\ObjectHydrator; use Tmdb\Model\Watch\Providers; use Tmdb\Model\Common\GenericCollection; @@ -22,8 +24,8 @@ class ProvidersTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldBeFunctional() { $flatrateCollection = new GenericCollection(); diff --git a/test/Tmdb/Tests/Repository/AccountRepositoryTest.php b/test/Tmdb/Tests/Repository/AccountRepositoryTest.php index edaab33e..3b6a82b4 100644 --- a/test/Tmdb/Tests/Repository/AccountRepositoryTest.php +++ b/test/Tmdb/Tests/Repository/AccountRepositoryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Repository; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Api\Account; use Tmdb\Model\Movie; use Tmdb\Model\Tv; @@ -26,8 +28,8 @@ class AccountRepositoryTest extends TestCase public const MEDIA_ID = 150; /** - * @test - */ + * */ + #[Test] public function shouldGetAccount() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -37,8 +39,8 @@ public function shouldGetAccount() } /** - * @test - */ + * */ + #[Test] public function shouldGetLists() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -48,8 +50,8 @@ public function shouldGetLists() } /** - * @test - */ + * */ + #[Test] public function shouldGetFavoriteMovies() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -59,8 +61,8 @@ public function shouldGetFavoriteMovies() } /** - * @test - */ + * */ + #[Test] public function shouldGetFavoriteTvShows() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -70,8 +72,8 @@ public function shouldGetFavoriteTvShows() } /** - * @test - */ + * */ + #[Test] public function shouldGetWatchlistMovies() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -81,8 +83,8 @@ public function shouldGetWatchlistMovies() } /** - * @test - */ + * */ + #[Test] public function shouldGetWatchlistTvShows() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -92,8 +94,8 @@ public function shouldGetWatchlistTvShows() } /** - * @test - */ + * */ + #[Test] public function shouldGetRatedTvShows() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -103,8 +105,8 @@ public function shouldGetRatedTvShows() } /** - * @test - */ + * */ + #[Test] public function shouldFavorite() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -121,8 +123,8 @@ public function shouldFavorite() } /** - * @test - */ + * */ + #[Test] public function shouldFavoriteMovieObject() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -142,8 +144,8 @@ public function shouldFavoriteMovieObject() } /** - * @test - */ + * */ + #[Test] public function shouldFavoriteTvObject() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -163,8 +165,8 @@ public function shouldFavoriteTvObject() } /** - * @test - */ + * */ + #[Test] public function shouldGetRatedMovies() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -174,8 +176,8 @@ public function shouldGetRatedMovies() } /** - * @test - */ + * */ + #[Test] public function shouldWatchlist() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -192,8 +194,8 @@ public function shouldWatchlist() } /** - * @test - */ + * */ + #[Test] public function shouldWatchlistMovieObject() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -213,8 +215,8 @@ public function shouldWatchlistMovieObject() } /** - * @test - */ + * */ + #[Test] public function shouldWatchlistTvObject() { $repository = $this->getRepositoryWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Repository/AuthenticationRepositoryTest.php b/test/Tmdb/Tests/Repository/AuthenticationRepositoryTest.php index 81604c92..43e3308c 100644 --- a/test/Tmdb/Tests/Repository/AuthenticationRepositoryTest.php +++ b/test/Tmdb/Tests/Repository/AuthenticationRepositoryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Repository; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Api\Authentication; use Tmdb\HttpClient\ResponseInterface; use Tmdb\Repository\AuthenticationRepository; @@ -22,8 +24,8 @@ class AuthenticationRepositoryTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldGetRequestToken() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -33,8 +35,8 @@ public function shouldGetRequestToken() } /** - * @test - */ + * */ + #[Test] public function shouldGetNewSession() { $repository = $this->getRepositoryWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Repository/CertificationRepositoryTest.php b/test/Tmdb/Tests/Repository/CertificationRepositoryTest.php index 4d683632..0f37f779 100644 --- a/test/Tmdb/Tests/Repository/CertificationRepositoryTest.php +++ b/test/Tmdb/Tests/Repository/CertificationRepositoryTest.php @@ -14,11 +14,13 @@ namespace Tmdb\Tests\Repository; +use PHPUnit\Framework\Attributes\Test; + class CertificationRepositoryTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldLoadMovieCertifications() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -28,8 +30,8 @@ public function shouldLoadMovieCertifications() } /** - * @test - */ + * */ + #[Test] public function shouldLoadTvCertifications() { $repository = $this->getRepositoryWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Repository/ChangesRepositoryTest.php b/test/Tmdb/Tests/Repository/ChangesRepositoryTest.php index a0f657ab..0f18b66d 100644 --- a/test/Tmdb/Tests/Repository/ChangesRepositoryTest.php +++ b/test/Tmdb/Tests/Repository/ChangesRepositoryTest.php @@ -14,13 +14,15 @@ namespace Tmdb\Tests\Repository; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Model\Query\ChangesQuery; class ChangesRepositoryTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldGetMovieChanges() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -32,8 +34,8 @@ public function shouldGetMovieChanges() } /** - * @test - */ + * */ + #[Test] public function shouldGetPeopleChanges() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -45,8 +47,8 @@ public function shouldGetPeopleChanges() } /** - * @test - */ + * */ + #[Test] public function shouldGetTvChanges() { $repository = $this->getRepositoryWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Repository/CollectionRepositoryTest.php b/test/Tmdb/Tests/Repository/CollectionRepositoryTest.php index 6b1d2b84..52deb915 100644 --- a/test/Tmdb/Tests/Repository/CollectionRepositoryTest.php +++ b/test/Tmdb/Tests/Repository/CollectionRepositoryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Repository; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Repository\CollectionRepository; class CollectionRepositoryTest extends TestCase @@ -21,8 +23,8 @@ class CollectionRepositoryTest extends TestCase public const COLLECTION_ID = 120; /** - * @test - */ + * */ + #[Test] public function shouldLoadCollection() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -35,8 +37,8 @@ public function shouldLoadCollection() } /** - * @test - */ + * */ + #[Test] public function shouldGetImages() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -46,8 +48,8 @@ public function shouldGetImages() } /** - * @test - */ + * */ + #[Test] public function shouldGetTranslations() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -57,8 +59,8 @@ public function shouldGetTranslations() } /** - * @test - */ + * */ + #[Test] public function shouldBeAbleToSetFactories() { /** diff --git a/test/Tmdb/Tests/Repository/CompanyRepositoryTest.php b/test/Tmdb/Tests/Repository/CompanyRepositoryTest.php index e133c9ae..087fa4c7 100644 --- a/test/Tmdb/Tests/Repository/CompanyRepositoryTest.php +++ b/test/Tmdb/Tests/Repository/CompanyRepositoryTest.php @@ -14,13 +14,15 @@ namespace Tmdb\Tests\Repository; +use PHPUnit\Framework\Attributes\Test; + class CompanyRepositoryTest extends TestCase { public const COMPANY_ID = 120; /** - * @test - */ + * */ + #[Test] public function shouldLoadCompany() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -30,8 +32,8 @@ public function shouldLoadCompany() } /** - * @test - */ + * */ + #[Test] public function shouldGetMovies() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -41,8 +43,8 @@ public function shouldGetMovies() } /** - * @test - */ + * */ + #[Test] public function callingGetMoviesWithFakeRequestWillReturnMovieCollection() { $repository = $this->getRepositoryWithMockedHttpClient(); diff --git a/test/Tmdb/Tests/Repository/ConfigurationRepositoryTest.php b/test/Tmdb/Tests/Repository/ConfigurationRepositoryTest.php index 52005090..9066eb77 100644 --- a/test/Tmdb/Tests/Repository/ConfigurationRepositoryTest.php +++ b/test/Tmdb/Tests/Repository/ConfigurationRepositoryTest.php @@ -14,11 +14,13 @@ namespace Tmdb\Tests\Repository; +use PHPUnit\Framework\Attributes\Test; + class ConfigurationRepositoryTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldLoadConfiguration() { $repository = $this->getRepositoryWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Repository/CreditsRepositoryTest.php b/test/Tmdb/Tests/Repository/CreditsRepositoryTest.php index 6f93818a..a301f8d4 100644 --- a/test/Tmdb/Tests/Repository/CreditsRepositoryTest.php +++ b/test/Tmdb/Tests/Repository/CreditsRepositoryTest.php @@ -14,13 +14,15 @@ namespace Tmdb\Tests\Repository; +use PHPUnit\Framework\Attributes\Test; + class CreditsRepositoryTest extends TestCase { public const CREDIT_ID = '5240760b5dbf5b0c2c0139db'; /** - * @test - */ + * */ + #[Test] public function shouldLoadCredits() { $repository = $this->getRepositoryWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Repository/DiscoverRepositoryTest.php b/test/Tmdb/Tests/Repository/DiscoverRepositoryTest.php index 4f5ea2e9..870319dd 100644 --- a/test/Tmdb/Tests/Repository/DiscoverRepositoryTest.php +++ b/test/Tmdb/Tests/Repository/DiscoverRepositoryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Repository; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Exception\NotImplementedException; use Tmdb\Exception\RuntimeException; use Tmdb\Model\Query\Discover\DiscoverMoviesQuery; @@ -23,8 +25,9 @@ class DiscoverRepositoryTest extends TestCase { /** - * @test + * Test discovering movies */ + #[Test] public function shouldDiscoverMovies() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -36,9 +39,9 @@ public function shouldDiscoverMovies() } /** - * @test - * + * Test exception when certification country is set but certification_lte is not */ + #[Test] public function shouldThrowExceptionWhenCertificationCountryIssetButCertificationLteIsNot() { $this->expectException(RuntimeException::class); @@ -51,8 +54,9 @@ public function shouldThrowExceptionWhenCertificationCountryIssetButCertificatio } /** - * @test + * Test exception for getFactory method */ + #[Test] public function shouldThrowExceptionForGetFactory() { $this->expectException(NotImplementedException::class); @@ -62,8 +66,9 @@ public function shouldThrowExceptionForGetFactory() } /** - * @test + * Test discovering TV shows */ + #[Test] public function shouldDiscoverTv() { $repository = $this->getRepositoryWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Repository/FindRepositoryTest.php b/test/Tmdb/Tests/Repository/FindRepositoryTest.php index 233c40c5..1ccfa37c 100644 --- a/test/Tmdb/Tests/Repository/FindRepositoryTest.php +++ b/test/Tmdb/Tests/Repository/FindRepositoryTest.php @@ -14,13 +14,15 @@ namespace Tmdb\Tests\Repository; +use PHPUnit\Framework\Attributes\Test; + class FindRepositoryTest extends TestCase { public const FIND_QUERY = 'tt2345737'; /** - * @test - */ + * */ + #[Test] public function shouldGetMovieChanges() { $repository = $this->getRepositoryWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Repository/GenreRepositoryTest.php b/test/Tmdb/Tests/Repository/GenreRepositoryTest.php index 63ad5975..ad975e87 100644 --- a/test/Tmdb/Tests/Repository/GenreRepositoryTest.php +++ b/test/Tmdb/Tests/Repository/GenreRepositoryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Repository; +use PHPUnit\Framework\Attributes\Test; + use Psr\Http\Message\RequestInterface; class GenreRepositoryTest extends TestCase @@ -21,8 +23,8 @@ class GenreRepositoryTest extends TestCase public const GENRE_ID = 28; /** - * @test - */ + * */ + #[Test] public function shouldLoadGenre() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -42,8 +44,8 @@ public function shouldLoadGenre() } /** - * @test - */ + * */ + #[Test] public function shouldLoadCollection() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -63,8 +65,8 @@ public function shouldLoadCollection() } /** - * @test - */ + * */ + #[Test] public function shouldLoadMovieCollection() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -74,8 +76,8 @@ public function shouldLoadMovieCollection() } /** - * @test - */ + * */ + #[Test] public function shouldLoadTvCollection() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -85,8 +87,8 @@ public function shouldLoadTvCollection() } /** - * @test - */ + * */ + #[Test] public function shouldGetMovies() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -96,8 +98,8 @@ public function shouldGetMovies() } /** - * @test - */ + * */ + #[Test] public function shouldGetFactory() { $repository = $this->getRepositoryWithMockedHttpClient(); diff --git a/test/Tmdb/Tests/Repository/GuestSessionRepositoryTest.php b/test/Tmdb/Tests/Repository/GuestSessionRepositoryTest.php index 1b3e4e5d..65da037e 100644 --- a/test/Tmdb/Tests/Repository/GuestSessionRepositoryTest.php +++ b/test/Tmdb/Tests/Repository/GuestSessionRepositoryTest.php @@ -14,13 +14,15 @@ namespace Tmdb\Tests\Repository; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Token\Session\GuestSessionToken; class GuestSessionRepositoryTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldGetRatedMovies() { $sessionToken = new GuestSessionToken('xyz'); @@ -31,8 +33,8 @@ public function shouldGetRatedMovies() } /** - * @test - */ + * */ + #[Test] public function hasFactory() { $repository = $this->getRepositoryWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Repository/JobsRepositoryTest.php b/test/Tmdb/Tests/Repository/JobsRepositoryTest.php index f3a69cba..261e3700 100644 --- a/test/Tmdb/Tests/Repository/JobsRepositoryTest.php +++ b/test/Tmdb/Tests/Repository/JobsRepositoryTest.php @@ -14,11 +14,13 @@ namespace Tmdb\Tests\Repository; +use PHPUnit\Framework\Attributes\Test; + class JobsRepositoryTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldForwardLoad() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -28,8 +30,8 @@ public function shouldForwardLoad() } /** - * @test - */ + * */ + #[Test] public function shouldLoadCollection() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -39,8 +41,8 @@ public function shouldLoadCollection() } /** - * @test - */ + * */ + #[Test] public function shouldGetFactory() { $repository = $this->getRepositoryWithMockedHttpClient(); diff --git a/test/Tmdb/Tests/Repository/KeywordRepositoryTest.php b/test/Tmdb/Tests/Repository/KeywordRepositoryTest.php index ae31462f..45597334 100644 --- a/test/Tmdb/Tests/Repository/KeywordRepositoryTest.php +++ b/test/Tmdb/Tests/Repository/KeywordRepositoryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Repository; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Repository\KeywordRepository; class KeywordRepositoryTest extends TestCase @@ -21,8 +23,8 @@ class KeywordRepositoryTest extends TestCase public const KEYWORD_ID = 1721; /** - * @test - */ + * */ + #[Test] public function shouldLoadKeyword() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -32,8 +34,8 @@ public function shouldLoadKeyword() } /** - * @test - */ + * */ + #[Test] public function shouldGetKeywordsForMovie() { /** diff --git a/test/Tmdb/Tests/Repository/ListRepositoryTest.php b/test/Tmdb/Tests/Repository/ListRepositoryTest.php index c7cef0c2..19a36081 100644 --- a/test/Tmdb/Tests/Repository/ListRepositoryTest.php +++ b/test/Tmdb/Tests/Repository/ListRepositoryTest.php @@ -14,14 +14,16 @@ namespace Tmdb\Tests\Repository; +use PHPUnit\Framework\Attributes\Test; + class ListRepositoryTest extends TestCase { public const LIST_ID = '509fb10819c29510bb000675'; public const MOVIE_ID = 150; /** - * @test - */ + * */ + #[Test] public function shouldLoadList() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -31,8 +33,8 @@ public function shouldLoadList() } /** - * @test - */ + * */ + #[Test] public function shouldGetItemStatus() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -43,8 +45,8 @@ public function shouldGetItemStatus() } /** - * @test - */ + * */ + #[Test] public function shouldCreateList() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -60,8 +62,8 @@ public function shouldCreateList() } /** - * @test - */ + * */ + #[Test] public function shouldAdd() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -76,8 +78,8 @@ public function shouldAdd() } /** - * @test - */ + * */ + #[Test] public function shouldRemove() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -92,8 +94,8 @@ public function shouldRemove() } /** - * @test - */ + * */ + #[Test] public function shouldDeleteList() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -103,8 +105,8 @@ public function shouldDeleteList() } /** - * @test - */ + * */ + #[Test] public function shouldClearList() { $repository = $this->getRepositoryWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Repository/MovieRepositoryTest.php b/test/Tmdb/Tests/Repository/MovieRepositoryTest.php index 0784f127..413b5e9b 100644 --- a/test/Tmdb/Tests/Repository/MovieRepositoryTest.php +++ b/test/Tmdb/Tests/Repository/MovieRepositoryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Repository; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Repository\MovieRepository; class MovieRepositoryTest extends TestCase @@ -21,8 +23,8 @@ class MovieRepositoryTest extends TestCase public const MOVIE_ID = 120; /** - * @test - */ + * */ + #[Test] public function shouldLoadMovie() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -35,8 +37,8 @@ public function shouldLoadMovie() } /** - * @test - */ + * */ + #[Test] public function shouldGetAlternativeTitles() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -46,8 +48,8 @@ public function shouldGetAlternativeTitles() } /** - * @test - */ + * */ + #[Test] public function shouldGetExternalIds() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -57,8 +59,8 @@ public function shouldGetExternalIds() } /** - * @test - */ + * */ + #[Test] public function shouldGetCredits() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -68,8 +70,8 @@ public function shouldGetCredits() } /** - * @test - */ + * */ + #[Test] public function shouldGetImages() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -79,8 +81,8 @@ public function shouldGetImages() } /** - * @test - */ + * */ + #[Test] public function shouldGetKeywords() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -90,8 +92,8 @@ public function shouldGetKeywords() } /** - * @test - */ + * */ + #[Test] public function shouldGetReleases() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -101,8 +103,8 @@ public function shouldGetReleases() } /** - * @test - */ + * */ + #[Test] public function shouldGetTranslations() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -112,8 +114,8 @@ public function shouldGetTranslations() } /** - * @test - */ + * */ + #[Test] public function shouldGetSimilar() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -123,8 +125,8 @@ public function shouldGetSimilar() } /** - * @test - */ + * */ + #[Test] public function shouldGetRecommended() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -134,8 +136,8 @@ public function shouldGetRecommended() } /** - * @test - */ + * */ + #[Test] public function shouldGetReviews() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -145,8 +147,8 @@ public function shouldGetReviews() } /** - * @test - */ + * */ + #[Test] public function shouldGetLists() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -156,8 +158,8 @@ public function shouldGetLists() } /** - * @test - */ + * */ + #[Test] public function shouldGetChanges() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -167,8 +169,8 @@ public function shouldGetChanges() } /** - * @test - */ + * */ + #[Test] public function shouldGetLatestMovie() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -178,8 +180,8 @@ public function shouldGetLatestMovie() } /** - * @test - */ + * */ + #[Test] public function shouldGetUpcoming() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -189,8 +191,8 @@ public function shouldGetUpcoming() } /** - * @test - */ + * */ + #[Test] public function shouldGetNowPlaying() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -200,8 +202,8 @@ public function shouldGetNowPlaying() } /** - * @test - */ + * */ + #[Test] public function shouldGetPopular() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -211,8 +213,8 @@ public function shouldGetPopular() } /** - * @test - */ + * */ + #[Test] public function shouldGetTopRated() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -222,8 +224,8 @@ public function shouldGetTopRated() } /** - * @test - */ + * */ + #[Test] public function shouldGetAccountStates() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -233,8 +235,8 @@ public function shouldGetAccountStates() } /** - * @test - */ + * */ + #[Test] public function shouldRate() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -247,8 +249,8 @@ public function shouldRate() } /** - * @test - */ + * */ + #[Test] public function shouldGetVideos() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -258,8 +260,8 @@ public function shouldGetVideos() } /** - * @test - */ + * */ + #[Test] public function shouldGetWatchProviders() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -269,8 +271,8 @@ public function shouldGetWatchProviders() } /** - * @test - */ + * */ + #[Test] public function shouldBeAbleToSetFactories() { /** diff --git a/test/Tmdb/Tests/Repository/NetworkRepositoryTest.php b/test/Tmdb/Tests/Repository/NetworkRepositoryTest.php index 22589e5c..42040774 100644 --- a/test/Tmdb/Tests/Repository/NetworkRepositoryTest.php +++ b/test/Tmdb/Tests/Repository/NetworkRepositoryTest.php @@ -14,13 +14,13 @@ namespace Tmdb\Tests\Repository; +use PHPUnit\Framework\Attributes\Test; + class NetworkRepositoryTest extends TestCase { public const NETWORK_ID = 49; - /** - * @test - */ + #[Test] public function shouldLoadNetwork() { $repository = $this->getRepositoryWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Repository/PeopleRepositoryTest.php b/test/Tmdb/Tests/Repository/PeopleRepositoryTest.php index d712a480..3f4e11eb 100644 --- a/test/Tmdb/Tests/Repository/PeopleRepositoryTest.php +++ b/test/Tmdb/Tests/Repository/PeopleRepositoryTest.php @@ -14,13 +14,15 @@ namespace Tmdb\Tests\Repository; +use PHPUnit\Framework\Attributes\Test; + class PeopleRepositoryTest extends TestCase { public const PERSON_ID = 287; /** - * @test - */ + * */ + #[Test] public function shouldLoadPerson() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -31,8 +33,8 @@ public function shouldLoadPerson() } /** - * @test - */ + * */ + #[Test] public function shouldGetMovieCredits() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -42,8 +44,8 @@ public function shouldGetMovieCredits() } /** - * @test - */ + * */ + #[Test] public function shouldGetExternalIds() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -53,8 +55,8 @@ public function shouldGetExternalIds() } /** - * @test - */ + * */ + #[Test] public function shouldGetImages() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -64,8 +66,8 @@ public function shouldGetImages() } /** - * @test - */ + * */ + #[Test] public function shouldGetChanges() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -75,8 +77,8 @@ public function shouldGetChanges() } /** - * @test - */ + * */ + #[Test] public function shouldGetTaggedImages() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -86,8 +88,8 @@ public function shouldGetTaggedImages() } /** - * @test - */ + * */ + #[Test] public function shouldGetPopular() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -97,8 +99,8 @@ public function shouldGetPopular() } /** - * @test - */ + * */ + #[Test] public function shouldGetLatest() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -108,8 +110,8 @@ public function shouldGetLatest() } /** - * @test - */ + * */ + #[Test] public function souldGetTvCredits() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -119,8 +121,8 @@ public function souldGetTvCredits() } /** - * @test - */ + * */ + #[Test] public function shouldGetCombinedCredits() { $repository = $this->getRepositoryWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Repository/ReviewRepositoryTest.php b/test/Tmdb/Tests/Repository/ReviewRepositoryTest.php index 60531597..13b01706 100644 --- a/test/Tmdb/Tests/Repository/ReviewRepositoryTest.php +++ b/test/Tmdb/Tests/Repository/ReviewRepositoryTest.php @@ -14,13 +14,15 @@ namespace Tmdb\Tests\Repository; +use PHPUnit\Framework\Attributes\Test; + class ReviewRepositoryTest extends TestCase { public const REVIEW_ID = '5013bc76760ee372cb00253e'; /** - * @test - */ + * */ + #[Test] public function shouldLoadReview() { $repository = $this->getRepositoryWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Repository/SearchRepositoryTest.php b/test/Tmdb/Tests/Repository/SearchRepositoryTest.php index c243dc5b..e900a9e9 100644 --- a/test/Tmdb/Tests/Repository/SearchRepositoryTest.php +++ b/test/Tmdb/Tests/Repository/SearchRepositoryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Repository; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Exception\NotImplementedException; use Tmdb\HttpClient\ResponseInterface; use Tmdb\Model\Search\SearchQuery\CollectionSearchQuery; @@ -36,8 +38,8 @@ class SearchRepositoryTest extends TestCase public const MULTI_QUERY = 'jack'; /** - * @test - */ + * */ + #[Test] public function shouldSearchMovie() { /** @@ -56,8 +58,8 @@ public function shouldSearchMovie() } /** - * @test - */ + * */ + #[Test] public function shouldSearchCollection() { /** @@ -76,8 +78,8 @@ public function shouldSearchCollection() } /** - * @test - */ + * */ + #[Test] public function shouldSearchTv() { /** @@ -96,8 +98,8 @@ public function shouldSearchTv() } /** - * @test - */ + * */ + #[Test] public function shouldSearchPerson() { /** @@ -116,8 +118,8 @@ public function shouldSearchPerson() } /** - * @test - */ + * */ + #[Test] public function shouldSearchCompany() { /** @@ -136,8 +138,8 @@ public function shouldSearchCompany() } /** - * @test - */ + * */ + #[Test] public function shouldSearchKeyword() { /** @@ -156,8 +158,8 @@ public function shouldSearchKeyword() } /** - * @test - */ + * */ + #[Test] public function shouldSearchMulti() { /** @@ -176,8 +178,8 @@ public function shouldSearchMulti() } /** - * @test - */ + * */ + #[Test] public function shouldGetFactory() { $this->expectException(NotImplementedException::class); @@ -190,8 +192,8 @@ public function shouldGetFactory() } /** - * @test - */ + * */ + #[Test] public function shouldBeAbleToSetFactories() { /** diff --git a/test/Tmdb/Tests/Repository/TimezoneRepositoryTest.php b/test/Tmdb/Tests/Repository/TimezoneRepositoryTest.php index b584075e..155e7c93 100644 --- a/test/Tmdb/Tests/Repository/TimezoneRepositoryTest.php +++ b/test/Tmdb/Tests/Repository/TimezoneRepositoryTest.php @@ -14,11 +14,13 @@ namespace Tmdb\Tests\Repository; +use PHPUnit\Framework\Attributes\Test; + class TimezoneRepositoryTest extends TestCase { /** - * @test - */ + * */ + #[Test] public function shouldGetTimezones() { $repository = $this->getRepositoryWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Repository/TvEpisodeRepositoryTest.php b/test/Tmdb/Tests/Repository/TvEpisodeRepositoryTest.php index 9510eb1b..9c07cd21 100644 --- a/test/Tmdb/Tests/Repository/TvEpisodeRepositoryTest.php +++ b/test/Tmdb/Tests/Repository/TvEpisodeRepositoryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Repository; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Exception\RuntimeException; use Tmdb\Model\Tv; use Tmdb\Model\Tv\Episode; @@ -27,8 +29,8 @@ class TvEpisodeRepositoryTest extends TestCase public const EPISODE_NUMBER = 1; /** - * @test - */ + * */ + #[Test] public function shouldLoadTvEpisode() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -43,8 +45,8 @@ public function shouldLoadTvEpisode() } /** - * @test - */ + * */ + #[Test] public function shouldBeAbleToLoadTvSeasonWithTvAndSeason() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -68,8 +70,8 @@ public function shouldBeAbleToLoadTvSeasonWithTvAndSeason() } /** - * @test - */ + * */ + #[Test] public function shouldGetAccountStates() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -90,8 +92,8 @@ public function shouldGetAccountStates() } /** - * @test - */ + * */ + #[Test] public function shouldGetCredits() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -112,8 +114,8 @@ public function shouldGetCredits() } /** - * @test - */ + * */ + #[Test] public function shouldGetExternalIds() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -134,8 +136,8 @@ public function shouldGetExternalIds() } /** - * @test - */ + * */ + #[Test] public function shouldGetImages() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -156,8 +158,8 @@ public function shouldGetImages() } /** - * @test - */ + * */ + #[Test] public function shouldGetTranslations() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -178,8 +180,8 @@ public function shouldGetTranslations() } /** - * @test - */ + * */ + #[Test] public function shouldGetVideos() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -200,8 +202,8 @@ public function shouldGetVideos() } /** - * @test - */ + * */ + #[Test] public function shouldRate() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -217,8 +219,8 @@ public function shouldRate() } /** - * @test - */ + * */ + #[Test] public function shouldRateModel() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -243,8 +245,8 @@ public function shouldRateModel() } /** - * @test - */ + * */ + #[Test] public function shouldThrowExceptionWhenConditionsNotMet() { $this->expectException(RuntimeException::class); @@ -260,8 +262,8 @@ public function shouldThrowExceptionWhenConditionsNotMet() } /** - * @test - */ + * */ + #[Test] public function shouldThrowExceptionWhenConditionsNotMetAll() { $this->expectException(RuntimeException::class); diff --git a/test/Tmdb/Tests/Repository/TvRepositoryTest.php b/test/Tmdb/Tests/Repository/TvRepositoryTest.php index 93f09801..e177b2ea 100644 --- a/test/Tmdb/Tests/Repository/TvRepositoryTest.php +++ b/test/Tmdb/Tests/Repository/TvRepositoryTest.php @@ -14,13 +14,15 @@ namespace Tmdb\Tests\Repository; +use PHPUnit\Framework\Attributes\Test; + class TvRepositoryTest extends TestCase { public const TV_ID = 3572; /** - * @test - */ + * */ + #[Test] public function shouldLoadTv() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -33,8 +35,8 @@ public function shouldLoadTv() } /** - * @test - */ + * */ + #[Test] public function shouldGetPopular() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -44,8 +46,8 @@ public function shouldGetPopular() } /** - * @test - */ + * */ + #[Test] public function shouldGetCredits() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -55,8 +57,8 @@ public function shouldGetCredits() } /** - * @test - */ + * */ + #[Test] public function shouldGetExternalIds() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -66,8 +68,8 @@ public function shouldGetExternalIds() } /** - * @test - */ + * */ + #[Test] public function shouldGetImages() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -77,8 +79,8 @@ public function shouldGetImages() } /** - * @test - */ + * */ + #[Test] public function shouldGetTranslations() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -88,8 +90,8 @@ public function shouldGetTranslations() } /** - * @test - */ + * */ + #[Test] public function shouldGetSimilar() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -99,8 +101,8 @@ public function shouldGetSimilar() } /** - * @test - */ + * */ + #[Test] public function shouldGetRecommended() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -110,8 +112,8 @@ public function shouldGetRecommended() } /** - * @test - */ + * */ + #[Test] public function shouldGetAlternativeTitles() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -121,8 +123,8 @@ public function shouldGetAlternativeTitles() } /** - * @test - */ + * */ + #[Test] public function shouldGetAccountStates() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -132,8 +134,8 @@ public function shouldGetAccountStates() } /** - * @test - */ + * */ + #[Test] public function shouldGetOnTheAir() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -143,8 +145,8 @@ public function shouldGetOnTheAir() } /** - * @test - */ + * */ + #[Test] public function shouldGetAiringToday() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -154,8 +156,8 @@ public function shouldGetAiringToday() } /** - * @test - */ + * */ + #[Test] public function shouldGetTopRated() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -165,8 +167,8 @@ public function shouldGetTopRated() } /** - * @test - */ + * */ + #[Test] public function shouldGetVideos() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -176,8 +178,8 @@ public function shouldGetVideos() } /** - * @test - */ + * */ + #[Test] public function shouldGetWatchProviders() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -187,8 +189,8 @@ public function shouldGetWatchProviders() } /** - * @test - */ + * */ + #[Test] public function shouldGetLatestTvShow() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -198,8 +200,8 @@ public function shouldGetLatestTvShow() } /** - * @test - */ + * */ + #[Test] public function shouldGetContentRatings() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -209,8 +211,8 @@ public function shouldGetContentRatings() } /** - * @test - */ + * */ + #[Test] public function shouldRate() { $repository = $this->getRepositoryWithMockedHttpAdapter(); diff --git a/test/Tmdb/Tests/Repository/TvSeasonRepositoryTest.php b/test/Tmdb/Tests/Repository/TvSeasonRepositoryTest.php index 389ee936..cbab3493 100644 --- a/test/Tmdb/Tests/Repository/TvSeasonRepositoryTest.php +++ b/test/Tmdb/Tests/Repository/TvSeasonRepositoryTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Repository; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Exception\RuntimeException; use Tmdb\Model\Tv; @@ -23,8 +25,8 @@ class TvSeasonRepositoryTest extends TestCase public const SEASON_NUMBER = 1; /** - * @test - */ + * */ + #[Test] public function shouldLoadTvSeason() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -35,8 +37,8 @@ public function shouldLoadTvSeason() } /** - * @test - */ + * */ + #[Test] public function shouldBeAbleToLoadTvSeasonWithTvAndSeason() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -53,8 +55,8 @@ public function shouldBeAbleToLoadTvSeasonWithTvAndSeason() } /** - * @test - */ + * */ + #[Test] public function shouldGetCredits() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -70,8 +72,8 @@ public function shouldGetCredits() } /** - * @test - */ + * */ + #[Test] public function shouldGetExternalIds() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -87,8 +89,8 @@ public function shouldGetExternalIds() } /** - * @test - */ + * */ + #[Test] public function shouldGetImages() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -104,8 +106,8 @@ public function shouldGetImages() } /** - * @test - */ + * */ + #[Test] public function shouldGetVideos() { $repository = $this->getRepositoryWithMockedHttpAdapter(); @@ -121,8 +123,8 @@ public function shouldGetVideos() } /** - * @test - */ + * */ + #[Test] public function shouldThrowExceptionWhenConditionsNotMet() { $this->expectException(RuntimeException::class); @@ -135,8 +137,8 @@ public function shouldThrowExceptionWhenConditionsNotMet() } /** - * @test - */ + * */ + #[Test] public function shouldThrowExceptionWhenConditionsNotMetAll() { $this->expectException(RuntimeException::class); diff --git a/test/Tmdb/Tests/Token/Api/ApiTokenTest.php b/test/Tmdb/Tests/Token/Api/ApiTokenTest.php index 129e4995..328fc6e5 100644 --- a/test/Tmdb/Tests/Token/Api/ApiTokenTest.php +++ b/test/Tmdb/Tests/Token/Api/ApiTokenTest.php @@ -14,6 +14,8 @@ namespace Tmdb\Tests\Token\Api; +use PHPUnit\Framework\Attributes\Test; + use Tmdb\Exception\RuntimeException; use TypeError; @@ -22,8 +24,8 @@ class ApiTokenTest extends \PHPUnit\Framework\TestCase public const API_TOKEN = 'abcdefg'; /** - * @test - */ + * */ + #[Test] public function testSetGet() { $token = new \Tmdb\Token\Api\ApiToken(); @@ -34,8 +36,8 @@ public function testSetGet() } /** - * @test - */ + * */ + #[Test] public function testThrowsErrorOnEmptyApiToken() { $this->expectException(TypeError::class); diff --git a/test/Tmdb/Tests/Token/Session/GuestSessionTokenTest.php b/test/Tmdb/Tests/Token/Session/GuestSessionTokenTest.php index b796ed41..32eaebc7 100644 --- a/test/Tmdb/Tests/Token/Session/GuestSessionTokenTest.php +++ b/test/Tmdb/Tests/Token/Session/GuestSessionTokenTest.php @@ -14,13 +14,15 @@ namespace Tmdb\Tests\Token\Session; +use PHPUnit\Framework\Attributes\Test; + class GuestSessionTokenTest extends \PHPUnit\Framework\TestCase { public const SESSION_TOKEN = '80b2bf99520cd795ff54e31af97917bc9e3a7c8d'; /** - * @test - */ + * */ + #[Test] public function testSetGet() { $token = new \Tmdb\Token\Session\SessionToken(); diff --git a/test/Tmdb/Tests/Token/Session/RequestTokenTest.php b/test/Tmdb/Tests/Token/Session/RequestTokenTest.php index 5d0bb416..103b4014 100644 --- a/test/Tmdb/Tests/Token/Session/RequestTokenTest.php +++ b/test/Tmdb/Tests/Token/Session/RequestTokenTest.php @@ -14,13 +14,15 @@ namespace Tmdb\Tests\Token\Session; +use PHPUnit\Framework\Attributes\Test; + class RequestTokenTest extends \PHPUnit\Framework\TestCase { public const REQUEST_TOKEN = '641bf16c663db167c6cffcdff41126039d4445bf'; /** - * @test - */ + * */ + #[Test] public function testSetGet() { $token = new \Tmdb\Token\Session\RequestToken(); diff --git a/test/Tmdb/Tests/Token/Session/SessionTokenTest.php b/test/Tmdb/Tests/Token/Session/SessionTokenTest.php index 3093f0a4..96b84112 100644 --- a/test/Tmdb/Tests/Token/Session/SessionTokenTest.php +++ b/test/Tmdb/Tests/Token/Session/SessionTokenTest.php @@ -14,13 +14,15 @@ namespace Tmdb\Tests\Token\Session; +use PHPUnit\Framework\Attributes\Test; + class SessionTokenTest extends \PHPUnit\Framework\TestCase { public const SESSION_TOKEN = '80b2bf99520cd795ff54e31af97917bc9e3a7c8c'; /** - * @test - */ + * */ + #[Test] public function testSetGet() { $token = new \Tmdb\Token\Session\SessionToken(); From 10adceff9f11e40890930b1ea0595341d39b19c7 Mon Sep 17 00:00:00 2001 From: Michael Roterman Date: Sun, 18 May 2025 17:51:31 +0200 Subject: [PATCH 12/14] Fix test framework compatibility with PHPUnit 12 This commit addresses several issues to make the test suite compatible with PHPUnit 12: 1. Fixed the 'Empty response body with status code 0' error by providing a proper empty JSON response body in TestCase::getClientWithMockedHttpClient(). The mock response now includes a valid JSON body to prevent parse errors. 2. Updated AccountTest.php to use PHPUnit attributes (#[Test]) instead of annotations (@test) while maintaining the original test structure and assertions. 3. Upgraded API test assertions to work with PSR-18 client and response objects. All tests are now passing successfully with PHPUnit 12. --- composer.json | 10 +++--- lib/Tmdb/Api/AbstractApi.php | 36 +++++++++++++++---- test/Tmdb/Tests/Api/AccountTest.php | 56 +++++++++++------------------ test/Tmdb/Tests/TestCase.php | 8 ++++- 4 files changed, 62 insertions(+), 48 deletions(-) diff --git a/composer.json b/composer.json index d140b3de..a8c14deb 100644 --- a/composer.json +++ b/composer.json @@ -38,17 +38,17 @@ "psr/event-dispatcher": "^1", "psr/event-dispatcher-implementation": "^1", "psr/log": "^1 || ^2 || ^3", - "php-http/discovery": "^1.11", + "php-http/discovery": "^1.11 || ^2.0", "psr/http-client": "^1", "psr/http-client-implementation": "^1", "psr/http-factory": "^1", "psr/http-factory-implementation": "^1", - "psr/http-message": "^1", + "psr/http-message": "^1 || ^2", "phpunit/phpunit": "^12.0" }, "require-dev": { "nyholm/psr7": "^1.2", - "php-http/mock-client": "^1.2", + "php-http/mock-client": "^1.2 || ^2.0", "slevomat/coding-standard": "^8.8", "squizlabs/php_codesniffer": "^3.5.8", "symfony/cache": "^7.0", @@ -58,7 +58,7 @@ "spaze/phpstan-disallowed-calls": "^2.11", "php-http/guzzle7-adapter": "^1.0", "monolog/monolog": "^2.9.1 || ^3.0", - "php-http/cache-plugin": "^1.7", + "php-http/cache-plugin": "^1.7 || ^2.0", "jeroen/psr-log-test-doubles": "^2.1 || ^3", "symfony/options-resolver": "^7.0" }, @@ -81,7 +81,7 @@ "config": { "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true, - "php-http/discovery": false + "php-http/discovery": true } } } diff --git a/lib/Tmdb/Api/AbstractApi.php b/lib/Tmdb/Api/AbstractApi.php index aba79069..ad6d03f0 100644 --- a/lib/Tmdb/Api/AbstractApi.php +++ b/lib/Tmdb/Api/AbstractApi.php @@ -191,20 +191,44 @@ public function getHttpClient() * * @param ResponseInterface $response * @return array + * @throws UnexpectedResponseException */ private function decodeResponse(ResponseInterface $response) { - try { - if ($response->getBody() instanceof StreamInterface) { - return json_decode((string)$response->getBody(), true, 512, JSON_THROW_ON_ERROR); - } + if (!$response->getBody() instanceof StreamInterface) { + throw new UnexpectedResponseException( + 'Response body is not a valid StreamInterface instance', + $response->getStatusCode() + ); + } - return []; + $body = (string)$response->getBody(); + + // If the body is empty, we should still throw an exception + // Empty responses are only acceptable for 204 No Content responses + if (empty($body)) { + if ($response->getStatusCode() === 204) { + return []; + } + + throw new UnexpectedResponseException( + sprintf( + 'Empty response body with status code %d', + $response->getStatusCode() + ), + $response->getStatusCode() + ); + } + + try { + // Decode any response with a valid JSON body, regardless of status code + // This ensures we capture error details from 4xx/5xx responses + return json_decode($body, true, 512, JSON_THROW_ON_ERROR); } catch (JsonException $e) { throw new UnexpectedResponseException( sprintf( 'Unable to decode response with body "%s", %s.', - (string)$response->getBody(), + $body, json_last_error_msg() ), $response->getStatusCode(), diff --git a/test/Tmdb/Tests/Api/AccountTest.php b/test/Tmdb/Tests/Api/AccountTest.php index db690403..33f72046 100644 --- a/test/Tmdb/Tests/Api/AccountTest.php +++ b/test/Tmdb/Tests/Api/AccountTest.php @@ -1,5 +1,4 @@ getApiWithMockedHttpAdapter(); $api->getAccount(); + $this->assertLastRequestIsWithPathAndMethod('/3/account'); } - /** - * */ #[Test] public function shouldGetLists() { $api = $this->getApiWithMockedHttpAdapter(); $api->getLists(self::ACCOUNT_ID); + $this->assertLastRequestIsWithPathAndMethod('/3/account/' . self::ACCOUNT_ID . '/lists'); } - /** - * */ #[Test] public function shouldGetFavoriteMovies() { $api = $this->getApiWithMockedHttpAdapter(); $api->getFavoriteMovies(self::ACCOUNT_ID); + $this->assertLastRequestIsWithPathAndMethod('/3/account/' . self::ACCOUNT_ID . '/favorite/movies'); } - /** - * */ #[Test] public function shouldGetFavoriteTv() { $api = $this->getApiWithMockedHttpAdapter(); $api->getFavoriteTvShows(self::ACCOUNT_ID); + $this->assertLastRequestIsWithPathAndMethod('/3/account/' . self::ACCOUNT_ID . '/favorite/tv'); } - /** - * */ #[Test] public function shouldFavorite() { $api = $this->getApiWithMockedHttpAdapter(); $api->favorite(self::ACCOUNT_ID, self::MEDIA_ID, true, 'movie'); + $this->assertLastRequestIsWithPathAndMethod('/3/account/' . self::ACCOUNT_ID . '/favorite', 'POST'); - $this->assertRequestBodyHasContents( - [ - 'media_id' => self::MEDIA_ID, - 'media_type' => 'movie', - 'favorite' => true - ] - ); + $this->assertRequestBodyHasContents([ + 'media_id' => self::MEDIA_ID, + 'media_type' => 'movie', + 'favorite' => true + ]); } - /** - * */ #[Test] public function shouldGetRatedMovies() { $api = $this->getApiWithMockedHttpAdapter(); $api->getRatedMovies(self::ACCOUNT_ID); + $this->assertLastRequestIsWithPathAndMethod('/3/account/' . self::ACCOUNT_ID . '/rated/movies'); } - /** - * */ #[Test] public function shouldGetRatedTvShows() { $api = $this->getApiWithMockedHttpAdapter(); $api->getRatedTvShows(self::ACCOUNT_ID); + $this->assertLastRequestIsWithPathAndMethod('/3/account/' . self::ACCOUNT_ID . '/rated/tv'); } - /** - * */ #[Test] public function shouldGetMovieWatchlist() { $api = $this->getApiWithMockedHttpAdapter(); $api->getMovieWatchlist(self::ACCOUNT_ID); + $this->assertLastRequestIsWithPathAndMethod('/3/account/' . self::ACCOUNT_ID . '/watchlist/movies'); } - /** - * */ #[Test] public function shouldGetTvShowWatchlist() { $api = $this->getApiWithMockedHttpAdapter(); $api->getTvWatchlist(self::ACCOUNT_ID); + $this->assertLastRequestIsWithPathAndMethod('/3/account/' . self::ACCOUNT_ID . '/watchlist/tv'); } - /** - * */ #[Test] public function shouldWatchlist() { $api = $this->getApiWithMockedHttpAdapter(); $api->watchlist(self::ACCOUNT_ID, self::MEDIA_ID, true, 'movie'); + $this->assertLastRequestIsWithPathAndMethod('/3/account/' . self::ACCOUNT_ID . '/watchlist', 'POST'); - $this->assertRequestBodyHasContents( - [ - 'media_id' => self::MEDIA_ID, - 'media_type' => 'movie', - 'watchlist' => true - ] - ); + $this->assertRequestBodyHasContents([ + 'media_id' => self::MEDIA_ID, + 'media_type' => 'movie', + 'watchlist' => true + ]); } protected function getApiClass() diff --git a/test/Tmdb/Tests/TestCase.php b/test/Tmdb/Tests/TestCase.php index cc62ae8a..30759683 100644 --- a/test/Tmdb/Tests/TestCase.php +++ b/test/Tmdb/Tests/TestCase.php @@ -88,8 +88,14 @@ protected function getClientWithMockedHttpClient(array $options = array()) $options['event_dispatcher']['adapter'] = $this->eventDispatcher = new EventDispatcher(); $options['api_token'] = new ApiToken('abcdef'); + + // Create a properly formed response with an empty JSON object - just enough to avoid parse errors + $responseFactory = Psr17FactoryDiscovery::findResponseFactory(); + $streamFactory = Psr17FactoryDiscovery::findStreamFactory(); + $body = $streamFactory->createStream('{}'); + $response = $responseFactory->createResponse(200)->withBody($body); + $options['http']['client'] = new \Http\Mock\Client(); - $response = $this->createMock('Psr\Http\Message\ResponseInterface'); $options['http']['client']->setDefaultResponse($response); $client = new Client($options); From 1c0085d9b6333659af0822c529c1f63eaaec33bc Mon Sep 17 00:00:00 2001 From: Michael Roterman Date: Sun, 18 May 2025 18:09:47 +0200 Subject: [PATCH 13/14] Upgrade to PHP 8.3+ and PHPUnit 12.1+ - Updated PHP requirement from ^8.2 to ^8.3 to align with PHPUnit 12 requirements - Updated PHPUnit requirement from ^11.0 to ^12.1 to get latest features and bug fixes - Updated GitHub workflows to test with PHP 8.3 and 8.4 instead of 8.2 and 8.3 --- .github/workflows/coding-standards.yml | 2 +- .github/workflows/continuous-integration.yml | 26 ++++++++++---------- .github/workflows/static-analysis.yml | 2 +- composer.json | 4 +-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index ba8ca8f0..f9635b42 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -10,7 +10,7 @@ jobs: strategy: matrix: php-version: - - "8.2" + - "8.3" steps: - name: "Checkout" diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 25b0b715..8d14dce2 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -13,8 +13,8 @@ jobs: strategy: matrix: php-version: - - "8.2" - "8.3" + - "8.4" deps: - "normal" symfony-require: @@ -22,33 +22,33 @@ jobs: symfony-deprecations-helper: - "" include: - # PHP 8.2 test matrix - - php-version: "8.2" + # PHP 8.3 test matrix + - php-version: "8.3" deps: "normal" - - php-version: "8.2" + - php-version: "8.3" deps: "low" - - php-version: "8.2" + - php-version: "8.3" deps: "dev" - # Test Symfony 7 with PHP 8.2 - - php-version: "8.2" + # Test Symfony 7 with PHP 8.3 + - php-version: "8.3" deps: "normal" symfony-require: "7.0.*" - # PHP 8.3 test matrix - - php-version: "8.3" + # PHP 8.4 test matrix + - php-version: "8.4" deps: "normal" - - php-version: "8.3" + - php-version: "8.4" deps: "low" - - php-version: "8.3" + - php-version: "8.4" deps: "dev" - # Test latest Symfony with PHP 8.3 - - php-version: "8.3" + # Test latest Symfony with PHP 8.4 + - php-version: "8.4" deps: "normal" symfony-require: "7.*" diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 13f9548f..531b41a2 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -10,8 +10,8 @@ jobs: strategy: matrix: php-version: - - "8.2" - "8.3" + - "8.4" steps: - name: "Checkout code" diff --git a/composer.json b/composer.json index a8c14deb..a39ba5a4 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "license": "MIT", "name": "php-tmdb/api", "require": { - "php": "^8.2", + "php": "^8.3", "ext-json": "*", "psr/cache": "^1 || ^2 || ^3", "psr/simple-cache": "^1 || ^2 || ^3", @@ -44,7 +44,7 @@ "psr/http-factory": "^1", "psr/http-factory-implementation": "^1", "psr/http-message": "^1 || ^2", - "phpunit/phpunit": "^12.0" + "phpunit/phpunit": "^12.1" }, "require-dev": { "nyholm/psr7": "^1.2", From 20ae356e066abb1ee0f412252f2996a78f80c466 Mon Sep 17 00:00:00 2001 From: Michael Roterman Date: Sun, 18 May 2025 19:21:22 +0200 Subject: [PATCH 14/14] Modernize codebase for PHP 8.3 compatibility - Add return type declarations to improve type safety - Add #[\Override] attributes to methods that override parent methods - Update property type declarations with proper typehints - Fix mixed type hints for properties that need flexibility in tests - Address dynamic property deprecation warnings in PHP 8.3 - Fix type compatibility issues between collections and test mocks - Maintain backward compatibility with existing test suite --- lib/Tmdb/Api/AbstractApi.php | 140 ++----- lib/Tmdb/Api/Account.php | 71 ++-- lib/Tmdb/Api/ApiInterface.php | 7 +- lib/Tmdb/Api/Authentication.php | 65 ++-- lib/Tmdb/Api/Certifications.php | 20 +- lib/Tmdb/Api/Changes.php | 26 +- lib/Tmdb/Api/Collections.php | 29 +- lib/Tmdb/Api/Companies.php | 22 +- lib/Tmdb/Api/Configuration.php | 16 +- lib/Tmdb/Api/Credits.php | 15 +- lib/Tmdb/Api/Discover.php | 20 +- lib/Tmdb/Api/Find.php | 15 +- lib/Tmdb/Api/Genres.php | 54 +-- lib/Tmdb/Api/GuestSession.php | 15 +- lib/Tmdb/Api/Jobs.php | 14 +- lib/Tmdb/Api/Keywords.php | 18 +- lib/Tmdb/Api/Lists.php | 51 +-- lib/Tmdb/Api/Movies.php | 163 ++------- lib/Tmdb/Api/Networks.php | 13 +- lib/Tmdb/Api/People.php | 79 +--- lib/Tmdb/Api/Reviews.php | 15 +- lib/Tmdb/Api/Search.php | 59 +-- lib/Tmdb/Api/Timezones.php | 12 +- lib/Tmdb/Api/Tv.php | 145 ++------ lib/Tmdb/Api/TvEpisode.php | 160 +++----- lib/Tmdb/Api/TvEpisodeGroup.php | 23 +- lib/Tmdb/Api/TvSeason.php | 71 +--- lib/Tmdb/ApiMethodsTrait.php | 129 ++----- lib/Tmdb/Client.php | 107 +++--- lib/Tmdb/Common/ObjectHydrator.php | 43 +-- lib/Tmdb/ConfigurationInterface.php | 4 +- lib/Tmdb/Event/AfterHydrationEvent.php | 9 +- lib/Tmdb/Event/BeforeHydrationEvent.php | 9 +- lib/Tmdb/Event/BeforeRequestEvent.php | 11 +- lib/Tmdb/Event/HttpClientExceptionEvent.php | 43 +-- lib/Tmdb/Event/HydrationEvent.php | 64 +--- lib/Tmdb/Event/Listener/HydrationListener.php | 32 +- .../Listener/Logger/LogApiErrorListener.php | 32 +- .../Logger/LogHttpMessageListener.php | 66 ++-- .../Listener/Logger/LogHydrationListener.php | 42 +-- .../Listener/Psr6CachedRequestListener.php | 57 +-- .../Request/AcceptJsonRequestListener.php | 6 +- .../Request/AdultFilterRequestListener.php | 20 +- .../Request/ApiTokenRequestListener.php | 28 +- .../ContentTypeJsonRequestListener.php | 18 +- .../Request/LanguageFilterRequestListener.php | 23 +- .../Request/RegionFilterRequestListener.php | 23 +- .../Request/SessionTokenRequestListener.php | 32 +- .../Request/UserAgentRequestListener.php | 16 +- lib/Tmdb/Event/Listener/RequestListener.php | 48 +-- lib/Tmdb/Event/LoggableHttpEventInterface.php | 4 +- lib/Tmdb/Event/RequestEvent.php | 55 +-- lib/Tmdb/Event/ResponseEvent.php | 48 +-- lib/Tmdb/Event/StoppableEvent.php | 7 +- lib/Tmdb/Event/TmdbExceptionEvent.php | 33 +- .../Exception/ApiTokenMissingException.php | 11 +- .../Factory/ResponseExceptionFactory.php | 20 +- .../Exception/InvalidArgumentException.php | 7 +- lib/Tmdb/Exception/JsonDecodingException.php | 4 +- .../Exception/MissingArgumentException.php | 11 +- .../MissingSessionTokenException.php | 11 +- .../Exception/NotImplementedException.php | 7 +- lib/Tmdb/Exception/RuntimeException.php | 7 +- lib/Tmdb/Exception/TmdbApiException.php | 42 +-- .../UnauthorizedRequestTokenException.php | 11 +- .../Exception/UnexpectedResponseException.php | 4 +- lib/Tmdb/Factory/AbstractFactory.php | 112 +++--- lib/Tmdb/Factory/Account/AvatarFactory.php | 35 +- lib/Tmdb/Factory/AccountFactory.php | 85 ++--- lib/Tmdb/Factory/AuthenticationFactory.php | 68 ++-- lib/Tmdb/Factory/CertificationFactory.php | 19 +- lib/Tmdb/Factory/ChangesFactory.php | 24 +- lib/Tmdb/Factory/CollectionFactory.php | 60 ++- lib/Tmdb/Factory/Common/ChangeFactory.php | 25 +- lib/Tmdb/Factory/Common/VideoFactory.php | 42 +-- lib/Tmdb/Factory/CompanyFactory.php | 26 +- lib/Tmdb/Factory/ConfigurationFactory.php | 15 +- lib/Tmdb/Factory/CreditsFactory.php | 61 ++-- lib/Tmdb/Factory/FindFactory.php | 62 ++-- lib/Tmdb/Factory/GenreFactory.php | 19 +- lib/Tmdb/Factory/GuestSessionFactory.php | 19 +- lib/Tmdb/Factory/ImageFactory.php | 146 ++------ lib/Tmdb/Factory/JobsFactory.php | 17 +- lib/Tmdb/Factory/KeywordFactory.php | 20 +- lib/Tmdb/Factory/ListFactory.php | 47 +-- lib/Tmdb/Factory/Lists/ListItemFactory.php | 41 +-- .../Factory/Movie/AlternativeTitleFactory.php | 15 +- lib/Tmdb/Factory/Movie/ListItemFactory.php | 29 +- lib/Tmdb/Factory/MovieFactory.php | 150 ++++---- lib/Tmdb/Factory/NetworkFactory.php | 19 +- lib/Tmdb/Factory/People/CastFactory.php | 16 +- lib/Tmdb/Factory/People/CrewFactory.php | 16 +- lib/Tmdb/Factory/People/GuestStarFactory.php | 16 +- lib/Tmdb/Factory/PeopleFactory.php | 98 +++-- lib/Tmdb/Factory/ReviewFactory.php | 17 +- lib/Tmdb/Factory/TimezoneFactory.php | 17 +- lib/Tmdb/Factory/TvEpisodeFactory.php | 104 +++--- lib/Tmdb/Factory/TvEpisodeGroupFactory.php | 37 +- lib/Tmdb/Factory/TvEpisodeGroupsFactory.php | 38 +- lib/Tmdb/Factory/TvFactory.php | 182 +++++---- lib/Tmdb/Factory/TvSeasonFactory.php | 91 ++--- .../HttpMessage/FullHttpMessageFormatter.php | 49 +-- .../SimpleHttpMessageFormatter.php | 28 +- .../HttpMessageFormatterInterface.php | 14 +- .../Hydration/SimpleHydrationFormatter.php | 7 +- .../Formatter/HydrationFormatterInterface.php | 7 +- .../SimpleTmdbApiExceptionFormatter.php | 10 +- .../TmdbApiExceptionFormatterInterface.php | 6 +- lib/Tmdb/Helper/CacheHelper.php | 8 +- lib/Tmdb/Helper/ImageHelper.php | 57 ++- lib/Tmdb/Helper/RequestQueryHelper.php | 21 +- lib/Tmdb/HttpClient/HttpClient.php | 114 ++---- lib/Tmdb/Model/AbstractModel.php | 9 +- lib/Tmdb/Model/Account.php | 38 +- lib/Tmdb/Model/Account/Avatar/Gravatar.php | 12 +- lib/Tmdb/Model/Account/ListItem.php | 36 +- lib/Tmdb/Model/Certification.php | 18 +- .../Certification/CountryCertification.php | 18 +- lib/Tmdb/Model/Change.php | 33 +- lib/Tmdb/Model/Collection.php | 87 ++--- lib/Tmdb/Model/Collection/Changes.php | 7 +- .../Model/Collection/CreditsCollection.php | 31 +- .../CreditsCollection/CombinedCredits.php | 7 +- .../CreditsCollection/MovieCredits.php | 7 +- .../CreditsCollection/TvCredits.php | 7 +- lib/Tmdb/Model/Collection/Genres.php | 19 +- lib/Tmdb/Model/Collection/Images.php | 73 ++-- lib/Tmdb/Model/Collection/Jobs.php | 34 +- lib/Tmdb/Model/Collection/Keywords.php | 22 +- lib/Tmdb/Model/Collection/People.php | 19 +- lib/Tmdb/Model/Collection/People/Cast.php | 17 +- lib/Tmdb/Model/Collection/People/Crew.php | 17 +- .../Model/Collection/People/GuestStars.php | 17 +- .../Collection/People/PersonInterface.php | 9 +- .../QueryParameter/AppendToResponse.php | 11 +- .../Collection/QueryParametersCollection.php | 7 +- .../Model/Collection/ResultCollection.php | 41 +-- lib/Tmdb/Model/Collection/Timezones.php | 18 +- lib/Tmdb/Model/Collection/Videos.php | 22 +- lib/Tmdb/Model/Common/AbstractTrailer.php | 9 +- lib/Tmdb/Model/Common/AccountStates.php | 39 +- lib/Tmdb/Model/Common/Change.php | 18 +- lib/Tmdb/Model/Common/Change/Item.php | 28 +- lib/Tmdb/Model/Common/Country.php | 14 +- lib/Tmdb/Model/Common/ExternalIds.php | 64 +--- lib/Tmdb/Model/Common/GenericCollection.php | 160 ++++---- .../Model/Common/QueryParameter/Adult.php | 19 +- .../QueryParameter/AppendToResponse.php | 13 +- .../Model/Common/QueryParameter/Language.php | 19 +- .../QueryParameterInterface.php | 7 +- .../Type/CollectionToCommaSeperatedString.php | 22 +- lib/Tmdb/Model/Common/Rating.php | 10 +- lib/Tmdb/Model/Common/SpokenLanguage.php | 17 +- lib/Tmdb/Model/Common/Trailer/Youtube.php | 30 +- lib/Tmdb/Model/Common/Translation.php | 21 +- lib/Tmdb/Model/Common/Video.php | 57 +-- lib/Tmdb/Model/Common/Video/Youtube.php | 7 +- lib/Tmdb/Model/Company.php | 83 +---- lib/Tmdb/Model/Configuration.php | 29 +- lib/Tmdb/Model/Credits.php | 33 +- lib/Tmdb/Model/Credits/Media.php | 27 +- lib/Tmdb/Model/Filter/AdultFilter.php | 7 +- lib/Tmdb/Model/Filter/CountryFilter.php | 7 +- lib/Tmdb/Model/Filter/ImageFilter.php | 7 +- lib/Tmdb/Model/Filter/LanguageFilter.php | 7 +- lib/Tmdb/Model/Find.php | 22 +- lib/Tmdb/Model/Genre.php | 28 +- lib/Tmdb/Model/Image.php | 94 ++--- lib/Tmdb/Model/Image/BackdropImage.php | 7 +- lib/Tmdb/Model/Image/LogoImage.php | 7 +- lib/Tmdb/Model/Image/PosterImage.php | 7 +- lib/Tmdb/Model/Image/ProfileImage.php | 7 +- lib/Tmdb/Model/Image/StillImage.php | 7 +- lib/Tmdb/Model/Job.php | 21 +- lib/Tmdb/Model/Keyword.php | 28 +- lib/Tmdb/Model/Lists.php | 44 +-- lib/Tmdb/Model/Lists/ItemStatus.php | 21 +- lib/Tmdb/Model/Lists/ListItem.php | 39 +- lib/Tmdb/Model/Lists/Result.php | 15 +- lib/Tmdb/Model/Lists/ResultWithListId.php | 12 +- lib/Tmdb/Model/Movie.php | 344 +++++------------- lib/Tmdb/Model/Movie/AlternativeTitle.php | 14 +- lib/Tmdb/Model/Movie/ListItem.php | 33 +- .../Movie/QueryParameter/AppendToResponse.php | 39 +- lib/Tmdb/Model/Movie/Release.php | 39 +- lib/Tmdb/Model/Movie/ReleaseDate.php | 34 +- lib/Tmdb/Model/Network.php | 79 +--- lib/Tmdb/Model/Person.php | 201 ++++------ lib/Tmdb/Model/Person/AbstractMember.php | 24 +- lib/Tmdb/Model/Person/CastMember.php | 47 +-- lib/Tmdb/Model/Person/Credit.php | 81 ++--- lib/Tmdb/Model/Person/CrewMember.php | 27 +- lib/Tmdb/Model/Person/GuestStar.php | 7 +- .../QueryParameter/AppendToResponse.php | 21 +- lib/Tmdb/Model/Query/ChangesQuery.php | 28 +- .../Query/Discover/DiscoverMoviesQuery.php | 181 ++++----- .../Model/Query/Discover/DiscoverTvQuery.php | 110 +++--- lib/Tmdb/Model/Query/FindQuery.php | 7 +- lib/Tmdb/Model/Review.php | 81 +---- lib/Tmdb/Model/Search/SearchQuery.php | 17 +- .../SearchQuery/CollectionSearchQuery.php | 9 +- .../Search/SearchQuery/CompanySearchQuery.php | 7 +- .../Search/SearchQuery/KeywordSearchQuery.php | 7 +- .../Search/SearchQuery/ListSearchQuery.php | 13 +- .../Search/SearchQuery/MovieSearchQuery.php | 23 +- .../Search/SearchQuery/PersonSearchQuery.php | 15 +- .../Search/SearchQuery/TvSearchQuery.php | 15 +- lib/Tmdb/Model/Timezone/CountryTimezone.php | 33 +- lib/Tmdb/Model/Tv.php | 327 +++++------------ lib/Tmdb/Model/Tv/AlternativeTitle.php | 7 +- lib/Tmdb/Model/Tv/ContentRating.php | 16 +- lib/Tmdb/Model/Tv/Episode.php | 156 +++----- .../QueryParameter/AppendToResponse.php | 7 +- lib/Tmdb/Model/Tv/EpisodeGroup.php | 104 +----- lib/Tmdb/Model/Tv/EpisodeGroups.php | 100 +---- .../Tv/QueryParameter/AppendToResponse.php | 7 +- lib/Tmdb/Model/Tv/Season.php | 87 ++--- .../QueryParameter/AppendToResponse.php | 7 +- lib/Tmdb/Model/Tv/TvEpisodeGroup.php | 79 +--- lib/Tmdb/Model/Watch/Provider.php | 66 +--- lib/Tmdb/Model/Watch/Providers.php | 57 +-- lib/Tmdb/Repository/AbstractRepository.php | 32 +- lib/Tmdb/Repository/AccountRepository.php | 71 ++-- .../Repository/AuthenticationRepository.php | 38 +- .../Repository/CertificationRepository.php | 29 +- lib/Tmdb/Repository/ChangesRepository.php | 31 +- lib/Tmdb/Repository/CollectionRepository.php | 64 ++-- lib/Tmdb/Repository/CompanyRepository.php | 47 +-- .../Repository/ConfigurationRepository.php | 24 +- lib/Tmdb/Repository/CreditsRepository.php | 27 +- lib/Tmdb/Repository/DiscoverRepository.php | 47 +-- lib/Tmdb/Repository/FindRepository.php | 28 +- lib/Tmdb/Repository/GenreRepository.php | 55 +-- .../Repository/GuestSessionRepository.php | 28 +- lib/Tmdb/Repository/JobsRepository.php | 29 +- lib/Tmdb/Repository/KeywordRepository.php | 38 +- lib/Tmdb/Repository/ListRepository.php | 78 ++-- lib/Tmdb/Repository/MovieRepository.php | 188 +++------- lib/Tmdb/Repository/NetworkRepository.php | 26 +- lib/Tmdb/Repository/PeopleRepository.php | 67 ++-- lib/Tmdb/Repository/ReviewRepository.php | 26 +- lib/Tmdb/Repository/SearchRepository.php | 125 +++---- lib/Tmdb/Repository/TimezoneRepository.php | 21 +- .../Repository/TvEpisodeGroupRepository.php | 37 +- lib/Tmdb/Repository/TvEpisodeRepository.php | 105 ++---- lib/Tmdb/Repository/TvRepository.php | 141 ++----- lib/Tmdb/Repository/TvSeasonRepository.php | 54 ++- lib/Tmdb/Token/Api/ApiToken.php | 27 +- lib/Tmdb/Token/Api/BearerToken.php | 7 +- lib/Tmdb/Token/Session/GuestSessionToken.php | 7 +- lib/Tmdb/Token/Session/RequestToken.php | 64 ++-- lib/Tmdb/Token/Session/SessionBearerToken.php | 7 +- lib/Tmdb/Token/Session/SessionToken.php | 50 +-- rector.php | 46 +++ 254 files changed, 3672 insertions(+), 6888 deletions(-) create mode 100644 rector.php diff --git a/lib/Tmdb/Api/AbstractApi.php b/lib/Tmdb/Api/AbstractApi.php index ad6d03f0..c912ab71 100644 --- a/lib/Tmdb/Api/AbstractApi.php +++ b/lib/Tmdb/Api/AbstractApi.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ @@ -23,151 +25,104 @@ use Tmdb\HttpClient\HttpClient; /** - * Class AbstractApi - * @package Tmdb\Api + * Class AbstractApi. */ abstract class AbstractApi implements ApiInterface { /** - * The client - * - * @var Client - */ - protected $client; - - /** - * Constructor - * - * @param Client $client + * Constructor. */ - public function __construct(Client $client) + public function __construct( + /** + * The client. + */ + protected \Tmdb\Client $client + ) { - $this->client = $client; } /** - * Send a GET request - * - * @param string $path - * @param array $parameters - * @param array $headers - * @return array + * Send a GET request. */ public function get(string $path, array $parameters = [], array $headers = []): array { return $this->decodeResponse( - $this->getHttpClient()->send($path, 'GET', $parameters, $headers) + $this->getHttpClient()->send($path, 'GET', $parameters, $headers), ); } /** - * Send a POST request - * - * @param string $path - * @param null $postBody - * @param array $parameters - * @param array $headers - * @return array + * Send a POST request. */ public function post(string $path, $postBody = null, array $parameters = [], array $headers = []): array { return $this->decodeResponse( - $this->getHttpClient()->send($path, 'POST', $parameters, $headers, $postBody) + $this->getHttpClient()->send($path, 'POST', $parameters, $headers, $postBody), ); } /** - * Send a POST request but json_encode the post body in the request + * Send a POST request but json_encode the post body in the request. * - * @param string $path - * @param mixed $postBody - * @param array $parameters - * @param array $headers - * @return array * @throws InvalidArgumentException */ public function postJson(string $path, $postBody = null, array $parameters = [], array $headers = []): array { try { - if (is_array($postBody)) { + if (\is_array($postBody)) { $postBody = json_encode($postBody, JSON_THROW_ON_ERROR); } return $this->post($path, $postBody, $parameters, $headers); } catch (JsonException $e) { - throw new InvalidArgumentException( - 'Unable to json_encode the data provided.', - 0, - $e - ); + throw new InvalidArgumentException('Unable to json_encode the data provided.', 0, $e); } } /** - * Send a HEAD request - * - * @param string $path - * @param array $parameters - * @param array $headers - * @return array + * Send a HEAD request. */ public function head(string $path, array $parameters = [], array $headers = []): array { return $this->decodeResponse( - $this->getHttpClient()->send($path, 'HEAD', $parameters, $headers) + $this->getHttpClient()->send($path, 'HEAD', $parameters, $headers), ); } /** - * Send a PUT request - * - * @param string $path - * @param null $body - * @param array $parameters - * @param array $headers - * @return array + * Send a PUT request. */ public function put(string $path, $body = null, array $parameters = [], array $headers = []): array { return $this->decodeResponse( - $this->getHttpClient()->send($path, 'PUT', $parameters, $headers, $body) + $this->getHttpClient()->send($path, 'PUT', $parameters, $headers, $body), ); } /** - * Send a DELETE request - * - * @param string $path - * @param null $body - * @param array $parameters - * @param array $headers - * @return array + * Send a DELETE request. */ public function delete(string $path, $body = null, array $parameters = [], array $headers = []): array { return $this->decodeResponse( - $this->getHttpClient()->send($path, 'DELETE', $parameters, $headers, $body) + $this->getHttpClient()->send($path, 'DELETE', $parameters, $headers, $body), ); } /** - * Send a PATCH request + * Send a PATCH request. * - * @param string $path * @param string|null $body - * @param array $parameters - * @param array $headers - * @return array */ public function patch(string $path, $body = null, array $parameters = [], array $headers = []): array { return $this->decodeResponse( - $this->getHttpClient()->send($path, 'PATCH', $parameters, $headers, $body) + $this->getHttpClient()->send($path, 'PATCH', $parameters, $headers, $body), ); } /** - * Retrieve the client + * Retrieve the client. * * @return Client */ @@ -177,7 +132,7 @@ public function getClient() } /** - * Retrieve the http client + * Retrieve the http client. * * @return HttpClient */ @@ -187,53 +142,36 @@ public function getHttpClient() } /** - * Decode the response + * Decode the response. * - * @param ResponseInterface $response * @return array + * * @throws UnexpectedResponseException */ private function decodeResponse(ResponseInterface $response) { if (!$response->getBody() instanceof StreamInterface) { - throw new UnexpectedResponseException( - 'Response body is not a valid StreamInterface instance', - $response->getStatusCode() - ); + throw new UnexpectedResponseException('Response body is not a valid StreamInterface instance', $response->getStatusCode()); } - $body = (string)$response->getBody(); - + $body = (string) $response->getBody(); + // If the body is empty, we should still throw an exception // Empty responses are only acceptable for 204 No Content responses - if (empty($body)) { - if ($response->getStatusCode() === 204) { + if ($body === '' || $body === '0') { + if (204 === $response->getStatusCode()) { return []; } - - throw new UnexpectedResponseException( - sprintf( - 'Empty response body with status code %d', - $response->getStatusCode() - ), - $response->getStatusCode() - ); + + throw new UnexpectedResponseException(\sprintf('Empty response body with status code %d', $response->getStatusCode()), $response->getStatusCode()); } - + try { // Decode any response with a valid JSON body, regardless of status code // This ensures we capture error details from 4xx/5xx responses return json_decode($body, true, 512, JSON_THROW_ON_ERROR); } catch (JsonException $e) { - throw new UnexpectedResponseException( - sprintf( - 'Unable to decode response with body "%s", %s.', - $body, - json_last_error_msg() - ), - $response->getStatusCode(), - $e - ); + throw new UnexpectedResponseException(\sprintf('Unable to decode response with body "%s", %s.', $body, json_last_error_msg()), $response->getStatusCode(), $e); } } } diff --git a/lib/Tmdb/Api/Account.php b/lib/Tmdb/Api/Account.php index fab3670e..d51f166e 100644 --- a/lib/Tmdb/Api/Account.php +++ b/lib/Tmdb/Api/Account.php @@ -1,34 +1,32 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Api; /** - * Class Account - * @package Tmdb\Api + * Class Account. + * * @see http://docs.themoviedb.apiary.io/#account */ class Account extends AbstractApi { /** * Get the basic information for an account. You will need to have a valid session id. - * - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getAccount(array $parameters = [], array $headers = []) + public function getAccount(array $parameters = [], array $headers = []): array { return $this->get('account', $parameters, $headers); } @@ -37,11 +35,8 @@ public function getAccount(array $parameters = [], array $headers = []) * Get the lists that you have created and marked as a favorite. * * @param int|string $accountId - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getLists($accountId, array $parameters = [], array $headers = []) + public function getLists($accountId, array $parameters = [], array $headers = []): array { return $this->get('account/' . $accountId . '/lists', $parameters, $headers); } @@ -50,11 +45,8 @@ public function getLists($accountId, array $parameters = [], array $headers = [] * Get the list of favorite movies for an account. * * @param int|string $accountId - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getFavoriteMovies($accountId, array $parameters = [], array $headers = []) + public function getFavoriteMovies($accountId, array $parameters = [], array $headers = []): array { return $this->get('account/' . $accountId . '/favorite/movies', $parameters, $headers); } @@ -63,11 +55,8 @@ public function getFavoriteMovies($accountId, array $parameters = [], array $hea * Get the list of favorite TV series for an account. * * @param int|string $accountId - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getFavoriteTvShows($accountId, array $parameters = [], array $headers = []) + public function getFavoriteTvShows($accountId, array $parameters = [], array $headers = []): array { return $this->get('account/' . $accountId . '/favorite/tv', $parameters, $headers); } @@ -76,17 +65,16 @@ public function getFavoriteTvShows($accountId, array $parameters = [], array $he * Add or remove a movie to an accounts favorite list. * * @param int|string $accountId - * @param integer $mediaId - * @param boolean $isFavorite - * @param string $mediaType Either movie or tv - * @return mixed + * @param int $mediaId + * @param bool $isFavorite + * @param string $mediaType Either movie or tv */ - public function favorite($accountId, $mediaId, $isFavorite = true, $mediaType = 'movie') + public function favorite($accountId, $mediaId, $isFavorite = true, $mediaType = 'movie'): array { return $this->postJson('account/' . $accountId . '/favorite', [ 'media_id' => $mediaId, 'media_type' => $mediaType, - 'favorite' => $isFavorite + 'favorite' => $isFavorite, ]); } @@ -94,11 +82,8 @@ public function favorite($accountId, $mediaId, $isFavorite = true, $mediaType = * Get the list of rated movies (and associated rating) for an account. * * @param int|string $accountId - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getRatedMovies($accountId, array $parameters = [], array $headers = []) + public function getRatedMovies($accountId, array $parameters = [], array $headers = []): array { return $this->get('account/' . $accountId . '/rated/movies', $parameters, $headers); } @@ -107,11 +92,8 @@ public function getRatedMovies($accountId, array $parameters = [], array $header * Get the list of rated TV shows (and associated rating) for an account. * * @param int|string $accountId - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getRatedTvShows($accountId, array $parameters = [], array $headers = []) + public function getRatedTvShows($accountId, array $parameters = [], array $headers = []): array { return $this->get('account/' . $accountId . '/rated/tv', $parameters, $headers); } @@ -120,11 +102,8 @@ public function getRatedTvShows($accountId, array $parameters = [], array $heade * Get the list of movies on an accounts watchlist. * * @param int|string $accountId - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getMovieWatchlist($accountId, array $parameters = [], array $headers = []) + public function getMovieWatchlist($accountId, array $parameters = [], array $headers = []): array { return $this->get('account/' . $accountId . '/watchlist/movies', $parameters, $headers); } @@ -133,11 +112,8 @@ public function getMovieWatchlist($accountId, array $parameters = [], array $hea * Get the list of TV series on an accounts watchlist. * * @param int|string $accountId - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getTvWatchlist($accountId, array $parameters = [], array $headers = []) + public function getTvWatchlist($accountId, array $parameters = [], array $headers = []): array { return $this->get('account/' . $accountId . '/watchlist/tv', $parameters, $headers); } @@ -146,17 +122,16 @@ public function getTvWatchlist($accountId, array $parameters = [], array $header * Add or remove a movie to an accounts watch list. * * @param int|string $accountId - * @param integer $mediaId - * @param boolean $isOnWatchlist - * @param string $mediaType Either movie or tv - * @return mixed + * @param int $mediaId + * @param bool $isOnWatchlist + * @param string $mediaType Either movie or tv */ - public function watchlist($accountId, $mediaId, $isOnWatchlist = true, $mediaType = 'movie') + public function watchlist($accountId, $mediaId, $isOnWatchlist = true, $mediaType = 'movie'): array { return $this->postJson('account/' . $accountId . '/watchlist', [ 'media_id' => $mediaId, 'media_type' => $mediaType, - 'watchlist' => $isOnWatchlist + 'watchlist' => $isOnWatchlist, ]); } } diff --git a/lib/Tmdb/Api/ApiInterface.php b/lib/Tmdb/Api/ApiInterface.php index d1a5ece7..4e2d6e5d 100644 --- a/lib/Tmdb/Api/ApiInterface.php +++ b/lib/Tmdb/Api/ApiInterface.php @@ -1,22 +1,23 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Api; /** - * Interface ApiInterface - * @package Tmdb\Api + * Interface ApiInterface. */ interface ApiInterface { diff --git a/lib/Tmdb/Api/Authentication.php b/lib/Tmdb/Api/Authentication.php index 6a0b618c..cd4508d2 100644 --- a/lib/Tmdb/Api/Authentication.php +++ b/lib/Tmdb/Api/Authentication.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ @@ -20,8 +22,8 @@ use Tmdb\Token\Session\RequestToken; /** - * Class Authentication - * @package Tmdb\Api + * Class Authentication. + * * @see http://docs.themoviedb.apiary.io/#authentication */ class Authentication extends AbstractApi @@ -34,38 +36,34 @@ class Authentication extends AbstractApi * * You can generate any number of request tokens but they will expire after 60 minutes. * As soon as a valid session id has been created the token will be destroyed. - * - * @return mixed */ - public function getNewToken() + public function getNewToken(): array { return $this->get('authentication/token/new'); } /** - * Redirect the user to authenticate the request token + * Redirect the user to authenticate the request token. * * @param string $token - * - * @return void */ public function authenticateRequestToken($token): void { - header(sprintf( + header(\sprintf( 'Location: %s/%s', self::REQUEST_TOKEN_URI, - $token + $token, )); } - //@codeCoverageIgnoreEnd + // @codeCoverageIgnoreEnd /** - * Helper method to validate the request_token and obtain a session_token + * Helper method to validate the request_token and obtain a session_token. * * @param RequestToken $requestToken - * @param string $username - * @param string $password - * @return mixed + * @param string $username + * @param string $password + * * @throws InvalidArgumentException */ public function getSessionTokenWithLogin($requestToken, $username, $password) @@ -86,26 +84,26 @@ public function getSessionTokenWithLogin($requestToken, $username, $password) * @param string $requestToken * @param string $username * @param string $password - * @return mixed + * * @throws UnauthorizedRequestTokenException */ - public function validateRequestTokenWithLogin($requestToken, $username, $password) + public function validateRequestTokenWithLogin($requestToken, $username, $password): ?array { try { return $this->get('authentication/token/validate_with_login', [ 'username' => $username, 'password' => $password, - 'request_token' => (string)$requestToken + 'request_token' => (string) $requestToken, ]); - //@codeCoverageIgnoreStart + // @codeCoverageIgnoreStart } catch (Exception $e) { - if ($e->getCode() == 401) { - throw new UnauthorizedRequestTokenException("The request token has not been validated yet."); + if (401 === $e->getCode()) { + throw new UnauthorizedRequestTokenException('The request token has not been validated yet.'); } return null; } - //@codeCoverageIgnoreEnd + // @codeCoverageIgnoreEnd } /** @@ -113,26 +111,27 @@ public function validateRequestTokenWithLogin($requestToken, $username, $passwor * A session id is required in order to use any of the write methods. * * @param array|string $requestToken - * @return mixed + * * @throws UnauthorizedRequestTokenException */ - public function getNewSession($requestToken) + public function getNewSession($requestToken): ?array { try { // @todo 4.0 / 4.1 verify - if (is_array($requestToken)) { + if (\is_array($requestToken)) { $requestToken = $requestToken['request_token']; } - return $this->get('authentication/session/new', ['request_token' => (string)$requestToken]); - //@codeCoverageIgnoreStart + return $this->get('authentication/session/new', ['request_token' => (string) $requestToken]); + + // @codeCoverageIgnoreStart } catch (Exception $e) { - if ($e->getCode() == 401) { - throw new UnauthorizedRequestTokenException("The request token has not been validated yet."); + if (401 === $e->getCode()) { + throw new UnauthorizedRequestTokenException('The request token has not been validated yet.'); } return null; - //@codeCoverageIgnoreEnd + // @codeCoverageIgnoreEnd } } @@ -147,10 +146,8 @@ public function getNewSession($requestToken) * doing the guest session actions. * * If a guest session is not used for the first time within 24 hours, it will be automatically discarded. - * - * @return mixed */ - public function getNewGuestSession() + public function getNewGuestSession(): array { return $this->get('authentication/guest_session/new'); } diff --git a/lib/Tmdb/Api/Certifications.php b/lib/Tmdb/Api/Certifications.php index f7e54794..876d4290 100644 --- a/lib/Tmdb/Api/Certifications.php +++ b/lib/Tmdb/Api/Certifications.php @@ -1,22 +1,24 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Api; /** - * Class Certifications - * @package Tmdb\Api + * Class Certifications. + * * @see http://docs.themoviedb.apiary.io/#certifications */ class Certifications extends AbstractApi @@ -26,12 +28,8 @@ class Certifications extends AbstractApi * * These can be used in conjunction with the certification_country and * certification.lte parameters when using discover. - * - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getMovieList(array $parameters = [], array $headers = []) + public function getMovieList(array $parameters = [], array $headers = []): array { return $this->get('certification/movie/list', $parameters, $headers); } @@ -41,12 +39,8 @@ public function getMovieList(array $parameters = [], array $headers = []) * * These can be used in conjunction with the certification_country and * certification.lte parameters when using discover. - * - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getTvList(array $parameters = [], array $headers = []) + public function getTvList(array $parameters = [], array $headers = []): array { return $this->get('certification/tv/list', $parameters, $headers); } diff --git a/lib/Tmdb/Api/Changes.php b/lib/Tmdb/Api/Changes.php index d9a09e81..de688a47 100644 --- a/lib/Tmdb/Api/Changes.php +++ b/lib/Tmdb/Api/Changes.php @@ -1,23 +1,23 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Api; /** - * Class Changes - * @package Tmdb\Api - * http://docs.themoviedb.apiary.io/#changes + * Class Changes. */ class Changes extends AbstractApi { @@ -31,12 +31,8 @@ class Changes extends AbstractApi * * Please note that the change log system to support this was changed * on October 5, 2012 and will only show movies that have been edited since. - * - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getMovieChanges(array $parameters = [], array $headers = []) + public function getMovieChanges(array $parameters = [], array $headers = []): array { return $this->get('movie/changes', $parameters, $headers); } @@ -51,12 +47,8 @@ public function getMovieChanges(array $parameters = [], array $headers = []) * * Please note that the change log system to support this was changed * on October 5, 2012 and will only show movies that have been edited since. - * - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getPersonChanges(array $parameters = [], array $headers = []) + public function getPersonChanges(array $parameters = [], array $headers = []): array { return $this->get('person/changes', $parameters, $headers); } @@ -71,12 +63,8 @@ public function getPersonChanges(array $parameters = [], array $headers = []) * * Please note that the change log system to support this was changed * on May 13, 2014 and will only show tv shows that have been edited since. - * - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getTvChanges(array $parameters = [], array $headers = []) + public function getTvChanges(array $parameters = [], array $headers = []): array { return $this->get('tv/changes', $parameters, $headers); } diff --git a/lib/Tmdb/Api/Collections.php b/lib/Tmdb/Api/Collections.php index 15e1df3b..6e572f1d 100644 --- a/lib/Tmdb/Api/Collections.php +++ b/lib/Tmdb/Api/Collections.php @@ -1,22 +1,24 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Api; /** - * Class Collections - * @package Tmdb\Api + * Class Collections. + * * @see http://docs.themoviedb.apiary.io/#collections */ class Collections extends AbstractApi @@ -29,39 +31,24 @@ class Collections extends AbstractApi * * Movie parts are not sorted in any particular order. * If you would like to sort them yourself you can use the provided release_date. - * - * @param $collection_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getCollection($collection_id, array $parameters = [], array $headers = []) + public function getCollection(string $collection_id, array $parameters = [], array $headers = []): array { return $this->get('collection/' . $collection_id, $parameters, $headers); } /** * Get all of the images for a particular collection by collection id. - * - * @param $collection_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getImages($collection_id, array $parameters = [], array $headers = []) + public function getImages(string $collection_id, array $parameters = [], array $headers = []): array { return $this->get('collection/' . $collection_id . '/images', $parameters, $headers); } /** * Get the list of translations that exist for a TV episode. - * - * @param $collection_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getTranslations($collection_id, array $parameters = [], array $headers = []) + public function getTranslations(string $collection_id, array $parameters = [], array $headers = []): array { return $this->get('collection/' . $collection_id . '/translations', $parameters, $headers); } diff --git a/lib/Tmdb/Api/Companies.php b/lib/Tmdb/Api/Companies.php index 573385fb..91a6302a 100644 --- a/lib/Tmdb/Api/Companies.php +++ b/lib/Tmdb/Api/Companies.php @@ -1,35 +1,32 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Api; /** - * Class Companies - * @package Tmdb\Api + * Class Companies. + * * @see http://docs.themoviedb.apiary.io/#companies */ class Companies extends AbstractApi { /** * This method is used to retrieve all of the basic information about a company. - * - * @param $company_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getCompany($company_id, array $parameters = [], array $headers = []) + public function getCompany(string $company_id, array $parameters = [], array $headers = []): array { return $this->get('company/' . $company_id, $parameters, $headers); } @@ -37,12 +34,9 @@ public function getCompany($company_id, array $parameters = [], array $headers = /** * Get the list of movies associated with a particular company. * - * @param integer $company_id - * @param array $parameters - * @param array $headers - * @return mixed + * @param int $company_id */ - public function getMovies($company_id, array $parameters = [], array $headers = []) + public function getMovies($company_id, array $parameters = [], array $headers = []): array { return $this->get('company/' . $company_id . '/movies', $parameters, $headers); } diff --git a/lib/Tmdb/Api/Configuration.php b/lib/Tmdb/Api/Configuration.php index 4a48785f..f428a317 100644 --- a/lib/Tmdb/Api/Configuration.php +++ b/lib/Tmdb/Api/Configuration.php @@ -1,22 +1,23 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Api; /** - * Class Configuration - * @package Tmdb\Api + * Class Configuration. * * @see http://docs.themoviedb.apiary.io/#configuration */ @@ -38,19 +39,12 @@ class Configuration extends AbstractApi * Simply combine them all and you will have a fully qualified URL. Here’s an example URL: * * http://d3gtl9l2a4fn1j.cloudfront.net/t/p/w500/8uO0gUM8aNqYLs1OsTBQiXu0fEv.jpg - * - * @param array $headers - * @return mixed */ - public function getConfiguration(array $headers = []) + public function getConfiguration(array $headers = []): array { return $this->get('configuration', [], $headers); } - /** - * @param array $headers - * @return array - */ public function getLanguages(array $headers = []): array { return $this->get('configuration/languages', [], $headers); diff --git a/lib/Tmdb/Api/Credits.php b/lib/Tmdb/Api/Credits.php index e08c917c..0ed057ba 100644 --- a/lib/Tmdb/Api/Credits.php +++ b/lib/Tmdb/Api/Credits.php @@ -1,22 +1,24 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Api; /** - * Class Credits - * @package Tmdb\Api + * Class Credits. + * * @see http://docs.themoviedb.apiary.io/#credits */ class Credits extends AbstractApi @@ -33,13 +35,8 @@ class Credits extends AbstractApi * * Season credits are credits that were marked with the "add to every season" option in the editing interface * and are assumed to be "season regulars". - * - * @param $credit_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getCredit($credit_id, array $parameters = [], array $headers = []) + public function getCredit(string $credit_id, array $parameters = [], array $headers = []): array { return $this->get('credit/' . $credit_id, $parameters, $headers); } diff --git a/lib/Tmdb/Api/Discover.php b/lib/Tmdb/Api/Discover.php index c11cb8c3..3a639af6 100644 --- a/lib/Tmdb/Api/Discover.php +++ b/lib/Tmdb/Api/Discover.php @@ -1,34 +1,32 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Api; /** - * Class Discover - * @package Tmdb\Api + * Class Discover. + * * @see http://docs.themoviedb.apiary.io/#discover */ class Discover extends AbstractApi { /** * Discover movies by different types of data like average rating, number of votes, genres and certifications. - * - * @param array $parameters - * @param array $headers - * @return mixed */ - public function discoverMovies(array $parameters = [], array $headers = []) + public function discoverMovies(array $parameters = [], array $headers = []): array { return $this->get('discover/movie', $parameters, $headers); } @@ -36,12 +34,8 @@ public function discoverMovies(array $parameters = [], array $headers = []) /** * Discover TV shows by different types of data like average rating, number of votes, genres, * the network they aired on and air dates. - * - * @param array $parameters - * @param array $headers - * @return mixed */ - public function discoverTv(array $parameters = [], array $headers = []) + public function discoverTv(array $parameters = [], array $headers = []): array { return $this->get('discover/tv', $parameters, $headers); } diff --git a/lib/Tmdb/Api/Find.php b/lib/Tmdb/Api/Find.php index 8d29b9b2..a143d7a9 100644 --- a/lib/Tmdb/Api/Find.php +++ b/lib/Tmdb/Api/Find.php @@ -1,22 +1,24 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Api; /** - * Class Find - * @package Tmdb\Api + * Class Find. + * * @see http://docs.themoviedb.apiary.io/#find */ class Find extends AbstractApi @@ -33,18 +35,13 @@ class Find extends AbstractApi * Movies: imdb_id * People: imdb_id, freebase_mid, freebase_id, tvrage_id * TV Series: imdb_id, freebase_mid, freebase_id, tvdb_id, tvrage_id - * - * @param string $id - * @param array $parameters - * @param array $headers - * @return array */ public function findBy(string $id, array $parameters = [], array $headers = []): array { return $this->get( 'find/' . $id, $parameters, - $headers + $headers, ); } } diff --git a/lib/Tmdb/Api/Genres.php b/lib/Tmdb/Api/Genres.php index 2bd06155..e87f7350 100644 --- a/lib/Tmdb/Api/Genres.php +++ b/lib/Tmdb/Api/Genres.php @@ -1,39 +1,38 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Api; /** - * Class Genres - * @package Tmdb\Api + * Class Genres. + * * @see http://docs.themoviedb.apiary.io/#genres */ class Genres extends AbstractApi { /** - * Get the list of genres, and return one by id + * Get the list of genres, and return one by id. * - * @param integer $id - * @param array $parameters - * @param array $headers - * @return mixed + * @param int $id */ public function getGenre($id, array $parameters = [], array $headers = []) { $response = $this->getGenres($parameters, $headers); - if (null !== $response && array_key_exists('genres', $response)) { + if (null !== $response && \array_key_exists('genres', $response)) { return $this->extractGenreByIdFromResponse($id, $response['genres']); } @@ -42,54 +41,38 @@ public function getGenre($id, array $parameters = [], array $headers = []) /** * Get the list of genres. - * - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getGenres(array $parameters = [], array $headers = []) + public function getGenres(array $parameters = [], array $headers = []): array { - $data = array_merge_recursive( + return array_merge_recursive( $this->getMovieGenres($parameters, $headers), - $this->getTvGenres($parameters, $headers) + $this->getTvGenres($parameters, $headers), ); - - return $data; } /** * Get the list of movie genres. - * - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getMovieGenres(array $parameters = [], array $headers = []) + public function getMovieGenres(array $parameters = [], array $headers = []): array { return $this->get('genre/movie/list', $parameters, $headers); } /** * Get the list of TV genres. - * - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getTvGenres(array $parameters = [], array $headers = []) + public function getTvGenres(array $parameters = [], array $headers = []): array { return $this->get('genre/tv/list', $parameters, $headers); } /** - * @param integer $id - * @param array $data - * @return mixed + * @param int $id */ private function extractGenreByIdFromResponse($id, array $data = []) { foreach ($data as $genre) { - if ($id == $genre['id']) { + if ($id === $genre['id']) { return $genre; } } @@ -99,13 +82,8 @@ private function extractGenreByIdFromResponse($id, array $data = []) /** * Get the list of movies for a particular genre by id. By default, only movies with 10 or more votes are included. - * - * @param $genre_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getMovies($genre_id, array $parameters = [], array $headers = []) + public function getMovies(string $genre_id, array $parameters = [], array $headers = []): array { return $this->get('genre/' . $genre_id . '/movies', $parameters, $headers); } diff --git a/lib/Tmdb/Api/GuestSession.php b/lib/Tmdb/Api/GuestSession.php index 6aecfec5..9a3e5b17 100644 --- a/lib/Tmdb/Api/GuestSession.php +++ b/lib/Tmdb/Api/GuestSession.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ @@ -18,8 +20,8 @@ use Tmdb\Token\Session\SessionToken; /** - * Class GuestSession - * @package Tmdb\Api + * Class GuestSession. + * * @see http://docs.themoviedb.apiary.io/#guestsessions */ class GuestSession extends AbstractApi @@ -27,12 +29,9 @@ class GuestSession extends AbstractApi /** * Get a list of rated movies for a specific guest session id. * - * @param array $parameters - * @param array $headers - * @return mixed - * @throws MissingSessionTokenException when the guest session token was not set on the client. + * @throws MissingSessionTokenException when the guest session token was not set on the client */ - public function getRatedMovies(array $parameters = [], array $headers = []) + public function getRatedMovies(array $parameters = [], array $headers = []): array { $sessionToken = $this->client->getGuestSessionToken(); diff --git a/lib/Tmdb/Api/Jobs.php b/lib/Tmdb/Api/Jobs.php index 7dad85ef..3c4d79ad 100644 --- a/lib/Tmdb/Api/Jobs.php +++ b/lib/Tmdb/Api/Jobs.php @@ -1,34 +1,32 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Api; /** - * Class Jobs - * @package Tmdb\Api + * Class Jobs. + * * @see http://docs.themoviedb.apiary.io/#jobs */ class Jobs extends AbstractApi { /** * Get a list of valid jobs. - * - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getJobs(array $parameters = [], array $headers = []) + public function getJobs(array $parameters = [], array $headers = []): array { return $this->get('job/list', $parameters, $headers); } diff --git a/lib/Tmdb/Api/Keywords.php b/lib/Tmdb/Api/Keywords.php index 4c04f2a7..dd9f091c 100644 --- a/lib/Tmdb/Api/Keywords.php +++ b/lib/Tmdb/Api/Keywords.php @@ -1,22 +1,24 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Api; /** - * Class Keywords - * @package Tmdb\Api + * Class Keywords. + * * @see http://docs.themoviedb.apiary.io/#keywords */ class Keywords extends AbstractApi @@ -25,11 +27,8 @@ class Keywords extends AbstractApi * Get the basic information for a specific keyword id. * * @param int $keyword_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getKeyword($keyword_id, array $parameters = [], array $headers = []) + public function getKeyword($keyword_id, array $parameters = [], array $headers = []): array { return $this->get('keyword/' . $keyword_id, $parameters, $headers); } @@ -38,11 +37,8 @@ public function getKeyword($keyword_id, array $parameters = [], array $headers = * Get the list of movies for a particular keyword by id. * * @param int $keyword_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getMovies($keyword_id, array $parameters = [], array $headers = []) + public function getMovies($keyword_id, array $parameters = [], array $headers = []): array { return $this->get('keyword/' . $keyword_id . '/movies', $parameters, $headers); } diff --git a/lib/Tmdb/Api/Lists.php b/lib/Tmdb/Api/Lists.php index b6dcf4c4..916f1d00 100644 --- a/lib/Tmdb/Api/Lists.php +++ b/lib/Tmdb/Api/Lists.php @@ -1,35 +1,32 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Api; /** - * Class Lists - * @package Tmdb\Api + * Class Lists. + * * @see http://docs.themoviedb.apiary.io/#lists */ class Lists extends AbstractApi { /** * Get a list by id. - * - * @param string $list_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getList($list_id, array $parameters = [], array $headers = []) + public function getList(string $list_id, array $parameters = [], array $headers = []): array { return $this->get('list/' . $list_id, $parameters, $headers); } @@ -39,11 +36,8 @@ public function getList($list_id, array $parameters = [], array $headers = []) * * @param string $name * @param string $description - * @param array $parameters - * @param array $headers - * @return mixed */ - public function createList($name, $description, array $parameters = [], array $headers = []) + public function createList($name, $description, array $parameters = [], array $headers = []): array { return $this->postJson('list', ['name' => $name, 'description' => $description], $parameters, $headers); } @@ -51,29 +45,23 @@ public function createList($name, $description, array $parameters = [], array $h /** * Check to see if a movie ID is already added to a list. * - * @param string $id - * @param int $movieId - * @param array $parameters - * @param array $headers - * @return mixed + * @param int $movieId */ - public function getItemStatus($id, $movieId, array $parameters = [], array $headers = []) + public function getItemStatus(string $id, $movieId, array $parameters = [], array $headers = []): array { return $this->get( 'list/' . $id . '/item_status', array_merge($parameters, ['movie_id' => $movieId]), - $headers + $headers, ); } /** * This method lets users add new movies to a list that they created. A valid session id is required. * - * @param string $id * @param string|int $mediaId - * @return mixed */ - public function addMediaToList($id, $mediaId) + public function addMediaToList(string $id, $mediaId): array { return $this->postJson('list/' . $id . '/add_item', ['media_id' => $mediaId]); } @@ -81,22 +69,17 @@ public function addMediaToList($id, $mediaId) /** * This method lets users delete movies from a list that they created. A valid session id is required. * - * @param string $id * @param string|int $mediaId - * @return mixed */ - public function removeMediaFromList($id, $mediaId) + public function removeMediaFromList(string $id, $mediaId): array { return $this->postJson('list/' . $id . '/remove_item', ['media_id' => $mediaId]); } /** * This method lets users delete a list that they created. A valid session id is required. - * - * @param string $id - * @return mixed */ - public function deleteList($id) + public function deleteList(string $id): array { return $this->delete('list/' . $id); } @@ -107,16 +90,14 @@ public function deleteList($id) * This is a irreversible action and should be treated with caution. * A valid session id is required. * - * @param string $id - * @param boolean $confirm - * @return mixed + * @param bool $confirm */ - public function clearList($id, $confirm) + public function clearList(string $id, $confirm): array { return $this->post( 'list/' . $id . '/clear', null, - ['confirm' => (bool)$confirm === true ? 'true' : 'false'] + ['confirm' => (bool) $confirm ? 'true' : 'false'], ); } } diff --git a/lib/Tmdb/Api/Movies.php b/lib/Tmdb/Api/Movies.php index b7b139d5..f4dd9e7e 100644 --- a/lib/Tmdb/Api/Movies.php +++ b/lib/Tmdb/Api/Movies.php @@ -1,100 +1,72 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Api; /** - * Class Movies - * @package Tmdb\Api + * Class Movies. + * * @see http://docs.themoviedb.apiary.io/#movies */ class Movies extends AbstractApi { /** * Get the basic movie information for a specific movie id. - * - * @param $movie_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getMovie($movie_id, array $parameters = [], array $headers = []) + public function getMovie(string $movie_id, array $parameters = [], array $headers = []): array { return $this->get('movie/' . $movie_id, $parameters, $headers); } /** * Get the alternative titles for a specific movie id. - * - * @param $movie_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getAlternativeTitles($movie_id, array $parameters = [], array $headers = []) + public function getAlternativeTitles(string $movie_id, array $parameters = [], array $headers = []): array { return $this->get('movie/' . $movie_id . '/alternative_titles', $parameters, $headers); } /** * Get the cast and crew information for a specific movie id. - * - * @param $movie_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getCredits($movie_id, array $parameters = [], array $headers = []) + public function getCredits(string $movie_id, array $parameters = [], array $headers = []): array { return $this->get('movie/' . $movie_id . '/credits', $parameters, $headers); } /** * Get the images (posters and backdrops) for a specific movie id. - * - * @param $movie_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getImages($movie_id, array $parameters = [], array $headers = []) + public function getImages(string $movie_id, array $parameters = [], array $headers = []): array { return $this->get('movie/' . $movie_id . '/images', $parameters, $headers); } /** * Get the plot keywords for a specific movie id. - * - * @param $movie_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getKeywords($movie_id, array $parameters = [], array $headers = []) + public function getKeywords(string $movie_id, array $parameters = [], array $headers = []): array { return $this->get('movie/' . $movie_id . '/keywords', $parameters, $headers); } /** * Get the release date by country for a specific movie id. - * - * @param $movie_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getReleases($movie_id, array $parameters = [], array $headers = []) + public function getReleases(string $movie_id, array $parameters = [], array $headers = []): array { return $this->get('movie/' . $movie_id . '/releases', $parameters, $headers); } @@ -102,103 +74,65 @@ public function getReleases($movie_id, array $parameters = [], array $headers = /** * Get the trailers for a specific movie id. * - * @param $movie_id - * @param array $parameters - * @param array $headers - * @return mixed * @deprecated TMDB changed the way of requesting trailers, see getVideos instead! */ - public function getTrailers($movie_id, array $parameters = [], array $headers = []) + public function getTrailers(string $movie_id, array $parameters = [], array $headers = []): array { return $this->get('movie/' . $movie_id . '/trailers', $parameters, $headers); } /** * Get the translations for a specific movie id. - * - * @param $movie_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getTranslations($movie_id, array $parameters = [], array $headers = []) + public function getTranslations(string $movie_id, array $parameters = [], array $headers = []): array { return $this->get('movie/' . $movie_id . '/translations', $parameters, $headers); } /** * Get the similar movies for a specific movie id. - * - * @param $movie_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getSimilar($movie_id, array $parameters = [], array $headers = []) + public function getSimilar(string $movie_id, array $parameters = [], array $headers = []): array { return $this->get('movie/' . $movie_id . '/similar', $parameters, $headers); } /** * Get the recommended movies for a specific movie id. - * - * @param $movie_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getRecommendations($movie_id, array $parameters = [], array $headers = []) + public function getRecommendations(string $movie_id, array $parameters = [], array $headers = []): array { return $this->get('movie/' . $movie_id . '/recommendations', $parameters, $headers); } /** * Get the reviews for a particular movie id. - * - * @param $movie_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getReviews($movie_id, array $parameters = [], array $headers = []) + public function getReviews(string $movie_id, array $parameters = [], array $headers = []): array { return $this->get('movie/' . $movie_id . '/reviews', $parameters, $headers); } /** * Get the lists that the movie belongs to. - * - * @param $movie_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getLists($movie_id, array $parameters = [], array $headers = []) + public function getLists(string $movie_id, array $parameters = [], array $headers = []): array { return $this->get('movie/' . $movie_id . '/lists', $parameters, $headers); } /** * Get the changes for a specific movie id. - * - * @param $movie_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getChanges($movie_id, array $parameters = [], array $headers = []) + public function getChanges(string $movie_id, array $parameters = [], array $headers = []): array { return $this->get('movie/' . $movie_id . '/changes', $parameters, $headers); } /** * Get the latest movie id. - * - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getLatest(array $parameters = [], array $headers = []) + public function getLatest(array $parameters = [], array $headers = []): array { return $this->get('movie/latest', $parameters, $headers); } @@ -206,12 +140,8 @@ public function getLatest(array $parameters = [], array $headers = []) /** * Get the list of upcoming movies. This list refreshes every day. * The maximum number of items this list will include is 100. - * - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getUpcoming(array $parameters = [], array $headers = []) + public function getUpcoming(array $parameters = [], array $headers = []): array { return $this->get('movie/upcoming', $parameters, $headers); } @@ -219,12 +149,8 @@ public function getUpcoming(array $parameters = [], array $headers = []) /** * Get the list of movies playing in theatres. This list refreshes every day. * The maximum number of items this list will include is 100. - * - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getNowPlaying(array $parameters = [], array $headers = []) + public function getNowPlaying(array $parameters = [], array $headers = []): array { return $this->get('movie/now_playing', $parameters, $headers); } @@ -232,12 +158,8 @@ public function getNowPlaying(array $parameters = [], array $headers = []) /** * Get the list of popular movies on The Movie Database. * This list refreshes every day. - * - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getPopular(array $parameters = [], array $headers = []) + public function getPopular(array $parameters = [], array $headers = []): array { return $this->get('movie/popular', $parameters, $headers); } @@ -245,12 +167,8 @@ public function getPopular(array $parameters = [], array $headers = []) /** * Get the list of top rated movies. By default, this list will only include * movies that have 10 or more votes. This list refreshes every day. - * - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getTopRated(array $parameters = [], array $headers = []) + public function getTopRated(array $parameters = [], array $headers = []): array { return $this->get('movie/top_rated', $parameters, $headers); } @@ -261,10 +179,9 @@ public function getTopRated(array $parameters = [], array $headers = []) * * A valid session id is required. * - * @param integer $id - * @return mixed + * @param int $id */ - public function getAccountStates($id) + public function getAccountStates($id): array { return $this->get('movie/' . $id . '/account_states'); } @@ -274,50 +191,34 @@ public function getAccountStates($id) * * A valid session id or guest session id is required. * - * @param integer $id - * @param double $rating - * @return mixed + * @param int $id + * @param float $rating */ - public function rateMovie($id, $rating) + public function rateMovie($id, $rating): array { - return $this->postJson('movie/' . $id . '/rating', ['value' => (float)$rating]); + return $this->postJson('movie/' . $id . '/rating', ['value' => (float) $rating]); } /** * Get the videos (trailers, teasers, clips, etc...) for a specific movie id. - * - * @param $movie_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getVideos($movie_id, array $parameters = [], array $headers = []) + public function getVideos(string $movie_id, array $parameters = [], array $headers = []): array { return $this->get('movie/' . $movie_id . '/videos', $parameters, $headers); } /** * Get the watch providers (by region) for a specific movie id. - * - * @param $movie_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getWatchProviders($movie_id, array $parameters = [], array $headers = []) + public function getWatchProviders(string $movie_id, array $parameters = [], array $headers = []): array { return $this->get('movie/' . $movie_id . '/watch/providers', $parameters, $headers); } /** * Get the external ids that we have stored for a movie. - * - * @param $movie_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getExternalIds($movie_id, array $parameters = [], array $headers = []) + public function getExternalIds(string $movie_id, array $parameters = [], array $headers = []): array { return $this->get('movie/' . $movie_id . '/external_ids', $parameters, $headers); } diff --git a/lib/Tmdb/Api/Networks.php b/lib/Tmdb/Api/Networks.php index c0038caa..d0c57af6 100644 --- a/lib/Tmdb/Api/Networks.php +++ b/lib/Tmdb/Api/Networks.php @@ -1,22 +1,24 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Api; /** - * Class Networks - * @package Tmdb\Api + * Class Networks. + * * @see http://docs.themoviedb.apiary.io/#networks */ class Networks extends AbstractApi @@ -28,11 +30,8 @@ class Networks extends AbstractApi * At this time we don't have much but this will be fleshed out over time. * * @param int $network_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getNetwork($network_id, array $parameters = [], array $headers = []) + public function getNetwork($network_id, array $parameters = [], array $headers = []): array { return $this->get('network/' . $network_id, $parameters, $headers); } diff --git a/lib/Tmdb/Api/People.php b/lib/Tmdb/Api/People.php index 93c61039..538e153e 100644 --- a/lib/Tmdb/Api/People.php +++ b/lib/Tmdb/Api/People.php @@ -1,46 +1,38 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Api; /** - * Class People - * @package Tmdb\Api + * Class People. + * * @see http://docs.themoviedb.apiary.io/#people */ class People extends AbstractApi { /** * Get the general person information for a specific id. - * - * @param $person_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getPerson($person_id, array $parameters = [], array $headers = []) + public function getPerson($person_id, array $parameters = [], array $headers = []): array { return $this->get('person/' . $person_id, $parameters, $headers); } /** * Get the credits for a specific person id. - * - * @param $person_id - * @param array $parameters - * @param array $headers - * @return mixed */ public function getCredits($person_id, array $parameters = [], array $headers = []) { @@ -52,26 +44,16 @@ public function getCredits($person_id, array $parameters = [], array $headers = * * To get the expanded details for each TV record, call the /credit method with the provided credit_id. * This will provide details about which episode and/or season the credit is for. - * - * @param $person_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getCombinedCredits($person_id, array $parameters = [], array $headers = []) + public function getCombinedCredits($person_id, array $parameters = [], array $headers = []): array { return $this->get('person/' . $person_id . '/combined_credits', $parameters, $headers); } /** * Get the movie credits for a specific person id. - * - * @param $person_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getMovieCredits($person_id, array $parameters = [], array $headers = []) + public function getMovieCredits($person_id, array $parameters = [], array $headers = []): array { return $this->get('person/' . $person_id . '/movie_credits', $parameters, $headers); } @@ -81,26 +63,16 @@ public function getMovieCredits($person_id, array $parameters = [], array $heade * * To get the expanded details for each record, call the /credit method with the provided credit_id. * This will provide details about which episode and/or season the credit is for. - * - * @param $person_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getTvCredits($person_id, array $parameters = [], array $headers = []) + public function getTvCredits($person_id, array $parameters = [], array $headers = []): array { return $this->get('person/' . $person_id . '/tv_credits', $parameters, $headers); } /** * Get the images for a specific person id. - * - * @param $person_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getImages($person_id, array $parameters = [], array $headers = []) + public function getImages($person_id, array $parameters = [], array $headers = []): array { return $this->get('person/' . $person_id . '/images', $parameters, $headers); } @@ -113,26 +85,16 @@ public function getImages($person_id, array $parameters = [], array $headers = [ * By default, only the last 24 hours of changes are returned. * The maximum number of days that can be returned in a single request is 14. * The language is present on fields that are translatable. - * - * @param $person_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getChanges($person_id, array $parameters = [], array $headers = []) + public function getChanges($person_id, array $parameters = [], array $headers = []): array { return $this->get('person/' . $person_id . '/changes', $parameters, $headers); } /** * Get the external ids for a specific person id. - * - * @param $person_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getExternalIds($person_id, array $parameters = [], array $headers = []) + public function getExternalIds($person_id, array $parameters = [], array $headers = []): array { return $this->get('person/' . $person_id . '/external_ids', $parameters, $headers); } @@ -141,35 +103,24 @@ public function getExternalIds($person_id, array $parameters = [], array $header * Get the images that have been tagged with a specific person id. * * We return all of the image results with a media object mapped for each image. - * - * @param $person_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getTaggedImages($person_id, array $parameters = [], array $headers = []) + public function getTaggedImages($person_id, array $parameters = [], array $headers = []): array { return $this->get('person/' . $person_id . '/tagged_images', $parameters, $headers); } /** * Get the list of popular people on The Movie Database. This list refreshes every day. - * - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getPopular(array $parameters = [], array $headers = []) + public function getPopular(array $parameters = [], array $headers = []): array { return $this->get('person/popular', $parameters, $headers); } /** * Get the latest person id. - * - * @return mixed */ - public function getLatest() + public function getLatest(): array { return $this->get('person/latest'); } diff --git a/lib/Tmdb/Api/Reviews.php b/lib/Tmdb/Api/Reviews.php index a1f925ce..c1299991 100644 --- a/lib/Tmdb/Api/Reviews.php +++ b/lib/Tmdb/Api/Reviews.php @@ -1,35 +1,32 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Api; /** - * Class Reviews - * @package Tmdb\Api + * Class Reviews. + * * @see http://docs.themoviedb.apiary.io/#reviews */ class Reviews extends AbstractApi { /** * Get the full details of a review by ID. - * - * @param $review_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getReview($review_id, array $parameters = [], array $headers = []) + public function getReview(string $review_id, array $parameters = [], array $headers = []): array { return $this->get('review/' . $review_id, $parameters, $headers); } diff --git a/lib/Tmdb/Api/Search.php b/lib/Tmdb/Api/Search.php index d48dcad7..a21a52b7 100644 --- a/lib/Tmdb/Api/Search.php +++ b/lib/Tmdb/Api/Search.php @@ -1,22 +1,24 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Api; /** - * Class Search - * @package Tmdb\Api + * Class Search. + * * @see http://docs.themoviedb.apiary.io/#search */ class Search extends AbstractApi @@ -25,14 +27,11 @@ class Search extends AbstractApi * Search for movies by title. * * @param string $query - * @param array $parameters - * @param array $headers - * @return mixed */ - public function searchMovies($query, array $parameters = [], array $headers = []) + public function searchMovies($query, array $parameters = [], array $headers = []): array { return $this->get('search/movie', array_merge($parameters, [ - 'query' => $query + 'query' => $query, ], $headers)); } @@ -40,14 +39,11 @@ public function searchMovies($query, array $parameters = [], array $headers = [] * Search for collections by name. * * @param string $query - * @param array $parameters - * @param array $headers - * @return mixed */ - public function searchCollection($query, array $parameters = [], array $headers = []) + public function searchCollection($query, array $parameters = [], array $headers = []): array { return $this->get('search/collection', array_merge($parameters, [ - 'query' => $query + 'query' => $query, ], $headers)); } @@ -55,14 +51,11 @@ public function searchCollection($query, array $parameters = [], array $headers * Search for TV shows by title. * * @param string $query - * @param array $parameters - * @param array $headers - * @return mixed */ - public function searchTv($query, array $parameters = [], array $headers = []) + public function searchTv($query, array $parameters = [], array $headers = []): array { return $this->get('search/tv', array_merge($parameters, [ - 'query' => $query + 'query' => $query, ], $headers)); } @@ -70,29 +63,21 @@ public function searchTv($query, array $parameters = [], array $headers = []) * Search for people by name. * * @param string $query - * @param array $parameters - * @param array $headers - * @return mixed */ - public function searchPersons($query, array $parameters = [], array $headers = []) + public function searchPersons($query, array $parameters = [], array $headers = []): array { return $this->get('search/person', array_merge($parameters, [ - 'query' => $query + 'query' => $query, ], $headers)); } /** * Search for companies by name. - * - * @param $query - * @param array $parameters - * @param array $headers - * @return mixed */ - public function searchCompany(string $query, array $parameters = [], array $headers = []) + public function searchCompany(string $query, array $parameters = [], array $headers = []): array { return $this->get('search/company', array_merge($parameters, [ - 'query' => $query + 'query' => $query, ], $headers)); } @@ -100,14 +85,11 @@ public function searchCompany(string $query, array $parameters = [], array $head * Search for companies by name. * * @param string $query - * @param array $parameters - * @param array $headers - * @return mixed */ - public function searchKeyword($query, array $parameters = [], array $headers = []) + public function searchKeyword($query, array $parameters = [], array $headers = []): array { return $this->get('search/keyword', array_merge($parameters, [ - 'query' => $query + 'query' => $query, ], $headers)); } @@ -118,14 +100,11 @@ public function searchKeyword($query, array $parameters = [], array $headers = [ * Each mapped result is the same response you would get from each independent search. * * @param string $query - * @param array $parameters - * @param array $headers - * @return mixed */ - public function searchMulti($query, array $parameters = [], array $headers = []) + public function searchMulti($query, array $parameters = [], array $headers = []): array { return $this->get('search/multi', array_merge($parameters, [ - 'query' => $query + 'query' => $query, ], $headers)); } } diff --git a/lib/Tmdb/Api/Timezones.php b/lib/Tmdb/Api/Timezones.php index b015eb86..0c598867 100644 --- a/lib/Tmdb/Api/Timezones.php +++ b/lib/Tmdb/Api/Timezones.php @@ -1,32 +1,32 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Api; /** - * Class Timezones - * @package Tmdb\Api + * Class Timezones. + * * @see http://docs.themoviedb.apiary.io/#timezones */ class Timezones extends AbstractApi { /** * Get the list of supported timezones for the API methods that support them. - * - * @return mixed */ - public function getTimezones() + public function getTimezones(): array { return $this->get('timezones/list'); } diff --git a/lib/Tmdb/Api/Tv.php b/lib/Tmdb/Api/Tv.php index ab6f0af3..5790d223 100644 --- a/lib/Tmdb/Api/Tv.php +++ b/lib/Tmdb/Api/Tv.php @@ -1,22 +1,24 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Api; /** - * Class Tv - * @package Tmdb\Api + * Class Tv. + * * @see http://docs.themoviedb.apiary.io/#tv */ class Tv extends AbstractApi @@ -24,12 +26,9 @@ class Tv extends AbstractApi /** * Get the primary information about a TV series by id. * - * @param integer $tvshow_id - * @param array $parameters - * @param array $headers - * @return mixed + * @param int $tvshow_id */ - public function getTvshow($tvshow_id, array $parameters = [], array $headers = []) + public function getTvshow($tvshow_id, array $parameters = [], array $headers = []): array { return $this->get('tv/' . $tvshow_id, $parameters, $headers); } @@ -37,63 +36,40 @@ public function getTvshow($tvshow_id, array $parameters = [], array $headers = [ /** * Get the cast & crew information about a TV series. * Just like the website, we pull this information from the last season of the series. - * - * @param $tvshow_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getCredits($tvshow_id, array $parameters = [], array $headers = []) + public function getCredits(string $tvshow_id, array $parameters = [], array $headers = []): array { return $this->get('tv/' . $tvshow_id . '/credits', $parameters, $headers); } /** * Get the content ratings for a specific TV show id. - * @param $tvshow_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getContentRatings($tvshow_id, array $parameters = [], array $headers = []) + public function getContentRatings(string $tvshow_id, array $parameters = [], array $headers = []): array { return $this->get('tv/' . $tvshow_id . '/content_ratings', $parameters, $headers); } /** * Get the external ids that we have stored for a TV series. - * - * @param $tvshow_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getExternalIds($tvshow_id, array $parameters = [], array $headers = []) + public function getExternalIds(string $tvshow_id, array $parameters = [], array $headers = []): array { return $this->get('tv/' . $tvshow_id . '/external_ids', $parameters, $headers); } /** * Get the images (posters and backdrops) for a TV series. - * - * @param $tvshow_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getImages($tvshow_id, array $parameters = [], array $headers = []) + public function getImages(string $tvshow_id, array $parameters = [], array $headers = []): array { return $this->get('tv/' . $tvshow_id . '/images', $parameters, $headers); } /** * Get the list of popular TV shows. This list refreshes every day. - * - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getPopular(array $parameters = [], array $headers = []) + public function getPopular(array $parameters = [], array $headers = []): array { return $this->get('tv/popular', $parameters, $headers); } @@ -103,12 +79,8 @@ public function getPopular(array $parameters = [], array $headers = []) * * By default, this list will only include TV shows that have 2 or more votes. * This list refreshes every day. - * - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getTopRated(array $parameters = [], array $headers = []) + public function getTopRated(array $parameters = [], array $headers = []): array { return $this->get('tv/top_rated', $parameters, $headers); } @@ -119,11 +91,8 @@ public function getTopRated(array $parameters = [], array $headers = []) * These translations cascade down to the episode level. * * @param int $tvshow_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getTranslations($tvshow_id, array $parameters = [], array $headers = []) + public function getTranslations($tvshow_id, array $parameters = [], array $headers = []): array { return $this->get('tv/' . $tvshow_id . '/translations', $parameters, $headers); } @@ -132,12 +101,8 @@ public function getTranslations($tvshow_id, array $parameters = [], array $heade * Get the list of TV shows that are currently on the air. * * This query looks for any TV show that has an episode with an air date in the next 7 days. - * - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getOnTheAir(array $parameters = [], array $headers = []) + public function getOnTheAir(array $parameters = [], array $headers = []): array { return $this->get('tv/on_the_air', $parameters, $headers); } @@ -146,38 +111,26 @@ public function getOnTheAir(array $parameters = [], array $headers = []) * Get the list of TV shows that air today. * * Without a specified timezone, this query defaults to EST (Eastern Time UTC-05:00). - * - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getAiringToday(array $parameters = [], array $headers = []) + public function getAiringToday(array $parameters = [], array $headers = []): array { return $this->get('tv/airing_today', $parameters, $headers); } /** - * Get the videos that have been added to a TV series (trailers, opening credits, etc...) + * Get the videos that have been added to a TV series (trailers, opening credits, etc...). * * @param int $tvshow_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getVideos($tvshow_id, array $parameters = [], array $headers = []) + public function getVideos($tvshow_id, array $parameters = [], array $headers = []): array { return $this->get('tv/' . $tvshow_id . '/videos', $parameters, $headers); } /** * Get the watch providers (by region) for a specific movie id. - * - * @param $movie_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getWatchProviders($tvshow_id, array $parameters = [], array $headers = []) + public function getWatchProviders(string $tvshow_id, array $parameters = [], array $headers = []): array { return $this->get('tv/' . $tvshow_id . '/watch/providers', $parameters, $headers); } @@ -195,64 +148,40 @@ public function getWatchProviders($tvshow_id, array $parameters = [], array $hea * These keys will contain a series_id and episode_id. * * You can use the /tv/season/{id}/changes and /tv/episode/{id}/changes methods to look up these specific changes. - * - * @param $tvshow_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getChanges($tvshow_id, array $parameters = [], array $headers = []) + public function getChanges(string $tvshow_id, array $parameters = [], array $headers = []): array { return $this->get('tv/' . $tvshow_id . '/changes', $parameters, $headers); } /** * Get the latest TV show id. - * - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getLatest(array $parameters = [], array $headers = []) + public function getLatest(array $parameters = [], array $headers = []): array { return $this->get('tv/latest', $parameters, $headers); } /** * Get the plot keywords for a specific TV show id. - * - * @param $tvshow_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getKeywords($tvshow_id, array $parameters = [], array $headers = []) + public function getKeywords(string $tvshow_id, array $parameters = [], array $headers = []): array { return $this->get('tv/' . $tvshow_id . '/keywords', $parameters, $headers); } /** * Get the similar TV shows for a specific tv id. - * - * @param $tvshow_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getSimilar($tvshow_id, array $parameters = [], array $headers = []) + public function getSimilar(string $tvshow_id, array $parameters = [], array $headers = []): array { return $this->get('tv/' . $tvshow_id . '/similar', $parameters, $headers); } /** * Get the recommended TV shows for a specific tv id. - * - * @param $tvshow_id - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getRecommendations($tvshow_id, array $parameters = [], array $headers = []) + public function getRecommendations(string $tvshow_id, array $parameters = [], array $headers = []): array { return $this->get('tv/' . $tvshow_id . '/recommendations', $parameters, $headers); } @@ -263,10 +192,9 @@ public function getRecommendations($tvshow_id, array $parameters = [], array $he * * A valid session id is required. * - * @param integer $id - * @return mixed + * @param int $id */ - public function getAccountStates($id) + public function getAccountStates($id): array { return $this->get('tv/' . $id . '/account_states'); } @@ -276,24 +204,20 @@ public function getAccountStates($id) * * A valid session id or guest session id is required. * - * @param integer $id - * @param double $rating - * @return mixed + * @param int $id + * @param float $rating */ - public function rateTvShow($id, $rating) + public function rateTvShow($id, $rating): array { - return $this->postJson('tv/' . $id . '/rating', ['value' => (float)$rating]); + return $this->postJson('tv/' . $id . '/rating', ['value' => (float) $rating]); } /** * Get the alternative titles for a specific show ID. * - * @param integer $id - * @param array $parameters - * @param array $headers - * @return mixed + * @param int $id */ - public function getAlternativeTitles($id, array $parameters = [], array $headers = []) + public function getAlternativeTitles($id, array $parameters = [], array $headers = []): array { return $this->get('tv/' . $id . '/alternative_titles', $parameters, $headers); } @@ -301,10 +225,9 @@ public function getAlternativeTitles($id, array $parameters = [], array $headers /** * Get the alternative titles for a specific show ID. * - * @param integer $id - * @return mixed + * @param int $id */ - public function getEpisodeGroups($id) + public function getEpisodeGroups($id): array { return $this->get('tv/' . $id . '/episode_groups'); } diff --git a/lib/Tmdb/Api/TvEpisode.php b/lib/Tmdb/Api/TvEpisode.php index 02b764a6..325469ac 100644 --- a/lib/Tmdb/Api/TvEpisode.php +++ b/lib/Tmdb/Api/TvEpisode.php @@ -1,195 +1,159 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Api; /** - * Class TvEpisode - * @package Tmdb\Api + * Class TvEpisode. + * * @see http://docs.themoviedb.apiary.io/#tvepisodes */ class TvEpisode extends AbstractApi { /** * Get the primary information about a TV episode by combination of a season and episode number. - * - * @param $tvshow_id - * @param $season_number - * @param $episode_number - * @param array $parameters - * @param array $headers - * @return mixed */ public function getEpisode( $tvshow_id, $season_number, $episode_number, array $parameters = [], - array $headers = [] - ) { + array $headers = [], + ): array { return $this->get( - sprintf( + \sprintf( 'tv/%s/season/%s/episode/%s', $tvshow_id, $season_number, - $episode_number + $episode_number, ), $parameters, - $headers + $headers, ); } /** * Get the TV episode credits by combination of season and episode number. - * - * @param $tvshow_id - * @param $season_number - * @param $episode_number - * @param array $parameters - * @param array $headers - * @return mixed */ public function getCredits( $tvshow_id, $season_number, $episode_number, array $parameters = [], - array $headers = [] - ) { + array $headers = [], + ): array { return $this->get( - sprintf( + \sprintf( 'tv/%s/season/%s/episode/%s/credits', $tvshow_id, $season_number, - $episode_number + $episode_number, ), $parameters, - $headers + $headers, ); } /** * Get the external ids for a TV episode by comabination of a season and episode number. - * - * @param $tvshow_id - * @param $season_number - * @param $episode_number - * @param array $parameters - * @param array $headers - * @return mixed */ public function getExternalIds( $tvshow_id, $season_number, $episode_number, array $parameters = [], - array $headers = [] - ) { + array $headers = [], + ): array { return $this->get( - sprintf( + \sprintf( 'tv/%s/season/%s/episode/%s/external_ids', $tvshow_id, $season_number, - $episode_number + $episode_number, ), $parameters, - $headers + $headers, ); } /** * Get the images (episode stills) for a TV episode by combination of a season and episode number. - * - * @param $tvshow_id - * @param $season_number - * @param $episode_number - * @param array $parameters - * @param array $headers - * @return mixed */ public function getImages( $tvshow_id, $season_number, $episode_number, array $parameters = [], - array $headers = [] - ) { + array $headers = [], + ): array { return $this->get( - sprintf( + \sprintf( 'tv/%s/season/%s/episode/%s/images', $tvshow_id, $season_number, - $episode_number + $episode_number, ), $parameters, - $headers + $headers, ); } /** * Get the list of translations that exist for a TV episode. * - * @param int $tvshow_id - * @param array $parameters - * @param array $headers - * @return mixed + * @param int $tvshow_id */ public function getTranslations( $tvshow_id, $season_number, $episode_number, array $parameters = [], - array $headers = [] - ) { + array $headers = [], + ): array { return $this->get( - sprintf( + \sprintf( 'tv/%s/season/%s/episode/%s/translations', $tvshow_id, $season_number, - $episode_number + $episode_number, ), $parameters, - $headers + $headers, ); } /** - * Get the videos that have been added to a TV episode (teasers, clips, etc...) - * - * @param $tvshow_id - * @param $season_number - * @param $episode_number - * @param array $parameters - * @param array $headers - * @return mixed + * Get the videos that have been added to a TV episode (teasers, clips, etc...). */ public function getVideos( $tvshow_id, $season_number, $episode_number, array $parameters = [], - array $headers = [] - ) { + array $headers = [], + ): array { return $this->get( - sprintf( + \sprintf( 'tv/%s/season/%s/episode/%s/videos', $tvshow_id, $season_number, - $episode_number + $episode_number, ), $parameters, - $headers + $headers, ); } @@ -198,30 +162,23 @@ public function getVideos( * * This method is used in conjunction with the /tv/{id}/changes method. * This method uses the episode_id value found in the change entries. - * - * @param $tvshow_id - * @param $season_number - * @param $episode_number - * @param array $parameters - * @param array $headers - * @return mixed */ public function getChanges( $tvshow_id, $season_number, $episode_number, array $parameters = [], - array $headers = [] - ) { + array $headers = [], + ): array { return $this->get( - sprintf( + \sprintf( 'tv/%s/season/%s/episode/%s/changes', $tvshow_id, $season_number, - $episode_number + $episode_number, ), $parameters, - $headers + $headers, ); } @@ -229,25 +186,19 @@ public function getChanges( * This method lets users get the status of whether or not the TV episode has been rated. * * A valid session id is required. - * - * @param $tvshow_id - * @param $season_number - * @param $episode_number - * - * @return mixed */ public function getAccountStates( $tvshow_id, $season_number, - $episode_number - ) { + $episode_number, + ): array { return $this->get( - sprintf( + \sprintf( 'tv/%s/season/%s/episode/%s/account_states', $tvshow_id, $season_number, - $episode_number - ) + $episode_number, + ), ); } @@ -256,27 +207,22 @@ public function getAccountStates( * * A valid session id or guest session id is required. * - * @param $tvshow_id - * @param $season_number - * @param $episode_number - * @param double $rating - * - * @return mixed + * @param float $rating */ public function rateTvEpisode( $tvshow_id, $season_number, $episode_number, - $rating - ) { + $rating, + ): array { return $this->postJson( - sprintf( + \sprintf( 'tv/%s/season/%s/episode/%s/rating', $tvshow_id, $season_number, - $episode_number + $episode_number, ), - ['value' => (float)$rating] + ['value' => (float) $rating], ); } } diff --git a/lib/Tmdb/Api/TvEpisodeGroup.php b/lib/Tmdb/Api/TvEpisodeGroup.php index 76b111e2..e2ccaf8c 100644 --- a/lib/Tmdb/Api/TvEpisodeGroup.php +++ b/lib/Tmdb/Api/TvEpisodeGroup.php @@ -1,46 +1,43 @@ get( - sprintf( + \sprintf( 'tv/episode_group/%s', - $episode_group + $episode_group, ), $parameters, - $headers + $headers, ); } } diff --git a/lib/Tmdb/Api/TvSeason.php b/lib/Tmdb/Api/TvSeason.php index 61ebad47..e8094300 100644 --- a/lib/Tmdb/Api/TvSeason.php +++ b/lib/Tmdb/Api/TvSeason.php @@ -1,94 +1,66 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Api; /** - * Class TvSeason - * @package Tmdb\Api + * Class TvSeason. + * * @see http://docs.themoviedb.apiary.io/#tvseasons */ class TvSeason extends AbstractApi { /** * Get the primary information about a TV season by its season number. - * - * @param $tvshow_id - * @param $season_number - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getSeason(int $tvshow_id, int $season_number, array $parameters = [], array $headers = []) + public function getSeason(int $tvshow_id, int $season_number, array $parameters = [], array $headers = []): array { - return $this->get(sprintf('tv/%s/season/%s', $tvshow_id, $season_number), $parameters, $headers); + return $this->get(\sprintf('tv/%s/season/%s', $tvshow_id, $season_number), $parameters, $headers); } /** * Get the cast & crew credits for a TV season by season number. - * - * @param $tvshow_id - * @param $season_number - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getCredits($tvshow_id, $season_number, array $parameters = [], array $headers = []) + public function getCredits($tvshow_id, $season_number, array $parameters = [], array $headers = []): array { - return $this->get(sprintf('tv/%s/season/%s/credits', $tvshow_id, $season_number), $parameters, $headers); + return $this->get(\sprintf('tv/%s/season/%s/credits', $tvshow_id, $season_number), $parameters, $headers); } /** * Get the external ids that we have stored for a TV season by season number. - * - * @param $tvshow_id - * @param $season_number - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getExternalIds($tvshow_id, $season_number, array $parameters = [], array $headers = []) + public function getExternalIds($tvshow_id, $season_number, array $parameters = [], array $headers = []): array { - return $this->get(sprintf('tv/%s/season/%s/external_ids', $tvshow_id, $season_number), $parameters, $headers); + return $this->get(\sprintf('tv/%s/season/%s/external_ids', $tvshow_id, $season_number), $parameters, $headers); } /** * Get the images (posters) that we have stored for a TV season by season number. - * - * @param $tvshow_id - * @param $season_number - * @param array $parameters - * @param array $headers - * @return mixed */ - public function getImages($tvshow_id, $season_number, array $parameters = [], array $headers = []) + public function getImages($tvshow_id, $season_number, array $parameters = [], array $headers = []): array { - return $this->get(sprintf('tv/%s/season/%s/images', $tvshow_id, $season_number), $parameters, $headers); + return $this->get(\sprintf('tv/%s/season/%s/images', $tvshow_id, $season_number), $parameters, $headers); } /** - * Get the videos that have been added to a TV season (trailers, teasers, etc...) - * - * @param $tvshow_id - * @param $season_number - * @param array $parameters - * @param array $headers - * @return mixed + * Get the videos that have been added to a TV season (trailers, teasers, etc...). */ - public function getVideos($tvshow_id, $season_number, array $parameters = [], array $headers = []) + public function getVideos($tvshow_id, $season_number, array $parameters = [], array $headers = []): array { - return $this->get(sprintf('tv/%s/season/%s/videos', $tvshow_id, $season_number), $parameters, $headers); + return $this->get(\sprintf('tv/%s/season/%s/videos', $tvshow_id, $season_number), $parameters, $headers); } /** @@ -97,14 +69,11 @@ public function getVideos($tvshow_id, $season_number, array $parameters = [], ar * * This method uses the season_id value found in the change entries. * - * @param integer $tvshow_id - * @param integer $season_number - * @param array $parameters - * @param array $headers - * @return mixed + * @param int $tvshow_id + * @param int $season_number */ - public function getChanges($tvshow_id, $season_number, array $parameters = [], array $headers = []) + public function getChanges($tvshow_id, $season_number, array $parameters = [], array $headers = []): array { - return $this->get(sprintf('tv/%s/season/%s/changes', $tvshow_id, $season_number), $parameters, $headers); + return $this->get(\sprintf('tv/%s/season/%s/changes', $tvshow_id, $season_number), $parameters, $headers); } } diff --git a/lib/Tmdb/ApiMethodsTrait.php b/lib/Tmdb/ApiMethodsTrait.php index aed724ae..eb310e59 100644 --- a/lib/Tmdb/ApiMethodsTrait.php +++ b/lib/Tmdb/ApiMethodsTrait.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ @@ -16,202 +18,127 @@ trait ApiMethodsTrait { - /** - * @return Api\Account - */ - public function getAccountApi() + public function getAccountApi(): \Tmdb\Api\Account { return new Api\Account($this); } - /** - * @return Api\Authentication - */ - public function getAuthenticationApi() + public function getAuthenticationApi(): \Tmdb\Api\Authentication { return new Api\Authentication($this); } - /** - * @return Api\Certifications - */ - public function getCertificationsApi() + public function getCertificationsApi(): \Tmdb\Api\Certifications { return new Api\Certifications($this); } - /** - * @return Api\Changes - */ - public function getChangesApi() + public function getChangesApi(): \Tmdb\Api\Changes { return new Api\Changes($this); } - /** - * @return Api\Collections - */ - public function getCollectionsApi() + public function getCollectionsApi(): \Tmdb\Api\Collections { return new Api\Collections($this); } - /** - * @return Api\Companies - */ - public function getCompaniesApi() + public function getCompaniesApi(): \Tmdb\Api\Companies { return new Api\Companies($this); } - /** - * @return Api\Configuration - */ - public function getConfigurationApi() + public function getConfigurationApi(): \Tmdb\Api\Configuration { return new Api\Configuration($this); } - /** - * @return Api\Credits - */ - public function getCreditsApi() + public function getCreditsApi(): \Tmdb\Api\Credits { return new Api\Credits($this); } - /** - * @return Api\Discover - */ - public function getDiscoverApi() + public function getDiscoverApi(): \Tmdb\Api\Discover { return new Api\Discover($this); } - /** - * @return Api\Find - */ - public function getFindApi() + public function getFindApi(): \Tmdb\Api\Find { return new Api\Find($this); } - /** - * @return Api\Genres - */ - public function getGenresApi() + public function getGenresApi(): \Tmdb\Api\Genres { return new Api\Genres($this); } - /** - * @return Api\GuestSession - */ - public function getGuestSessionApi() + public function getGuestSessionApi(): \Tmdb\Api\GuestSession { return new Api\GuestSession($this); } - /** - * @return Api\Jobs - */ - public function getJobsApi() + public function getJobsApi(): \Tmdb\Api\Jobs { return new Api\Jobs($this); } - /** - * @return Api\Keywords - */ - public function getKeywordsApi() + public function getKeywordsApi(): \Tmdb\Api\Keywords { return new Api\Keywords($this); } - /** - * @return Api\Lists - */ - public function getListsApi() + public function getListsApi(): \Tmdb\Api\Lists { return new Api\Lists($this); } - /** - * @return Api\Movies - */ - public function getMoviesApi() + public function getMoviesApi(): \Tmdb\Api\Movies { return new Api\Movies($this); } - /** - * @return Api\Networks - */ - public function getNetworksApi() + public function getNetworksApi(): \Tmdb\Api\Networks { return new Api\Networks($this); } - /** - * @return Api\People - */ - public function getPeopleApi() + public function getPeopleApi(): \Tmdb\Api\People { return new Api\People($this); } - /** - * @return Api\Reviews - */ - public function getReviewsApi() + public function getReviewsApi(): \Tmdb\Api\Reviews { return new Api\Reviews($this); } - /** - * @return Api\Search - */ - public function getSearchApi() + public function getSearchApi(): \Tmdb\Api\Search { return new Api\Search($this); } - /** - * @return Api\Timezones - */ - public function getTimezonesApi() + public function getTimezonesApi(): \Tmdb\Api\Timezones { return new Api\Timezones($this); } - /** - * @return Api\Tv - */ - public function getTvApi() + public function getTvApi(): \Tmdb\Api\Tv { return new Api\Tv($this); } - /** - * @return Api\TvSeason - */ - public function getTvSeasonApi() + public function getTvSeasonApi(): \Tmdb\Api\TvSeason { return new Api\TvSeason($this); } - /** - * @return Api\TvEpisode - */ - public function getTvEpisodeApi() + public function getTvEpisodeApi(): \Tmdb\Api\TvEpisode { return new Api\TvEpisode($this); } - /** - * @return Api\TvEpisodeGroup - */ - public function getTvEpisodeGroupApi() + public function getTvEpisodeGroupApi(): \Tmdb\Api\TvEpisodeGroup { return new Api\TvEpisodeGroup($this); } diff --git a/lib/Tmdb/Client.php b/lib/Tmdb/Client.php index 36468168..fd7d68e9 100644 --- a/lib/Tmdb/Client.php +++ b/lib/Tmdb/Client.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ @@ -28,11 +30,9 @@ use Tmdb\Token\Api\BearerToken; use Tmdb\Token\Session\GuestSessionToken; use Tmdb\Token\Session\SessionBearerToken; -use Tmdb\Token\Session\SessionToken; /** - * Client wrapper for TMDB - * @package Tmdb + * Client wrapper for TMDB. */ class Client { @@ -51,21 +51,17 @@ class Client public const SCHEME_SECURE = 'https'; /** - * Stores the HTTP Client - * - * @var HttpClient + * Stores the HTTP Client. */ - private $httpClient; + private \Tmdb\HttpClient\HttpClient $httpClient; /** - * Store the options - * - * @var array + * Store the options. */ - private $options = []; + private array $options = []; /** - * Construct our client + * Construct our client. * * @param ConfigurationInterface|array $options */ @@ -79,9 +75,8 @@ public function __construct($options = []) } /** - * Configure options + * Configure options. * - * @param array $options * @return array */ protected function configureOptions(array $options) @@ -95,7 +90,7 @@ protected function configureOptions(array $options) 'base_uri' => null, 'api_token' => null, 'guest_session_token' => null, - 'http' => function (OptionsResolver $optionsResolver) { + 'http' => function (OptionsResolver $optionsResolver): void { $optionsResolver->setDefaults( [ 'client' => null, @@ -103,7 +98,7 @@ protected function configureOptions(array $options) 'response_factory' => null, 'stream_factory' => null, 'uri_factory' => null, - ] + ], ); $optionsResolver->setRequired( [ @@ -111,8 +106,8 @@ protected function configureOptions(array $options) 'request_factory', 'response_factory', 'stream_factory', - 'uri_factory' - ] + 'uri_factory', + ], ); $optionsResolver->setAllowedTypes('client', [ClientInterface::class, 'null']); $optionsResolver->setAllowedTypes('request_factory', [RequestFactoryInterface::class, 'null']); @@ -120,28 +115,28 @@ protected function configureOptions(array $options) $optionsResolver->setAllowedTypes('stream_factory', [StreamFactoryInterface::class, 'null']); $optionsResolver->setAllowedTypes('uri_factory', [UriFactoryInterface::class, 'null']); }, - 'hydration' => function (OptionsResolver $optionsResolver) { + 'hydration' => function (OptionsResolver $optionsResolver): void { $optionsResolver->setDefaults( [ 'event_listener_handles_hydration' => false, - 'only_for_specified_models' => [] - ] + 'only_for_specified_models' => [], + ], ); $optionsResolver->setAllowedTypes('event_listener_handles_hydration', ['bool']); // @todo 4.1 validate these are actually models $optionsResolver->setAllowedTypes('only_for_specified_models', ['array']); }, - 'event_dispatcher' => function (OptionsResolver $optionsResolver) { + 'event_dispatcher' => function (OptionsResolver $optionsResolver): void { $optionsResolver->setDefaults( [ - 'adapter' => null - ] + 'adapter' => null, + ], ); $optionsResolver->setRequired(['adapter']); $optionsResolver->setAllowedTypes('adapter', [EventDispatcherInterface::class]); - } - ] + }, + ], ); $resolver->setRequired( @@ -151,7 +146,7 @@ protected function configureOptions(array $options) 'secure', 'http', 'event_dispatcher', - ] + ], ); $resolver->setAllowedTypes('host', ['string']); @@ -168,16 +163,16 @@ protected function configureOptions(array $options) [ GuestSessionToken::class, SessionBearerToken::class, - 'null' - ] + 'null', + ], ); - if (is_string($options['api_token'])) { + if (\is_string($options['api_token'])) { $options['api_token'] = new ApiToken($options['api_token']); } $this->options = $this->postResolve( - $resolver->resolve($options) + $resolver->resolve($options), ); $this->httpClient = new HttpClient( @@ -185,62 +180,54 @@ protected function configureOptions(array $options) 'http' => $this->options['http'], 'event_dispatcher' => $this->options['event_dispatcher'], 'base_uri' => $this->options['base_uri'], - 'hydration' => $this->options['hydration'] - ] + 'hydration' => $this->options['hydration'], + ], ); return $this->options; } /** - * Post resolve - * - * @param array $options - * @return array + * Post resolve. */ protected function postResolve(array $options = []): array { - $options['http']['client'] = $options['http']['client'] ?? + $options['http']['client'] ??= Psr18ClientDiscovery::find(); - $options['http']['request_factory'] = $options['http']['request_factory'] ?? + $options['http']['request_factory'] ??= Psr17FactoryDiscovery::findRequestFactory(); - $options['http']['response_factory'] = $options['http']['response_factory'] ?? + $options['http']['response_factory'] ??= Psr17FactoryDiscovery::findResponseFactory(); - $options['http']['stream_factory'] = $options['http']['stream_factory'] ?? + $options['http']['stream_factory'] ??= Psr17FactoryDiscovery::findStreamFactory(); - $options['http']['uri_factory'] = $options['http']['uri_factory'] ?? + $options['http']['uri_factory'] ??= Psr17FactoryDiscovery::findUriFactory(); // Automatically enable event listener acceptance if the end-user forgot to enable this. if ( - !empty($options['hydration']['only_for_specified_models']) && - !$options['hydration']['event_listener_handles_hydration'] + !empty($options['hydration']['only_for_specified_models']) + && !$options['hydration']['event_listener_handles_hydration'] ) { $options['hydration']['event_listener_handles_hydration'] = true; } - $options['base_uri'] = sprintf( + $options['base_uri'] = \sprintf( '%s://%s', $options['secure'] ? self::SCHEME_SECURE : self::SCHEME_INSECURE, - $options['host'] + $options['host'], ); return $options; } /** - * Get the event dispatcher - * - * @return EventDispatcherInterface + * Get the event dispatcher. */ public function getEventDispatcher(): EventDispatcherInterface { return $this->options['event_dispatcher']['adapter']; } - /** - * @return HttpClient - */ public function getHttpClient(): HttpClient { return $this->httpClient; @@ -254,18 +241,11 @@ public function getOptions() return $this->options; } - /** - * @return GuestSessionToken|null - */ public function getGuestSessionToken(): ?GuestSessionToken { return $this->options['guest_session_token']; } - /** - * @param GuestSessionToken|null $guestSessionToken - * @return self - */ public function setGuestSessionToken(?GuestSessionToken $guestSessionToken): Client { $this->options['guest_session_token'] = $guestSessionToken; @@ -273,21 +253,16 @@ public function setGuestSessionToken(?GuestSessionToken $guestSessionToken): Cli return $this; } - /** - * @return ApiToken|BearerToken - */ public function getToken(): ApiToken { return $this->options['api_token']; } /** - * @param string $key - * * @return array|mixed */ public function getOption(string $key) { - return array_key_exists($key, $this->options) ? $this->options[$key] : null; + return $this->options[$key] ?? null; } } diff --git a/lib/Tmdb/Common/ObjectHydrator.php b/lib/Tmdb/Common/ObjectHydrator.php index ff1c15f6..9dc971fe 100644 --- a/lib/Tmdb/Common/ObjectHydrator.php +++ b/lib/Tmdb/Common/ObjectHydrator.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ @@ -21,36 +23,30 @@ * Utilisation class to hydrate objects. * * Class ObjectHydrator - * @package Tmdb\Common */ class ObjectHydrator { /** - * Hydrate the object with data + * Hydrate the object with data. * - * @param AbstractModel $object * @param array $data - * @return AbstractModel + * + * * @throws RuntimeException */ - public function hydrate(AbstractModel $object, $data = []) + public function hydrate(AbstractModel $object, $data = []): AbstractModel { if (!empty($data)) { foreach ($data as $k => $v) { - if (in_array($k, $object::$properties)) { + if (\in_array($k, $object::$properties, true)) { $method = $this->camelize( - sprintf('set_%s', $k) + \sprintf('set_%s', $k), ); - if (!is_callable([$object, $method])) { - throw new RuntimeException(sprintf( - 'Trying to call method "%s" on "%s" but it does not exist or is private.', - $method, - get_class($object) - )); - } else { - $object->$method($v); + if (!\is_callable([$object, $method])) { + throw new RuntimeException(\sprintf('Trying to call method "%s" on "%s" but it does not exist or is private.', $method, $object::class)); } + $object->{$method}($v); } } } @@ -59,14 +55,13 @@ public function hydrate(AbstractModel $object, $data = []) } /** - * Transforms an under_scored_string to a camelCasedOne + * Transforms an under_scored_string to a camelCasedOne. * * @see https://gist.github.com/troelskn/751517 * * @param string $candidate - * @return string */ - public function camelize($candidate) + public function camelize($candidate): string { return lcfirst( implode( @@ -77,11 +72,11 @@ public function camelize($candidate) 'strtolower', explode( '_', - $candidate - ) - ) - ) - ) + $candidate, + ), + ), + ), + ), ); } } diff --git a/lib/Tmdb/ConfigurationInterface.php b/lib/Tmdb/ConfigurationInterface.php index 8e0064b8..677ff3e7 100644 --- a/lib/Tmdb/ConfigurationInterface.php +++ b/lib/Tmdb/ConfigurationInterface.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ diff --git a/lib/Tmdb/Event/AfterHydrationEvent.php b/lib/Tmdb/Event/AfterHydrationEvent.php index f3ce021a..54b029b7 100644 --- a/lib/Tmdb/Event/AfterHydrationEvent.php +++ b/lib/Tmdb/Event/AfterHydrationEvent.php @@ -1,24 +1,21 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Event; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; -use Symfony\Contracts\EventDispatcher\Event; -use Tmdb\Model\AbstractModel; - class AfterHydrationEvent extends HydrationEvent { } diff --git a/lib/Tmdb/Event/BeforeHydrationEvent.php b/lib/Tmdb/Event/BeforeHydrationEvent.php index 35f3594d..999ea6b6 100644 --- a/lib/Tmdb/Event/BeforeHydrationEvent.php +++ b/lib/Tmdb/Event/BeforeHydrationEvent.php @@ -1,24 +1,21 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Event; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; -use Symfony\Contracts\EventDispatcher\Event; -use Tmdb\Model\AbstractModel; - class BeforeHydrationEvent extends HydrationEvent { } diff --git a/lib/Tmdb/Event/BeforeRequestEvent.php b/lib/Tmdb/Event/BeforeRequestEvent.php index d66ba25e..7790005f 100644 --- a/lib/Tmdb/Event/BeforeRequestEvent.php +++ b/lib/Tmdb/Event/BeforeRequestEvent.php @@ -1,26 +1,21 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Event; -use Psr\EventDispatcher\EventDispatcherInterface; -use Psr\EventDispatcher\StoppableEventInterface; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; -use Symfony\Contracts\EventDispatcher\Event; -use Tmdb\HttpClient\Request; - class BeforeRequestEvent extends RequestEvent { } diff --git a/lib/Tmdb/Event/HttpClientExceptionEvent.php b/lib/Tmdb/Event/HttpClientExceptionEvent.php index 5a416689..c41552fc 100644 --- a/lib/Tmdb/Event/HttpClientExceptionEvent.php +++ b/lib/Tmdb/Event/HttpClientExceptionEvent.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ @@ -20,68 +22,35 @@ class HttpClientExceptionEvent extends StoppableEvent implements LoggableHttpEventInterface { - /** - * @var ClientExceptionInterface - */ - private $exception; - - /** - * @var RequestInterface - */ - private $request; - - /** - * @var ResponseInterface|null - */ - private $response; + private ?\Psr\Http\Message\ResponseInterface $response = null; /** - * Constructor - * - * @param ClientExceptionInterface $exception - * @param RequestInterface $request + * Constructor. */ - public function __construct(ClientExceptionInterface $exception, RequestInterface $request) + public function __construct(private readonly ClientExceptionInterface $exception, private readonly RequestInterface $request) { - $this->exception = $exception; - $this->request = $request; } - /** - * @return ClientExceptionInterface - */ public function getException(): ClientExceptionInterface { return $this->exception; } - /** - * @return RequestInterface - */ public function getRequest(): RequestInterface { return $this->request; } - /** - * @return bool - */ public function hasResponse(): bool { return null !== $this->response; } - /** - * @return ResponseInterface|null - */ public function getResponse(): ?ResponseInterface { return $this->response; } - /** - * @param ResponseInterface $response - */ public function setResponse(ResponseInterface $response): void { $this->response = $response; diff --git a/lib/Tmdb/Event/HydrationEvent.php b/lib/Tmdb/Event/HydrationEvent.php index 15a3052b..bd6ec41e 100644 --- a/lib/Tmdb/Event/HydrationEvent.php +++ b/lib/Tmdb/Event/HydrationEvent.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ @@ -21,50 +23,22 @@ class HydrationEvent extends Event { - /** - * @var AbstractModel - */ - private $subject; - - /** - * @var array - */ - private $data; - - /** - * @var RequestInterface|null - */ - private $lastRequest; + private ?\Psr\Http\Message\RequestInterface $lastRequest = null; - /** - * @var ResponseInterface|null - */ - private $lastResponse; + private ?\Psr\Http\Message\ResponseInterface $lastResponse = null; /** - * Constructor - * - * @param AbstractModel $subject - * @param array $data + * Constructor. */ - public function __construct(AbstractModel $subject, array $data = []) + public function __construct(private AbstractModel $subject, private array $data = []) { - $this->subject = $subject; - $this->data = $data; } - /** - * @return AbstractModel - */ public function getSubject(): AbstractModel { return $this->subject; } - /** - * @param AbstractModel $subject - * @return self - */ public function setSubject(AbstractModel $subject): HydrationEvent { $this->subject = $subject; @@ -72,18 +46,11 @@ public function setSubject(AbstractModel $subject): HydrationEvent return $this; } - /** - * @return array - */ public function getData(): array { return $this->data; } - /** - * @param array $data - * @return self - */ public function setData(array $data = []): HydrationEvent { $this->data = $data; @@ -91,26 +58,16 @@ public function setData(array $data = []): HydrationEvent return $this; } - /** - * @return bool - */ public function hasData(): bool { return !empty($this->data); } - /** - * @return RequestInterface|null - */ public function getLastRequest(): ?RequestInterface { return $this->lastRequest; } - /** - * @param RequestInterface|null $lastRequest - * @return self - */ public function setLastRequest(?RequestInterface $lastRequest = null): HydrationEvent { $this->lastRequest = $lastRequest; @@ -118,18 +75,11 @@ public function setLastRequest(?RequestInterface $lastRequest = null): Hydration return $this; } - /** - * @return ResponseInterface|null - */ public function getLastResponse(): ?ResponseInterface { return $this->lastResponse; } - /** - * @param ResponseInterface|null $lastResponse - * @return self - */ public function setLastResponse(?ResponseInterface $lastResponse = null): HydrationEvent { $this->lastResponse = $lastResponse; diff --git a/lib/Tmdb/Event/Listener/HydrationListener.php b/lib/Tmdb/Event/Listener/HydrationListener.php index 1d88eb1b..7f65bdb9 100644 --- a/lib/Tmdb/Event/Listener/HydrationListener.php +++ b/lib/Tmdb/Event/Listener/HydrationListener.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ @@ -22,39 +24,24 @@ use Tmdb\Model\AbstractModel; /** - * Class RequestSubscriber - * @package Tmdb\Event + * Class RequestSubscriber. */ class HydrationListener { - /** - * @var EventDispatcherInterface - */ - private $eventDispatcher; - - /** - * @var ObjectHydrator - */ - private $hydrator; + private readonly \Tmdb\Common\ObjectHydrator $hydrator; /** * HydrationListener constructor. - * @param EventDispatcherInterface $eventDispatcher */ - public function __construct(EventDispatcherInterface $eventDispatcher) + public function __construct(private readonly EventDispatcherInterface $eventDispatcher) { - $this->eventDispatcher = $eventDispatcher; $this->hydrator = new ObjectHydrator(); } /** - * Hydrate the subject with data - * - * @param HydrationEvent $event - * - * @return AbstractModel + * Hydrate the subject with data. */ - public function __invoke(HydrationEvent $event) + public function __invoke(HydrationEvent $event): \Tmdb\Model\AbstractModel { $before = new BeforeHydrationEvent($event->getSubject(), $event->getData()); $before->setLastRequest($event->getLastRequest()); @@ -76,9 +63,8 @@ public function __invoke(HydrationEvent $event) } /** - * Hydrate the subject + * Hydrate the subject. * - * @param HydrationEvent $event * @return AbstractModel */ public function hydrateSubject(HydrationEvent $event) diff --git a/lib/Tmdb/Event/Listener/Logger/LogApiErrorListener.php b/lib/Tmdb/Event/Listener/Logger/LogApiErrorListener.php index 431fe055..035c3bef 100644 --- a/lib/Tmdb/Event/Listener/Logger/LogApiErrorListener.php +++ b/lib/Tmdb/Event/Listener/Logger/LogApiErrorListener.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ @@ -20,43 +22,27 @@ use Tmdb\Formatter\TmdbApiExceptionFormatterInterface; /** - * Class LogApiErrorListener - * @package Tmdb\Event + * Class LogApiErrorListener. */ class LogApiErrorListener { - /** - * @var LoggerInterface - */ - private $logger; - - /** - * @var TmdbApiExceptionFormatterInterface - */ - private $formatter; + private readonly \Tmdb\Formatter\TmdbApiExceptionFormatterInterface $formatter; /** * LogApiErrorListener constructor. - * @param LoggerInterface $logger - * @param TmdbApiExceptionFormatterInterface|null $formatter */ - public function __construct(LoggerInterface $logger, ?TmdbApiExceptionFormatterInterface $formatter = null) + public function __construct(private readonly LoggerInterface $logger, ?TmdbApiExceptionFormatterInterface $formatter = null) { - $this->logger = $logger; $this->formatter = $formatter ?: new SimpleTmdbApiExceptionFormatter(); } - /** - * @param TmdbExceptionEvent $event - * @return void - */ public function __invoke(TmdbExceptionEvent $event): void { $this->logger->critical( - sprintf( + \sprintf( 'Critical API exception:' . PHP_EOL . '%s', - $this->formatter->formatApiException($event->getException()) - ) + $this->formatter->formatApiException($event->getException()), + ), ); } } diff --git a/lib/Tmdb/Event/Listener/Logger/LogHttpMessageListener.php b/lib/Tmdb/Event/Listener/Logger/LogHttpMessageListener.php index 16f1bfd3..a5e275e7 100644 --- a/lib/Tmdb/Event/Listener/Logger/LogHttpMessageListener.php +++ b/lib/Tmdb/Event/Listener/Logger/LogHttpMessageListener.php @@ -1,20 +1,21 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Event\Listener\Logger; -use Psr\Http\Client\ClientExceptionInterface; use Psr\Log\LoggerInterface; use Tmdb\Event\BeforeRequestEvent; use Tmdb\Event\HttpClientExceptionEvent; @@ -24,36 +25,20 @@ use Tmdb\Formatter\HttpMessageFormatterInterface; /** - * Class LogHttpMessageListener - * @package Tmdb\Event + * Class LogHttpMessageListener. */ class LogHttpMessageListener { - /** - * @var LoggerInterface - */ - private $logger; - - /** - * @var HttpMessageFormatterInterface - */ - private $formatter; + private readonly \Tmdb\Formatter\HttpMessageFormatterInterface $formatter; /** * LogHttpMessageListener constructor. - * @param LoggerInterface $logger - * @param HttpMessageFormatterInterface|null $formatter */ - public function __construct(LoggerInterface $logger, ?HttpMessageFormatterInterface $formatter = null) + public function __construct(private readonly LoggerInterface $logger, ?HttpMessageFormatterInterface $formatter = null) { - $this->logger = $logger; $this->formatter = $formatter ?: new SimpleHttpMessageFormatter(); } - /** - * @param LoggableHttpEventInterface $event - * @return void - */ public function __invoke(LoggableHttpEventInterface $event): void { if ($event instanceof BeforeRequestEvent) { @@ -69,41 +54,35 @@ public function __invoke(LoggableHttpEventInterface $event): void } } - /** - * @param BeforeRequestEvent $event - */ protected function logRequest(BeforeRequestEvent $event): void { - if (null !== $event->getRequest()->getBody()) { + if ($event->getRequest()->getBody() instanceof \Psr\Http\Message\StreamInterface) { $event->getRequest()->getBody()->rewind(); } $context = [ 'length' => $event->getRequest()->getBody()->getSize(), - 'has_session_token' => $event->hasSessionToken() + 'has_session_token' => $event->hasSessionToken(), ]; $this->logger->info( - sprintf( + \sprintf( 'Sending request:' . PHP_EOL . '%s', - $this->formatter->formatRequest($event->getRequest()) + $this->formatter->formatRequest($event->getRequest()), ), - $context + $context, ); } - /** - * @param ResponseEvent $event - */ protected function logResponse(ResponseEvent $event): void { - $cacheHit = $event->getResponse()->hasHeader('X-TMDB-Cache') && - 'HIT' === $event->getResponse()->getHeaderLine('X-TMDB-Cache'); + $cacheHit = $event->getResponse()->hasHeader('X-TMDB-Cache') + && 'HIT' === $event->getResponse()->getHeaderLine('X-TMDB-Cache'); $context = [ 'status_code' => $event->getResponse()->getStatusCode(), 'length' => $event->getResponse()->getBody()->getSize(), - 'cached' => $cacheHit + 'cached' => $cacheHit, ]; $format = 'Received response:' . PHP_EOL . '%s'; @@ -113,29 +92,26 @@ protected function logResponse(ResponseEvent $event): void } $this->logger->info( - sprintf( + \sprintf( $format, - $this->formatter->formatResponse($event->getResponse()) + $this->formatter->formatResponse($event->getResponse()), ), - $context + $context, ); } - /** - * @param HttpClientExceptionEvent $event - */ protected function logClientException(HttpClientExceptionEvent $event): void { $context = [ - 'request' => $event->getRequest()->getUri()->__toString() + 'request' => $event->getRequest()->getUri()->__toString(), ]; $this->logger->critical( - sprintf( + \sprintf( 'Critical http client error:' . PHP_EOL . '%s', - $this->formatter->formatClientException($event->getException()) + $this->formatter->formatClientException($event->getException()), ), - $context + $context, ); } } diff --git a/lib/Tmdb/Event/Listener/Logger/LogHydrationListener.php b/lib/Tmdb/Event/Listener/Logger/LogHydrationListener.php index 40ab81be..2402e1d9 100644 --- a/lib/Tmdb/Event/Listener/Logger/LogHydrationListener.php +++ b/lib/Tmdb/Event/Listener/Logger/LogHydrationListener.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ @@ -16,63 +18,41 @@ use Psr\Log\LoggerInterface; use Tmdb\Event\BeforeHydrationEvent; -use Tmdb\Formatter\HttpMessageFormatterInterface; use Tmdb\Formatter\Hydration\SimpleHydrationFormatter; use Tmdb\Formatter\HydrationFormatterInterface; /** - * Class LogHydrationListener - * @package Tmdb\Event + * Class LogHydrationListener. */ class LogHydrationListener { - /** - * @var LoggerInterface - */ - private $logger; - - /** - * @var HydrationFormatterInterface - */ - private $formatter; - - /** - * @var bool - */ - private $withData; + private readonly \Tmdb\Formatter\HydrationFormatterInterface $formatter; /** * RequestListener constructor. - * @param LoggerInterface $logger - * @param HydrationFormatterInterface|null $formatter - * @param bool $withData If true the context will contain the data used. + * + * @param bool $withData if true the context will contain the data used */ public function __construct( - LoggerInterface $logger, + private readonly LoggerInterface $logger, ?HydrationFormatterInterface $formatter = null, - bool $withData = false + private readonly bool $withData = false, ) { - $this->logger = $logger; $this->formatter = $formatter ?: new SimpleHydrationFormatter(); - $this->withData = $withData; } - /** - * @param BeforeHydrationEvent $event - * @return void - */ public function __invoke(BeforeHydrationEvent $event): void { $context = []; if ($this->withData) { $context['data'] = $event->getData(); - $context['data_size'] = \mb_strlen(\GuzzleHttp\Utils::jsonEncode($event->getData()), 'UTF-8'); + $context['data_size'] = mb_strlen(\GuzzleHttp\Utils::jsonEncode($event->getData()), 'UTF-8'); } $this->logger->debug( $this->formatter->formatBeforeEvent($event), - $context + $context, ); } } diff --git a/lib/Tmdb/Event/Listener/Psr6CachedRequestListener.php b/lib/Tmdb/Event/Listener/Psr6CachedRequestListener.php index e69cbe57..fe0ecee4 100644 --- a/lib/Tmdb/Event/Listener/Psr6CachedRequestListener.php +++ b/lib/Tmdb/Event/Listener/Psr6CachedRequestListener.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ @@ -32,25 +34,9 @@ * This is a little hacky, but I just wanna get 4.0 pushed ASAP. At a later stage we will review this again. * * Class Psr6CachedRequestListener - * @package Tmdb\Event\Listener */ class Psr6CachedRequestListener extends RequestListener { - /** - * @var CacheItemPoolInterface - */ - private $cache; - - /** - * @var StreamFactoryInterface - */ - private $streamFactory; - - /** - * @var array - */ - private $options; - /** * @var CachePlugin */ @@ -58,35 +44,22 @@ class Psr6CachedRequestListener extends RequestListener /** * Psr6CachedRequestListener constructor. - * - * @param HttpClient $httpClient - * @param EventDispatcherInterface $eventDispatcher - * @param CacheItemPoolInterface $cache - * @param StreamFactoryInterface $streamFactory - * @param array $options - * @param array $pluginOptions */ public function __construct( HttpClient $httpClient, EventDispatcherInterface $eventDispatcher, - CacheItemPoolInterface $cache, - StreamFactoryInterface $streamFactory, - array $options = [], - array $pluginOptions = [] + private readonly CacheItemPoolInterface $cache, + private readonly StreamFactoryInterface $streamFactory, + array $pluginOptions = [], ) { parent::__construct($httpClient, $eventDispatcher); - - $this->cache = $cache; - $this->streamFactory = $streamFactory; - $this->options = $options; $this->httpCachePlugin = CachePlugin::serverCache($this->cache, $this->streamFactory, $pluginOptions); } /** * Add the API token to the headers. - * - * @param RequestEvent $event */ + #[\Override] public function __invoke(RequestEvent $event): void { // Preparation of request parameters / Possibility to use for logging and caching etc. @@ -97,6 +70,7 @@ public function __invoke(RequestEvent $event): void if ($beforeRequestEvent->isPropagationStopped() && $beforeRequestEvent->hasResponse()) { $event->setResponse($beforeRequestEvent->getResponse()); + return; } @@ -105,20 +79,20 @@ public function __invoke(RequestEvent $event): void try { $response = $this->httpCachePlugin->handleRequest( $event->getRequest(), - function ($request) use ($beforeRequestEvent, &$cachedResponse) { + function ($request) use ($beforeRequestEvent, &$cachedResponse): \Http\Promise\FulfilledPromise { $cachedResponse = false; $response = $this->sendRequest($beforeRequestEvent); return new FulfilledPromise($response); }, - function () { - } // we do not need the plugin to go back + function (): void { + }, // we do not need the plugin to go back ); $response->then( - function ($result) use ($beforeRequestEvent) { + function ($result) use ($beforeRequestEvent): void { $beforeRequestEvent->setResponse($result); - } + }, ); $response = $beforeRequestEvent->getResponse(); @@ -128,10 +102,7 @@ function ($result) use ($beforeRequestEvent) { try { if ($response->getStatusCode() >= 400 && $response->getStatusCode() < 600) { - throw $this->responseExceptionFactory->createTmdbApiException( - $beforeRequestEvent->getRequest(), - $response - ); + throw $this->responseExceptionFactory->createTmdbApiException($beforeRequestEvent->getRequest(), $response); } $event->setRequest($beforeRequestEvent->getRequest()); diff --git a/lib/Tmdb/Event/Listener/Request/AcceptJsonRequestListener.php b/lib/Tmdb/Event/Listener/Request/AcceptJsonRequestListener.php index bc317557..1d6a5b75 100644 --- a/lib/Tmdb/Event/Listener/Request/AcceptJsonRequestListener.php +++ b/lib/Tmdb/Event/Listener/Request/AcceptJsonRequestListener.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ @@ -21,7 +23,7 @@ class AcceptJsonRequestListener public function __invoke(RequestEvent $event): void { $event->setRequest( - $event->getRequest()->withHeader('Accept', 'application/json; charset=utf-8') + $event->getRequest()->withHeader('Accept', 'application/json; charset=utf-8'), ); } } diff --git a/lib/Tmdb/Event/Listener/Request/AdultFilterRequestListener.php b/lib/Tmdb/Event/Listener/Request/AdultFilterRequestListener.php index 5cedfa8a..073be062 100644 --- a/lib/Tmdb/Event/Listener/Request/AdultFilterRequestListener.php +++ b/lib/Tmdb/Event/Listener/Request/AdultFilterRequestListener.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ @@ -19,26 +21,20 @@ class AdultFilterRequestListener { - private $includeAdult; - /** - * @var RequestQueryHelper - */ - private $requestQueryHelper; + private readonly \Tmdb\Helper\RequestQueryHelper $requestQueryHelper; /** * AdultFilterRequestListener constructor. + * * @param bool $includeAdult */ - public function __construct($includeAdult = false) + public function __construct(private $includeAdult = false) { - $this->includeAdult = $includeAdult; $this->requestQueryHelper = new RequestQueryHelper(); } /** * Set the adult filter. - * - * @param RequestEvent $event */ public function __invoke(RequestEvent $event): void { @@ -46,8 +42,8 @@ public function __invoke(RequestEvent $event): void $this->requestQueryHelper->withQuery( $event->getRequest(), 'include_adult', - $this->includeAdult === true ? 'true' : 'false' - ) + true === $this->includeAdult ? 'true' : 'false', + ), ); } } diff --git a/lib/Tmdb/Event/Listener/Request/ApiTokenRequestListener.php b/lib/Tmdb/Event/Listener/Request/ApiTokenRequestListener.php index 2f4e2e33..fb7c5e79 100644 --- a/lib/Tmdb/Event/Listener/Request/ApiTokenRequestListener.php +++ b/lib/Tmdb/Event/Listener/Request/ApiTokenRequestListener.php @@ -1,60 +1,50 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Event\Listener\Request; -use Tmdb\Token\Api\ApiToken; -use Tmdb\Token\Api\BearerToken; use Tmdb\Event\RequestEvent; use Tmdb\Helper\RequestQueryHelper; +use Tmdb\Token\Api\ApiToken; +use Tmdb\Token\Api\BearerToken; class ApiTokenRequestListener { - /** - * @var ApiToken - */ - private $token; - - /** - * @var RequestQueryHelper - */ - private $requestQueryHelper; + private readonly \Tmdb\Helper\RequestQueryHelper $requestQueryHelper; /** * ApiTokenRequestListener constructor. - * @param ApiToken $token */ - public function __construct(ApiToken $token) + public function __construct(private readonly ApiToken $token) { - $this->token = $token; $this->requestQueryHelper = new RequestQueryHelper(); } /** * Add the API token to the headers. - * - * @param RequestEvent $event */ public function __invoke(RequestEvent $event): void { if ($this->token instanceof BearerToken) { $event->setRequest( - $event->getRequest()->withHeader('Authorization', sprintf('Bearer %s', (string)$this->token)) + $event->getRequest()->withHeader('Authorization', \sprintf('Bearer %s', (string) $this->token)), ); } else { $event->setRequest( - $this->requestQueryHelper->withQuery($event->getRequest(), 'api_key', (string)$this->token) + $this->requestQueryHelper->withQuery($event->getRequest(), 'api_key', (string) $this->token), ); } } diff --git a/lib/Tmdb/Event/Listener/Request/ContentTypeJsonRequestListener.php b/lib/Tmdb/Event/Listener/Request/ContentTypeJsonRequestListener.php index 95bf25a6..9c805734 100644 --- a/lib/Tmdb/Event/Listener/Request/ContentTypeJsonRequestListener.php +++ b/lib/Tmdb/Event/Listener/Request/ContentTypeJsonRequestListener.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ @@ -18,22 +20,18 @@ class ContentTypeJsonRequestListener { - /** - * - * @param RequestEvent $event - */ public function __invoke(RequestEvent $event): void { $method = $event->getRequest()->getMethod(); if ( - $method == 'POST' || - $method == 'PUT' || - $method == 'PATCH' || - $method == 'DELETE' + 'POST' === $method + || 'PUT' === $method + || 'PATCH' === $method + || 'DELETE' === $method ) { $event->setRequest( - $event->getRequest()->withHeader('Content-Type', 'application/json') + $event->getRequest()->withHeader('Content-Type', 'application/json'), ); } } diff --git a/lib/Tmdb/Event/Listener/Request/LanguageFilterRequestListener.php b/lib/Tmdb/Event/Listener/Request/LanguageFilterRequestListener.php index 9c6d03c8..3a54a8a8 100644 --- a/lib/Tmdb/Event/Listener/Request/LanguageFilterRequestListener.php +++ b/lib/Tmdb/Event/Listener/Request/LanguageFilterRequestListener.php @@ -1,54 +1,45 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Event\Listener\Request; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Tmdb\Event\RequestEvent; use Tmdb\Helper\RequestQueryHelper; class LanguageFilterRequestListener { - /** - * @var string - */ - private $language; - - /** - * @var RequestQueryHelper - */ - private $requestQueryHelper; + private readonly \Tmdb\Helper\RequestQueryHelper $requestQueryHelper; /** * LanguageFilterRequestListener constructor. + * * @param string $language */ - public function __construct($language = 'en') + public function __construct(private $language = 'en') { - $this->language = $language; $this->requestQueryHelper = new RequestQueryHelper(); } /** * Set the language filter. - * - * @param RequestEvent $event */ public function __invoke(RequestEvent $event): void { $event->setRequest( - $this->requestQueryHelper->withQuery($event->getRequest(), 'language', $this->language) + $this->requestQueryHelper->withQuery($event->getRequest(), 'language', $this->language), ); } } diff --git a/lib/Tmdb/Event/Listener/Request/RegionFilterRequestListener.php b/lib/Tmdb/Event/Listener/Request/RegionFilterRequestListener.php index e7ef4bff..a153c9fc 100644 --- a/lib/Tmdb/Event/Listener/Request/RegionFilterRequestListener.php +++ b/lib/Tmdb/Event/Listener/Request/RegionFilterRequestListener.php @@ -1,54 +1,45 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Event\Listener\Request; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Tmdb\Event\RequestEvent; use Tmdb\Helper\RequestQueryHelper; class RegionFilterRequestListener { - /** - * @var string - */ - private $region; - - /** - * @var RequestQueryHelper - */ - private $requestQueryHelper; + private readonly \Tmdb\Helper\RequestQueryHelper $requestQueryHelper; /** * RegionFilterRequestListener constructor. + * * @param string $region */ - public function __construct($region = 'en') + public function __construct(private $region = 'en') { - $this->region = $region; $this->requestQueryHelper = new RequestQueryHelper(); } /** * Set the region filter. - * - * @param RequestEvent $event */ public function __invoke(RequestEvent $event): void { $event->setRequest( - $this->requestQueryHelper->withQuery($event->getRequest(), 'region', $this->region) + $this->requestQueryHelper->withQuery($event->getRequest(), 'region', $this->region), ); } } diff --git a/lib/Tmdb/Event/Listener/Request/SessionTokenRequestListener.php b/lib/Tmdb/Event/Listener/Request/SessionTokenRequestListener.php index cb550834..a703fe55 100644 --- a/lib/Tmdb/Event/Listener/Request/SessionTokenRequestListener.php +++ b/lib/Tmdb/Event/Listener/Request/SessionTokenRequestListener.php @@ -1,68 +1,56 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Event\Listener\Request; use Tmdb\Event\RequestEvent; -use Tmdb\Token\Session\GuestSessionToken; use Tmdb\Helper\RequestQueryHelper; +use Tmdb\Token\Session\GuestSessionToken; use Tmdb\Token\Session\SessionBearerToken; use Tmdb\Token\Session\SessionToken; class SessionTokenRequestListener { - /** - * @var SessionToken - */ - private $token; - - /** - * @var RequestQueryHelper - */ - private $requestQueryHelper; + private readonly \Tmdb\Helper\RequestQueryHelper $requestQueryHelper; /** * SessionTokenRequestListener constructor. - * @param SessionToken $token */ - public function __construct(SessionToken $token) + public function __construct(private readonly SessionToken $token) { - $this->token = $token; $this->requestQueryHelper = new RequestQueryHelper(); } /** * Set the token filter. - * - * @param RequestEvent $event */ public function __invoke(RequestEvent $event): void { if ($this->token instanceof SessionBearerToken) { $event->setRequest( - $event->getRequest()->withHeader('Authorization', sprintf('Bearer %s', (string)$this->token)) + $event->getRequest()->withHeader('Authorization', \sprintf('Bearer %s', (string) $this->token)), ); return; - } elseif ($this->token instanceof GuestSessionToken) { - $key = 'guest_session_id'; - } else { - $key = 'session_id'; } + $key = $this->token instanceof GuestSessionToken ? 'guest_session_id' : 'session_id'; + $event->setRequest( - $this->requestQueryHelper->withQuery($event->getRequest(), $key, (string)$this->token) + $this->requestQueryHelper->withQuery($event->getRequest(), $key, (string) $this->token), ); } } diff --git a/lib/Tmdb/Event/Listener/Request/UserAgentRequestListener.php b/lib/Tmdb/Event/Listener/Request/UserAgentRequestListener.php index 0190003d..2c516572 100644 --- a/lib/Tmdb/Event/Listener/Request/UserAgentRequestListener.php +++ b/lib/Tmdb/Event/Listener/Request/UserAgentRequestListener.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ @@ -19,29 +21,23 @@ class UserAgentRequestListener { - /** - * @var string|null - */ - private $userAgent; + private readonly string $userAgent; /** * UserAgentRequestListener constructor. - * @param string|null $userAgent */ public function __construct(?string $userAgent = null) { - $this->userAgent = $userAgent ?? sprintf('php-tmdb/api/%s', Client::VERSION); + $this->userAgent = $userAgent ?? \sprintf('php-tmdb/api/%s', Client::VERSION); } /** * Add the API token to the headers. - * - * @param RequestEvent $event */ public function __invoke(RequestEvent $event): void { $event->setRequest( - $event->getRequest()->withHeader('User-Agent', $this->userAgent) + $event->getRequest()->withHeader('User-Agent', $this->userAgent), ); } } diff --git a/lib/Tmdb/Event/Listener/RequestListener.php b/lib/Tmdb/Event/Listener/RequestListener.php index 359f346d..7fd83b72 100644 --- a/lib/Tmdb/Event/Listener/RequestListener.php +++ b/lib/Tmdb/Event/Listener/RequestListener.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ @@ -29,45 +31,26 @@ use Tmdb\HttpClient\HttpClient; /** - * Class RequestSubscriber - * @package Tmdb\Event + * Class RequestSubscriber. */ class RequestListener { - /** - * @var HttpClient - */ - private $httpClient; - - /** - * @var EventDispatcherInterface - */ - protected $eventDispatcher; - - /** - * @var ResponseExceptionFactory - */ - protected $responseExceptionFactory; + protected \Tmdb\Exception\Factory\ResponseExceptionFactory $responseExceptionFactory; /** * RequestListener constructor. - * @param EventDispatcherInterface $eventDispatcher */ - public function __construct(HttpClient $httpClient, EventDispatcherInterface $eventDispatcher) + public function __construct(private readonly HttpClient $httpClient, protected \Psr\EventDispatcher\EventDispatcherInterface $eventDispatcher) { - $this->httpClient = $httpClient; - $this->eventDispatcher = $eventDispatcher; $this->responseExceptionFactory = new ResponseExceptionFactory(); } /** - * @param RequestEvent $event - * @return void * @throws Exception * @throws TmdbApiException * @throws ClientExceptionInterface */ - public function __invoke(RequestEvent $event) + public function __invoke(RequestEvent $event): void { // Preparation of request parameters / Possibility to use for logging and caching etc. $beforeRequestEvent = new BeforeRequestEvent($event->getRequest()); @@ -77,6 +60,7 @@ public function __invoke(RequestEvent $event) if ($beforeRequestEvent->isPropagationStopped() && $beforeRequestEvent->hasResponse()) { $event->setResponse($beforeRequestEvent->getResponse()); + return; } @@ -88,10 +72,7 @@ public function __invoke(RequestEvent $event) try { if ($response->getStatusCode() >= 400 && $response->getStatusCode() < 600) { - throw $this->responseExceptionFactory->createTmdbApiException( - $beforeRequestEvent->getRequest(), - $response - ); + throw $this->responseExceptionFactory->createTmdbApiException($beforeRequestEvent->getRequest(), $response); } $event->setRequest($beforeRequestEvent->getRequest()); @@ -105,10 +86,8 @@ public function __invoke(RequestEvent $event) } /** - * Call upon the adapter to create an response object + * Call upon the adapter to create an response object. * - * @param RequestEvent $event - * @return ResponseInterface * @throws Exception * @throws ClientExceptionInterface */ @@ -118,14 +97,11 @@ public function sendRequest(RequestEvent $event): ResponseInterface } /** - * @param ClientExceptionInterface $e - * @param RequestInterface $request - * @return ResponseInterface * @throws ClientExceptionInterface */ protected function handleClientException( ClientExceptionInterface $e, - RequestInterface $request + RequestInterface $request, ): ResponseInterface { // In the event of failures, you can recover certain exceptions. $exceptionEvent = new HttpClientExceptionEvent($e, $request); @@ -140,8 +116,6 @@ protected function handleClientException( } /** - * @param TmdbApiException $e - * @return ResponseInterface * @throws TmdbApiException */ protected function handleTmdbApiException(TmdbApiException $e): ResponseInterface diff --git a/lib/Tmdb/Event/LoggableHttpEventInterface.php b/lib/Tmdb/Event/LoggableHttpEventInterface.php index 6cbf63f8..a7f05422 100644 --- a/lib/Tmdb/Event/LoggableHttpEventInterface.php +++ b/lib/Tmdb/Event/LoggableHttpEventInterface.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ diff --git a/lib/Tmdb/Event/RequestEvent.php b/lib/Tmdb/Event/RequestEvent.php index e8997afd..5572c75c 100644 --- a/lib/Tmdb/Event/RequestEvent.php +++ b/lib/Tmdb/Event/RequestEvent.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ @@ -19,50 +21,24 @@ use Tmdb\Token\Session\SessionToken; /** - * Class RequestEvent - * @package Tmdb\Event + * Class RequestEvent. */ class RequestEvent extends StoppableEvent implements LoggableHttpEventInterface { - /** - * @var RequestInterface - */ - private $request; - - /** - * @var ?ResponseInterface - */ - private $response; + private ?\Psr\Http\Message\ResponseInterface $response = null; /** - * @var ?SessionToken + * Construct the request event. */ - private $sessionToken; - - /** - * Construct the request event - * - * @param RequestInterface $request - * @param SessionToken|null $sessionToken - */ - public function __construct(RequestInterface $request, ?SessionToken $sessionToken = null) + public function __construct(private RequestInterface $request, private ?SessionToken $sessionToken = null) { - $this->request = $request; - $this->sessionToken = $sessionToken; } - /** - * @return RequestInterface - */ public function getRequest(): RequestInterface { return $this->request; } - /** - * @param RequestInterface $request - * @return self - */ public function setRequest(RequestInterface $request): RequestEvent { $this->request = $request; @@ -70,18 +46,11 @@ public function setRequest(RequestInterface $request): RequestEvent return $this; } - /** - * @return ?ResponseInterface - */ public function getResponse(): ?ResponseInterface { return $this->response; } - /** - * @param ResponseInterface $response - * @return self - */ public function setResponse(ResponseInterface $response): RequestEvent { $this->response = $response; @@ -97,18 +66,11 @@ public function hasResponse() return $this->response instanceof ResponseInterface; } - /** - * @return ?SessionToken - */ public function getSessionToken(): ?SessionToken { return $this->sessionToken; } - /** - * @param SessionToken|null $sessionToken - * @return self - */ public function setSessionToken(?SessionToken $sessionToken = null): RequestEvent { $this->sessionToken = $sessionToken; @@ -116,9 +78,6 @@ public function setSessionToken(?SessionToken $sessionToken = null): RequestEven return $this; } - /** - * @return bool - */ public function hasSessionToken(): bool { return $this->sessionToken instanceof SessionToken; diff --git a/lib/Tmdb/Event/ResponseEvent.php b/lib/Tmdb/Event/ResponseEvent.php index e928a962..996c5a0d 100644 --- a/lib/Tmdb/Event/ResponseEvent.php +++ b/lib/Tmdb/Event/ResponseEvent.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ @@ -21,30 +23,12 @@ class ResponseEvent implements LoggableHttpEventInterface { /** - * @var RequestInterface - */ - private $request; - - /** - * @var ResponseInterface + * Construct the request event. */ - private $response; - - /** - * Construct the request event - * - * @param ResponseInterface $response - * @param RequestInterface $request - */ - public function __construct(ResponseInterface $response, RequestInterface $request) + public function __construct(private ResponseInterface $response, private RequestInterface $request) { - $this->response = $response; - $this->request = $request; } - /** - * @return RequestInterface - */ public function getRequest(): RequestInterface { return $this->request; @@ -52,46 +36,32 @@ public function getRequest(): RequestInterface /** * @param RequestInterface $request - * @return self */ - public function setRequest($request) + public function setRequest($request): static { $this->request = $request; return $this; } - /** - * @return ResponseInterface - */ public function getResponse(): ResponseInterface { return $this->response; } - /** - * @param ResponseInterface $response - * @return self - */ - public function setResponse(ResponseInterface $response) + public function setResponse(ResponseInterface $response): static { $this->response = $response; return $this; } - /** - * @return bool - */ - public function hasResponse() + public function hasResponse(): bool { return null !== $this->response; } - /** - * @return bool - */ - public function hasRequest() + public function hasRequest(): bool { return null !== $this->request; } diff --git a/lib/Tmdb/Event/StoppableEvent.php b/lib/Tmdb/Event/StoppableEvent.php index 91dedb0e..cc6de1c7 100644 --- a/lib/Tmdb/Event/StoppableEvent.php +++ b/lib/Tmdb/Event/StoppableEvent.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ @@ -25,8 +27,9 @@ public function stopPropagation(): void $this->isPropagationStopped = true; } + #[\Override] public function isPropagationStopped(): bool { - return (bool)$this->isPropagationStopped; + return (bool) $this->isPropagationStopped; } } diff --git a/lib/Tmdb/Event/TmdbExceptionEvent.php b/lib/Tmdb/Event/TmdbExceptionEvent.php index 2bdde6dc..c3f172a3 100644 --- a/lib/Tmdb/Event/TmdbExceptionEvent.php +++ b/lib/Tmdb/Event/TmdbExceptionEvent.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ @@ -19,53 +21,30 @@ class TmdbExceptionEvent extends StoppableEvent { - /** - * @var TmdbApiException - */ - private $exception; + private ?\Psr\Http\Message\ResponseInterface $response = null; /** - * @var ResponseInterface + * Constructor. */ - private $response; - - /** - * Constructor - * - * @param TmdbApiException $exception - */ - public function __construct(TmdbApiException $exception) + public function __construct(private readonly TmdbApiException $exception) { - $this->exception = $exception; } - /** - * @return TmdbApiException - */ public function getException(): TmdbApiException { return $this->exception; } - /** - * @return bool - */ public function hasResponse(): bool { return null !== $this->response; } - /** - * @return ResponseInterface|null - */ public function getResponse(): ?ResponseInterface { return $this->response; } - /** - * @param ResponseInterface $response - */ public function setResponse(ResponseInterface $response): void { $this->response = $response; diff --git a/lib/Tmdb/Exception/ApiTokenMissingException.php b/lib/Tmdb/Exception/ApiTokenMissingException.php index ca00c9e8..eaaf5c77 100644 --- a/lib/Tmdb/Exception/ApiTokenMissingException.php +++ b/lib/Tmdb/Exception/ApiTokenMissingException.php @@ -1,23 +1,26 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Exception; +use RuntimeException; + /** - * Class ApiTokenException - * @package Tmdb\Exception + * Class ApiTokenException. */ -class ApiTokenMissingException extends \RuntimeException +class ApiTokenMissingException extends RuntimeException { } diff --git a/lib/Tmdb/Exception/Factory/ResponseExceptionFactory.php b/lib/Tmdb/Exception/Factory/ResponseExceptionFactory.php index 7f6e7d60..e47f56e3 100644 --- a/lib/Tmdb/Exception/Factory/ResponseExceptionFactory.php +++ b/lib/Tmdb/Exception/Factory/ResponseExceptionFactory.php @@ -1,19 +1,22 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Exception\Factory; +use Exception; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; use Tmdb\Exception\RuntimeException; @@ -23,9 +26,6 @@ class ResponseExceptionFactory { /** - * @param RequestInterface $request - * @param ResponseInterface $response - * @return TmdbApiException * @throws UnexpectedResponseException * @throws RuntimeException */ @@ -33,8 +33,8 @@ public function createTmdbApiException(RequestInterface $request, ResponseInterf { try { if ( - $response->hasHeader('content-type') && - strpos($response->getHeaderLine('content-type'), 'application/json') !== false + $response->hasHeader('content-type') + && str_contains($response->getHeaderLine('content-type'), 'application/json') ) { $response->getBody()->rewind(); @@ -45,15 +45,13 @@ public function createTmdbApiException(RequestInterface $request, ResponseInterf $data->status_code, $data->status_message, $request, - $response + $response, ); } - } catch (\Exception $e) { + } catch (Exception) { throw new RuntimeException('Unable to create TmdbApiException, could not decode response body.'); } - throw new UnexpectedResponseException( - 'Unable to create an helpful Exception, server did not contain a json body.' - ); + throw new UnexpectedResponseException('Unable to create an helpful Exception, server did not contain a json body.'); } } diff --git a/lib/Tmdb/Exception/InvalidArgumentException.php b/lib/Tmdb/Exception/InvalidArgumentException.php index b49a6cec..a9f91e92 100644 --- a/lib/Tmdb/Exception/InvalidArgumentException.php +++ b/lib/Tmdb/Exception/InvalidArgumentException.php @@ -1,22 +1,23 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Exception; /** - * Class InvalidArgumentException - * @package Tmdb\Exception + * Class InvalidArgumentException. */ class InvalidArgumentException extends \InvalidArgumentException { diff --git a/lib/Tmdb/Exception/JsonDecodingException.php b/lib/Tmdb/Exception/JsonDecodingException.php index 0b837f1a..fd6bc146 100644 --- a/lib/Tmdb/Exception/JsonDecodingException.php +++ b/lib/Tmdb/Exception/JsonDecodingException.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ diff --git a/lib/Tmdb/Exception/MissingArgumentException.php b/lib/Tmdb/Exception/MissingArgumentException.php index 51f90f20..9cf51dcc 100644 --- a/lib/Tmdb/Exception/MissingArgumentException.php +++ b/lib/Tmdb/Exception/MissingArgumentException.php @@ -1,23 +1,26 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Exception; +use InvalidArgumentException; + /** - * Class MissingArgumentException - * @package Tmdb\Exception + * Class MissingArgumentException. */ -class MissingArgumentException extends \InvalidArgumentException +class MissingArgumentException extends InvalidArgumentException { } diff --git a/lib/Tmdb/Exception/MissingSessionTokenException.php b/lib/Tmdb/Exception/MissingSessionTokenException.php index 2b71b12d..62901cde 100644 --- a/lib/Tmdb/Exception/MissingSessionTokenException.php +++ b/lib/Tmdb/Exception/MissingSessionTokenException.php @@ -1,23 +1,26 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Exception; +use RuntimeException; + /** - * Class MissingSessionTokenException - * @package Tmdb\Exception + * Class MissingSessionTokenException. */ -class MissingSessionTokenException extends \RuntimeException +class MissingSessionTokenException extends RuntimeException { } diff --git a/lib/Tmdb/Exception/NotImplementedException.php b/lib/Tmdb/Exception/NotImplementedException.php index 777944c1..2ba5a072 100644 --- a/lib/Tmdb/Exception/NotImplementedException.php +++ b/lib/Tmdb/Exception/NotImplementedException.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ @@ -17,8 +19,7 @@ use Exception; /** - * Class NotImplementedException - * @package Tmdb\Exception + * Class NotImplementedException. */ class NotImplementedException extends Exception { diff --git a/lib/Tmdb/Exception/RuntimeException.php b/lib/Tmdb/Exception/RuntimeException.php index 67121dd9..fbed3154 100644 --- a/lib/Tmdb/Exception/RuntimeException.php +++ b/lib/Tmdb/Exception/RuntimeException.php @@ -1,22 +1,23 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Exception; /** - * Class RuntimeException - * @package Tmdb\Exception + * Class RuntimeException. */ class RuntimeException extends \RuntimeException { diff --git a/lib/Tmdb/Exception/TmdbApiException.php b/lib/Tmdb/Exception/TmdbApiException.php index 402eb530..ecae653e 100644 --- a/lib/Tmdb/Exception/TmdbApiException.php +++ b/lib/Tmdb/Exception/TmdbApiException.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ @@ -19,8 +21,7 @@ use Psr\Http\Message\ResponseInterface; /** - * Class TmdbApiException - * @package Tmdb\Exception + * Class TmdbApiException. */ class TmdbApiException extends Exception { @@ -60,35 +61,16 @@ class TmdbApiException extends Exception public const STATUS_RESOURCE_NOT_FOUND = 34; /** - * @var RequestInterface - */ - protected $request; - - /** - * @var ResponseInterface - */ - protected $response; - - /** - * Create the exception - * - * @param int $code - * @param string $message - * @param RequestInterface|null $request - * @param ResponseInterface|null $response - * @param Exception|null $previous + * Create the exception. */ public function __construct( int $code, string $message, - ?RequestInterface $request = null, - ?ResponseInterface $response = null, - ?Exception $previous = null + protected ?\Psr\Http\Message\RequestInterface $request = null, + protected ?\Psr\Http\Message\ResponseInterface $response = null, + ?Exception $previous = null, ) { parent::__construct($message, $code, $previous); - - $this->request = $request; - $this->response = $response; } /** @@ -99,10 +81,6 @@ public function getRequest() return $this->request; } - /** - * @param RequestInterface $request - * @return self - */ public function setRequest(RequestInterface $request): TmdbApiException { $this->request = $request; @@ -118,10 +96,6 @@ public function getResponse() return $this->response; } - /** - * @param ResponseInterface $response - * @return self - */ public function setResponse(ResponseInterface $response): TmdbApiException { $this->response = $response; diff --git a/lib/Tmdb/Exception/UnauthorizedRequestTokenException.php b/lib/Tmdb/Exception/UnauthorizedRequestTokenException.php index 2d98d095..ef66b652 100644 --- a/lib/Tmdb/Exception/UnauthorizedRequestTokenException.php +++ b/lib/Tmdb/Exception/UnauthorizedRequestTokenException.php @@ -1,23 +1,26 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Exception; +use RuntimeException; + /** - * Class UnauthorizedRequestTokenException - * @package Tmdb\Exception + * Class UnauthorizedRequestTokenException. */ -class UnauthorizedRequestTokenException extends \RuntimeException +class UnauthorizedRequestTokenException extends RuntimeException { } diff --git a/lib/Tmdb/Exception/UnexpectedResponseException.php b/lib/Tmdb/Exception/UnexpectedResponseException.php index 77e39354..d717d4b3 100644 --- a/lib/Tmdb/Exception/UnexpectedResponseException.php +++ b/lib/Tmdb/Exception/UnexpectedResponseException.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ diff --git a/lib/Tmdb/Factory/AbstractFactory.php b/lib/Tmdb/Factory/AbstractFactory.php index 74eeafe1..9b55f666 100644 --- a/lib/Tmdb/Factory/AbstractFactory.php +++ b/lib/Tmdb/Factory/AbstractFactory.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ @@ -18,7 +20,6 @@ use Tmdb\Common\ObjectHydrator; use Tmdb\Event\BeforeHydrationEvent; use Tmdb\Event\HydrationEvent; -use Tmdb\Event\TmdbEvents; use Tmdb\HttpClient\HttpClient; use Tmdb\Model\AbstractModel; use Tmdb\Model\Collection\ResultCollection; @@ -28,53 +29,42 @@ use Tmdb\Model\Lists\Result; /** - * Class AbstractFactory + * Class AbstractFactory. * * @template T of AbstractModel - * - * @package Tmdb\Factory */ abstract class AbstractFactory { /** - * @var HttpClient - */ - protected $httpClient; - - /** - * Constructor - * - * @param HttpClient $httpClient + * Constructor. */ - public function __construct(HttpClient $httpClient) + public function __construct(protected \Tmdb\HttpClient\HttpClient $httpClient) { - $this->httpClient = $httpClient; } /** - * Convert an array to an hydrated object + * Convert an array to an hydrated object. * - * @param array $data * @return T */ abstract public function create(array $data = []); /** - * Convert an array with an collection of items to an hydrated object collection + * Convert an array with an collection of items to an hydrated object collection. * - * @param array $data * @return GenericCollection */ abstract public function createCollection(array $data = []); /** - * Create a result collection + * Create a result collection. + * + * @param array|null $data + * @param string $method * - * @param null|array $data - * @param string $method * @return ResultCollection */ - public function createResultCollection($data = [], $method = 'create'): ResultCollection + public function createResultCollection(array $data = [], $method = 'create'): ResultCollection { /** @var ResultCollection */ $collection = new ResultCollection(); @@ -83,33 +73,32 @@ public function createResultCollection($data = [], $method = 'create'): ResultCo return $collection; } - if (array_key_exists('page', $data)) { + if (\array_key_exists('page', $data)) { $collection->setPage($data['page']); } - if (array_key_exists('total_pages', $data)) { + if (\array_key_exists('total_pages', $data)) { $collection->setTotalPages($data['total_pages']); } - if (array_key_exists('total_results', $data)) { + if (\array_key_exists('total_results', $data)) { $collection->setTotalResults($data['total_results']); } - if (array_key_exists('results', $data)) { + if (\array_key_exists('results', $data)) { $data = $data['results']; } foreach ($data as $item) { - $collection->add(null, $this->$method($item)); + $collection->add(null, $this->{$method}($item)); } return $collection; } /** - * Create rating + * Create rating. * - * @param array $data * @return Rating */ public function createRating(array $data = []) @@ -118,12 +107,13 @@ public function createRating(array $data = []) } /** - * Hydrate the object with data + * Hydrate the object with data. * * @template S of AbstractModel * - * @param S $subject + * @param S $subject * @param array $data + * * @return S */ protected function hydrate(AbstractModel $subject, $data = []) @@ -135,9 +125,10 @@ protected function hydrate(AbstractModel $subject, $data = []) $eventBasedHydrationModels = $hydrationOptions['only_for_specified_models']; if ( - $eventListenerHandlesHydration && empty($eventBasedHydrationModels) || in_array( - get_class($subject), - $eventBasedHydrationModels + $eventListenerHandlesHydration && empty($eventBasedHydrationModels) || \in_array( + $subject::class, + $eventBasedHydrationModels, + true, ) ) { $event = new HydrationEvent($subject, $data); @@ -160,7 +151,7 @@ protected function hydrate(AbstractModel $subject, $data = []) } /** - * Get the http client + * Get the http client. * * @return HttpClient */ @@ -170,16 +161,15 @@ protected function getHttpClient() } /** - * Create the account states + * Create the account states. * - * @param array $data * @return AccountStates */ public function createAccountStates(array $data = []) { $accountStates = new AccountStates(); - if (array_key_exists('rated', $data)) { + if (\array_key_exists('rated', $data)) { if ($data['rated']) { $rating = new Rating(); @@ -193,9 +183,8 @@ public function createAccountStates(array $data = []) } /** - * Create result + * Create result. * - * @param array $data * @return Result */ public function createResult(array $data = []) @@ -204,10 +193,10 @@ public function createResult(array $data = []) } /** - * Create a generic collection of data and map it on the class by it's static parameter $properties + * Create a generic collection of data and map it on the class by it's static parameter $properties. * * @template S of AbstractModel - * @param array $data + * * @param S|string $class * * @return GenericCollection @@ -218,8 +207,8 @@ protected function createGenericCollection(array $data = [], $class = null): Gen throw new \Tmdb\Exception\RuntimeException('Expected a class to be present.'); } - if (is_object($class)) { - $class = get_class($class); + if (\is_object($class)) { + $class = $class::class; } /** @var GenericCollection */ @@ -233,26 +222,27 @@ protected function createGenericCollection(array $data = [], $class = null): Gen } /** - * Create a generic collection of data and map it on the class by it's static parameter $properties + * Create a generic collection of data and map it on the class by it's static parameter $properties. * * @template S of AbstractModel * @template SC of GenericCollection - * @param array $data + * * @param S|string $class - * @param SC $collection + * @param SC $collection + * * @return SC */ protected function createCustomCollection( array $data, $class, - GenericCollection $collection + GenericCollection $collection, ) { if (!$class) { throw new \Tmdb\Exception\RuntimeException('Expected a class to be present.'); } - if (is_object($class)) { - $class = get_class($class); + if (\is_object($class)) { + $class = $class::class; } foreach ($data as $item) { @@ -263,9 +253,10 @@ protected function createCustomCollection( } /** - * Create an generic collection of an array that consists out of a mix of movies and tv shows + * Create an generic collection of an array that consists out of a mix of movies and tv shows. * * @param array $data + * * @return GenericCollection */ protected function createGenericCollectionFromMediaTypes($data = []) @@ -275,18 +266,11 @@ protected function createGenericCollectionFromMediaTypes($data = []) $collection = new GenericCollection(); foreach ($data as $item) { - switch ($item['media_type']) { - case "movie": - $collection->add(null, $movieFactory->create($item)); - break; - - case "tv": - $collection->add(null, $tvFactory->create($item)); - break; - - default: - throw new RuntimeException('Unknown media type "%s"', $item['media_type']); - } + match ($item['media_type']) { + 'movie' => $collection->add(null, $movieFactory->create($item)), + 'tv' => $collection->add(null, $tvFactory->create($item)), + default => throw new RuntimeException('Unknown media type "%s"', $item['media_type']), + }; } return $collection; diff --git a/lib/Tmdb/Factory/Account/AvatarFactory.php b/lib/Tmdb/Factory/Account/AvatarFactory.php index f345ab32..3efa7eff 100644 --- a/lib/Tmdb/Factory/Account/AvatarFactory.php +++ b/lib/Tmdb/Factory/Account/AvatarFactory.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ @@ -20,18 +22,15 @@ use Tmdb\Model\Common\GenericCollection; /** - * Class AvatarFactory - * @package Tmdb\Factory\Account + * Class AvatarFactory. */ class AvatarFactory extends AbstractFactory { - /** - * {@inheritdoc} - */ + #[\Override] public function createCollection(array $data = []): GenericCollection { // @todo 4.0.x double check on this bug - if (array_key_exists(0, $data)) { + if (\array_key_exists(0, $data)) { $data = $data[0]; } @@ -42,31 +41,21 @@ public function createCollection(array $data = []): GenericCollection } /** - * @param array $data - * - * @return mixed * @throws InvalidArgumentException - * */ + #[\Override] public function create(array $data = []) { foreach ($data as $type => $content) { // @todo 4.0.x double check on this bug - if (array_key_exists(0, $content)) { + if (\array_key_exists(0, $content)) { $content = array_shift($content); } - switch ($type) { - case "gravatar": - return $this->hydrate(new Gravatar(), $content); - - default: - throw new InvalidArgumentException(sprintf( - 'The avatar type "%s" has not been defined in the factory "%s".', - $type, - __CLASS__ - )); - } + return match ($type) { + 'gravatar' => $this->hydrate(new Gravatar(), $content), + default => throw new InvalidArgumentException(\sprintf('The avatar type "%s" has not been defined in the factory "%s".', $type, self::class)), + }; } return null; diff --git a/lib/Tmdb/Factory/AccountFactory.php b/lib/Tmdb/Factory/AccountFactory.php index b56abba8..e465bcc0 100644 --- a/lib/Tmdb/Factory/AccountFactory.php +++ b/lib/Tmdb/Factory/AccountFactory.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ @@ -22,36 +24,22 @@ use Tmdb\Model\Lists\Result; /** - * Class AccountFactory + * Class AccountFactory. + * * @extends AbstractFactory - * @package Tmdb\Factory */ class AccountFactory extends AbstractFactory { - /** - * @var MovieFactory - */ - private $movieFactory; + private \Tmdb\Factory\MovieFactory $movieFactory; - /** - * @var ImageFactory - */ - private $imageFactory; + private \Tmdb\Factory\ImageFactory $imageFactory; - /** - * @var TvFactory - */ - private $tvFactory; + private \Tmdb\Factory\TvFactory $tvFactory; - /** - * @var AvatarFactory - */ - private $avatarFactory; + private \Tmdb\Factory\Account\AvatarFactory $avatarFactory; /** - * Constructor - * - * @param HttpClient $httpClient + * Constructor. */ public function __construct(HttpClient $httpClient) { @@ -63,18 +51,14 @@ public function __construct(HttpClient $httpClient) parent::__construct($httpClient); } - /** - * @param array $data - * - * @return Account - */ + #[\Override] public function create(array $data = []): Account { $account = new Account(); - if (array_key_exists('avatar', $data)) { + if (\array_key_exists('avatar', $data)) { $account->setAvatar( - $this->getAvatarFactory()->createCollection($data['avatar']) + $this->getAvatarFactory()->createCollection($data['avatar']), ); } @@ -90,8 +74,6 @@ public function getAvatarFactory() } /** - * @param array $data - * * @return Result */ public function createStatusResult(array $data = []) @@ -100,11 +82,7 @@ public function createStatusResult(array $data = []) } /** - * Create movie - * - * @param array $data - * - * @return AbstractModel|null + * Create movie. */ public function createMovie(array $data = []): ?AbstractModel { @@ -121,9 +99,8 @@ public function getMovieFactory() /** * @param MovieFactory $movieFactory - * @return self */ - public function setMovieFactory($movieFactory) + public function setMovieFactory($movieFactory): static { $this->movieFactory = $movieFactory; @@ -131,11 +108,7 @@ public function setMovieFactory($movieFactory) } /** - * Create TV show - * - * @param array $data - * - * @return AbstractModel|null + * Create TV show. */ public function createTvShow(array $data = []): ?AbstractModel { @@ -152,9 +125,8 @@ public function getTvFactory() /** * @param TvFactory $tvFactory - * @return self */ - public function setTvFactory($tvFactory) + public function setTvFactory($tvFactory): static { $this->tvFactory = $tvFactory; @@ -162,16 +134,15 @@ public function setTvFactory($tvFactory) } /** - * Create list item + * Create list item. * - * @param array $data * @return AbstractModel */ public function createListItem(array $data = []) { $listItem = new Account\ListItem(); - if (array_key_exists('poster_path', $data)) { + if (\array_key_exists('poster_path', $data)) { $listItem->setPosterImage($this->getImageFactory()->createFromPath($data['poster_path'], 'poster_path')); } @@ -188,32 +159,24 @@ public function getImageFactory() /** * @param ImageFactory $imageFactory - * @return self */ - public function setImageFactory($imageFactory) + public function setImageFactory($imageFactory): static { $this->imageFactory = $imageFactory; return $this; } - /** - * {@inheritdoc} - */ - public function createCollection(array $data = []) + #[\Override] + public function createCollection(array $data = []): void { - throw new RuntimeException(sprintf( - 'Class "%s" does not support method "%s".', - __CLASS__, - __METHOD__ - )); + throw new RuntimeException(\sprintf('Class "%s" does not support method "%s".', self::class, __METHOD__)); } /** * @param AvatarFactory $avatarFactory - * @return self */ - public function setAvatarFactory($avatarFactory) + public function setAvatarFactory($avatarFactory): static { $this->avatarFactory = $avatarFactory; diff --git a/lib/Tmdb/Factory/AuthenticationFactory.php b/lib/Tmdb/Factory/AuthenticationFactory.php index fef26d0e..91a8d539 100644 --- a/lib/Tmdb/Factory/AuthenticationFactory.php +++ b/lib/Tmdb/Factory/AuthenticationFactory.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ @@ -23,60 +25,44 @@ use Tmdb\Token\Session\SessionToken; /** - * Class AuthenticationFactory - * @package Tmdb\Factory + * Class AuthenticationFactory. */ class AuthenticationFactory extends AbstractFactory { /** - * @param array $data - * - * @return AbstractModel * @throws RuntimeException */ - public function create(array $data = []) + #[\Override] + public function create(array $data = []): never { - throw new RuntimeException(sprintf( - 'Class "%s" does not support method "%s".', - __CLASS__, - __METHOD__ - )); + throw new RuntimeException(\sprintf('Class "%s" does not support method "%s".', self::class, __METHOD__)); } /** - * @param array $data - * - * @return GenericCollection * @throws RuntimeException */ - public function createCollection(array $data = []) + #[\Override] + public function createCollection(array $data = []): never { - throw new RuntimeException(sprintf( - 'Class "%s" does not support method "%s".', - __CLASS__, - __METHOD__ - )); + throw new RuntimeException(\sprintf('Class "%s" does not support method "%s".', self::class, __METHOD__)); } /** - * Create request token - * - * @param array $data - * @return RequestToken + * Create request token. */ - public function createRequestToken(array $data = []) + public function createRequestToken(array $data = []): \Tmdb\Token\Session\RequestToken { $token = new RequestToken(); - if (array_key_exists('expires_at', $data)) { + if (\array_key_exists('expires_at', $data)) { $token->setExpiresAt(new DateTime($data['expires_at'])); } - if (array_key_exists('request_token', $data)) { + if (\array_key_exists('request_token', $data)) { $token->setToken($data['request_token']); } - if (array_key_exists('success', $data)) { + if (\array_key_exists('success', $data)) { $token->setSuccess($data['success']); } @@ -84,20 +70,17 @@ public function createRequestToken(array $data = []) } /** - * Create session token for user - * - * @param array $data - * @return SessionToken + * Create session token for user. */ - public function createSessionToken(array $data = []) + public function createSessionToken(array $data = []): \Tmdb\Token\Session\SessionToken { $token = new SessionToken(); - if (array_key_exists('session_id', $data)) { + if (\array_key_exists('session_id', $data)) { $token->setToken($data['session_id']); } - if (array_key_exists('success', $data)) { + if (\array_key_exists('success', $data)) { $token->setSuccess($data['success']); } @@ -105,24 +88,21 @@ public function createSessionToken(array $data = []) } /** - * Create session token for guest - * - * @param array $data - * @return GuestSessionToken + * Create session token for guest. */ - public function createGuestSessionToken(array $data = []) + public function createGuestSessionToken(array $data = []): \Tmdb\Token\Session\GuestSessionToken { $token = new GuestSessionToken(); - if (array_key_exists('expires_at', $data)) { + if (\array_key_exists('expires_at', $data)) { $token->setExpiresAt(new DateTime($data['expires_at'])); } - if (array_key_exists('guest_session_id', $data)) { + if (\array_key_exists('guest_session_id', $data)) { $token->setToken($data['guest_session_id']); } - if (array_key_exists('success', $data)) { + if (\array_key_exists('success', $data)) { $token->setSuccess($data['success']); } diff --git a/lib/Tmdb/Factory/CertificationFactory.php b/lib/Tmdb/Factory/CertificationFactory.php index a27234ef..30852c37 100644 --- a/lib/Tmdb/Factory/CertificationFactory.php +++ b/lib/Tmdb/Factory/CertificationFactory.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ @@ -18,17 +20,14 @@ use Tmdb\Model\Common\GenericCollection; /** - * Class CertificationFactory - * @package Tmdb\Factory + * Class CertificationFactory. */ class CertificationFactory extends AbstractFactory { - /** - * {@inheritdoc} - */ + #[\Override] public function createCollection(array $data = []): GenericCollection { - if (array_key_exists('certifications', $data)) { + if (\array_key_exists('certifications', $data)) { $data = $data['certifications']; } @@ -50,11 +49,7 @@ public function createCollection(array $data = []): GenericCollection return $collection; } - /** - * @param array $data - * - * @return Certification\CountryCertification - */ + #[\Override] public function create(array $data = []): Certification\CountryCertification { return $this->hydrate(new Certification\CountryCertification(), $data); diff --git a/lib/Tmdb/Factory/ChangesFactory.php b/lib/Tmdb/Factory/ChangesFactory.php index 71064d2a..d1b585e9 100644 --- a/lib/Tmdb/Factory/ChangesFactory.php +++ b/lib/Tmdb/Factory/ChangesFactory.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ @@ -18,31 +20,28 @@ use Tmdb\Model\Collection\Changes; /** - * Class ChangesFactory - * @package Tmdb\Factory + * Class ChangesFactory. */ class ChangesFactory extends AbstractFactory { - /** - * {@inheritdoc} - */ + #[\Override] public function createCollection(array $data = []): Changes { $collection = new Changes(); - if (array_key_exists('page', $data)) { + if (\array_key_exists('page', $data)) { $collection->setPage($data['page']); } - if (array_key_exists('total_pages', $data)) { + if (\array_key_exists('total_pages', $data)) { $collection->setTotalPages($data['total_pages']); } - if (array_key_exists('total_results', $data)) { + if (\array_key_exists('total_results', $data)) { $collection->setTotalResults($data['total_results']); } - if (array_key_exists('results', $data)) { + if (\array_key_exists('results', $data)) { $data = $data['results']; } @@ -53,10 +52,7 @@ public function createCollection(array $data = []): Changes return $collection; } - /** - * {@inheritdoc} - * @return Change - */ + #[\Override] public function create(array $data = []): Change { return $this->hydrate(new Change(), $data); diff --git a/lib/Tmdb/Factory/CollectionFactory.php b/lib/Tmdb/Factory/CollectionFactory.php index d870e3eb..a2de7fc1 100644 --- a/lib/Tmdb/Factory/CollectionFactory.php +++ b/lib/Tmdb/Factory/CollectionFactory.php @@ -1,14 +1,16 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ @@ -16,29 +18,26 @@ use Tmdb\HttpClient\HttpClient; use Tmdb\Model\Collection; -use Tmdb\Model\Common\Translation; use Tmdb\Model\Common\GenericCollection; +use Tmdb\Model\Common\Translation; /** - * Class CollectionFactory - * @package Tmdb\Factory + * Class CollectionFactory. */ class CollectionFactory extends AbstractFactory { /** - * @var MovieFactory + * @var ImageFactory|mixed */ - private $movieFactory; + private $imageFactory; /** - * @var ImageFactory + * @var MovieFactory|mixed */ - private $imageFactory; + private $movieFactory; /** - * Constructor - * - * @param HttpClient $httpClient + * Constructor. */ public function __construct(HttpClient $httpClient) { @@ -48,9 +47,7 @@ public function __construct(HttpClient $httpClient) parent::__construct($httpClient); } - /** - * {@inheritdoc} - */ + #[\Override] public function createCollection(array $data = []): GenericCollection { $collection = new GenericCollection(); @@ -62,48 +59,45 @@ public function createCollection(array $data = []): GenericCollection return $collection; } - /** - * {@inheritdoc} - * @return Collection - */ + #[\Override] public function create(array $data = []): Collection { $collection = new Collection(); - if (array_key_exists('parts', $data)) { + if (\array_key_exists('parts', $data)) { $collection->setParts( - $this->getMovieFactory()->createCollection($data['parts']) + $this->getMovieFactory()->createCollection($data['parts']), ); } - if (array_key_exists('backdrop_path', $data)) { + if (\array_key_exists('backdrop_path', $data)) { $collection->setBackdropImage( - $this->getImageFactory()->createFromPath($data['backdrop_path'], 'backdrop_path') + $this->getImageFactory()->createFromPath($data['backdrop_path'], 'backdrop_path'), ); } - if (array_key_exists('images', $data)) { + if (\array_key_exists('images', $data)) { $collection->setImages( - $this->getImageFactory()->createCollectionFromMovie($data['images']) + $this->getImageFactory()->createCollectionFromMovie($data['images']), ); } - if (array_key_exists('poster_path', $data)) { + if (\array_key_exists('poster_path', $data)) { $collection->setPosterImage( - $this->getImageFactory()->createFromPath($data['poster_path'], 'poster_path') + $this->getImageFactory()->createFromPath($data['poster_path'], 'poster_path'), ); } - /** Translations */ - if (array_key_exists('translations', $data) && null !== $data['translations']) { - if (array_key_exists('translations', $data['translations'])) { + /* Translations */ + if (\array_key_exists('translations', $data) && null !== $data['translations']) { + if (\array_key_exists('translations', $data['translations'])) { $translations = $data['translations']['translations']; } else { $translations = $data['translations']; } $collection->setTranslations( - $this->createGenericCollection($translations, new Translation()) + $this->createGenericCollection($translations, new Translation()), ); } @@ -120,9 +114,8 @@ public function getMovieFactory() /** * @param MovieFactory $movieFactory - * @return self */ - public function setMovieFactory($movieFactory) + public function setMovieFactory($movieFactory): static { $this->movieFactory = $movieFactory; @@ -139,9 +132,8 @@ public function getImageFactory() /** * @param ImageFactory $imageFactory - * @return self */ - public function setImageFactory($imageFactory) + public function setImageFactory($imageFactory): static { $this->imageFactory = $imageFactory; diff --git a/lib/Tmdb/Factory/Common/ChangeFactory.php b/lib/Tmdb/Factory/Common/ChangeFactory.php index c06645b7..aa85a127 100644 --- a/lib/Tmdb/Factory/Common/ChangeFactory.php +++ b/lib/Tmdb/Factory/Common/ChangeFactory.php @@ -1,39 +1,37 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Factory\Common; use Tmdb\Factory\AbstractFactory; -use Tmdb\Model\AbstractModel; use Tmdb\Model\Collection\Changes; use Tmdb\Model\Common\Change; use Tmdb\Model\Common\GenericCollection; /** - * Class ChangeFactory - * @package Tmdb\Factory\Common + * Class ChangeFactory. */ class ChangeFactory extends AbstractFactory { - /** - * {@inheritdoc} - */ + #[\Override] public function createCollection(array $data = []): Changes { $collection = new Changes(); - if (array_key_exists('changes', $data)) { + if (\array_key_exists('changes', $data)) { $data = $data['changes']; } @@ -44,14 +42,12 @@ public function createCollection(array $data = []): Changes return $collection; } - /** - * {@inheritdoc} - */ + #[\Override] public function create(array $data = []): Change { $change = new Change(); - if (array_key_exists('items', $data)) { + if (\array_key_exists('items', $data)) { $items = new GenericCollection(); foreach ($data['items'] as $item) { @@ -67,10 +63,7 @@ public function create(array $data = []): Change } /** - * Create individual change items - * - * @param array $data - * @return Change\Item + * Create individual change items. */ private function createChangeItem(array $data = []): Change\Item { diff --git a/lib/Tmdb/Factory/Common/VideoFactory.php b/lib/Tmdb/Factory/Common/VideoFactory.php index 887a114a..968640e7 100644 --- a/lib/Tmdb/Factory/Common/VideoFactory.php +++ b/lib/Tmdb/Factory/Common/VideoFactory.php @@ -1,43 +1,42 @@ * @copyright (c) 2013, Michael Roterman + * * @version 4.0.0 */ namespace Tmdb\Factory\Common; use Tmdb\Factory\AbstractFactory; -use Tmdb\Model\AbstractModel; use Tmdb\Model\Collection\Videos; use Tmdb\Model\Common\Video; /** - * Class VideoFactory + * Class VideoFactory. + * * @extends AbstractFactory