Open
Conversation
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.
- 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
- 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
There was a problem hiding this comment.
Pull Request Overview
This PR modernizes the TMDB PHP client by introducing strict types and explicit return type hints across API classes, updating the PHP requirement and dependencies to recent versions, and revising CI workflows to test on PHP 8.3/8.4 with the latest GitHub Actions.
- Added
declare(strict_types=1)and return types to API methods - Bumped PHP requirement to
^8.3, updated composer dependencies, and moved PHPUnit versions - Updated GitHub Actions workflows to use PHP 8.3/8.4 and upgraded action versions
Reviewed Changes
Copilot reviewed 385 out of 385 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| composer.json | Bumped php requirement, updated dependencies and mistakenly moved PHPUnit to require |
| lib/Tmdb/Api/AbstractApi.php | Introduced strict types, property promotion, and revamped decodeResponse with exceptions |
| .github/workflows/continuous-integration.yml | Updated PHP matrix to 8.3/8.4 and upgraded actions/checkout, actions/cache, and codecov |
| lib/Tmdb/Api/GuestSession.php | Added strict types and return type for getRatedMovies, but docblock lacks @return array |
Comments suppressed due to low confidence (2)
lib/Tmdb/Api/AbstractApi.php:161
- Add tests for empty and
'0'response bodies to ensure correct handling for 204 No Content and valid numeric zero responses.
if ($body === '' || $body === '0') {
composer.json:47
- PHPUnit is a development tool and should be declared under
require-dev, not in the mainrequiresection.
"phpunit/phpunit": "^12.1"
| * @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 |
There was a problem hiding this comment.
Update the docblock to include a @return array annotation to match the new return type.
Suggested change
| * @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 | |
| * @return array An array containing the list of rated movies. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.