Skip to content

Commit 6338e84

Browse files
authored
Update composer dependencies (#289)
* Updated dependencies, including Symfony 7 * Update PHPStan version
1 parent 025ce6c commit 6338e84

File tree

7 files changed

+72
-49
lines changed

7 files changed

+72
-49
lines changed

composer.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"require": {
3434
"php": "^7.3 || ^8.0",
3535
"ext-json": "*",
36-
"symfony/options-resolver": "^4.4 || ^5 || ^6",
36+
"symfony/options-resolver": "^4.4 || ^5 || ^6 || ^7",
3737
"psr/cache": "^1 || ^2 || ^3",
3838
"psr/simple-cache": "^1 || ^2 || ^3",
3939
"psr/event-dispatcher": "^1",
@@ -44,27 +44,27 @@
4444
"psr/http-client-implementation": "^1",
4545
"psr/http-factory": "^1",
4646
"psr/http-factory-implementation": "^1",
47-
"psr/http-message": "^1"
47+
"psr/http-message": "^1 || ^2"
4848
},
4949
"require-dev": {
5050
"nyholm/psr7": "^1.2",
5151
"php-http/mock-client": "^1.2",
52-
"slevomat/coding-standard": "^8.8",
53-
"squizlabs/php_codesniffer": "^3.5.8",
54-
"symfony/cache": "^4.4 || ^5 || ^6",
55-
"symfony/event-dispatcher": "^4.4 || ^5 || ^6",
56-
"phpstan/phpstan": "^1.8.1",
57-
"phpstan/phpstan-deprecation-rules": "^1.1",
58-
"spaze/phpstan-disallowed-calls": "^2.11",
59-
"phpunit/phpunit": "^9.6.3",
52+
"slevomat/coding-standard": "^8.27.1",
53+
"squizlabs/php_codesniffer": "^4.0.1",
54+
"symfony/cache": "^4.4 || ^5 || ^6 || ^7",
55+
"symfony/event-dispatcher": "^4.4 || ^5 || ^6 || ^7",
56+
"phpstan/phpstan": "^2.1.38",
57+
"phpstan/phpstan-deprecation-rules": "^2.0.3",
58+
"spaze/phpstan-disallowed-calls": "^4.7.0",
59+
"phpunit/phpunit": "^9 || ^10 || ^11",
6060
"php-http/guzzle7-adapter": "^1.0",
6161
"monolog/monolog": "^2.9.1 || ^3.0",
62-
"php-http/cache-plugin": "^1.7",
62+
"php-http/cache-plugin": "^1.7 || ^2.0",
6363
"jeroen/psr-log-test-doubles": "^2.1 || ^3"
6464
},
6565
"scripts": {
6666
"test": "vendor/bin/phpunit",
67-
"test-ci": "vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml coverage",
67+
"test-ci": "vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml",
6868
"test-coverage": "php -d xdebug.mode=coverage vendor/bin/phpunit --coverage-html build/coverage",
6969
"test-cs": "vendor/bin/phpcs",
7070
"test-phpstan": "vendor/bin/phpstan analyse"

lib/Tmdb/Api/AbstractApi.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,12 @@ private function decodeResponse(ResponseInterface $response)
196196
{
197197
try {
198198
if ($response->getBody() instanceof StreamInterface) {
199-
return json_decode((string)$response->getBody(), true, 512, JSON_THROW_ON_ERROR);
199+
$body = (string)$response->getBody();
200+
if (trim($body) === '') {
201+
return [];
202+
}
203+
204+
return json_decode($body, true, 512, JSON_THROW_ON_ERROR);
200205
}
201206

202207
return [];

phpstan-baseline.neon

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,97 @@
11
parameters:
22
ignoreErrors:
33
-
4-
message: "#^Instanceof between Psr\\\\Http\\\\Message\\\\StreamInterface and Psr\\\\Http\\\\Message\\\\StreamInterface will always evaluate to true\\.$#"
4+
rawMessage: Instanceof between Psr\Http\Message\StreamInterface and Psr\Http\Message\StreamInterface will always evaluate to true.
5+
identifier: instanceof.alwaysTrue
56
count: 1
67
path: lib/Tmdb/Api/AbstractApi.php
78

89
-
9-
message: "#^Unreachable statement \\- code above always terminates\\.$#"
10+
rawMessage: Unreachable statement - code above always terminates.
11+
identifier: deadCode.unreachable
1012
count: 1
1113
path: lib/Tmdb/Api/AbstractApi.php
1214

1315
-
14-
message: "#^Strict comparison using \\!\\=\\= between null and Psr\\\\Http\\\\Message\\\\StreamInterface will always evaluate to true\\.$#"
16+
rawMessage: 'Strict comparison using !== between null and Psr\Http\Message\StreamInterface will always evaluate to true.'
17+
identifier: notIdentical.alwaysTrue
1518
count: 1
1619
path: lib/Tmdb/Event/Listener/Logger/LogHttpMessageListener.php
1720

1821
-
19-
message: "#^Parameter \\#3 \\$first of method Http\\\\Client\\\\Common\\\\Plugin\\\\CachePlugin\\:\\:handleRequest\\(\\) expects callable\\(Psr\\\\Http\\\\Message\\\\RequestInterface\\)\\: Http\\\\Promise\\\\Promise, Closure\\(\\)\\: void given\\.$#"
22+
rawMessage: 'Parameter #3 $first of method Http\Client\Common\Plugin\CachePlugin::handleRequest() expects callable(Psr\Http\Message\RequestInterface): Http\Promise\Promise, Closure(): void given.'
23+
identifier: argument.type
2024
count: 1
2125
path: lib/Tmdb/Event/Listener/Psr6CachedRequestListener.php
2226

2327
-
24-
message: "#^Property Tmdb\\\\Event\\\\Listener\\\\Psr6CachedRequestListener\\:\\:\\$options is never read, only written\\.$#"
28+
rawMessage: 'Property Tmdb\Event\Listener\Psr6CachedRequestListener::$options is never read, only written.'
29+
identifier: property.onlyWritten
2530
count: 1
2631
path: lib/Tmdb/Event/Listener/Psr6CachedRequestListener.php
2732

2833
-
29-
message: """
30-
#^Call to deprecated method setReleases\\(\\) of class Tmdb\\\\Model\\\\Movie\\:
31-
Use the setReleaseDates instead\\.$#
32-
"""
34+
rawMessage: '''
35+
Call to deprecated method setReleases() of class Tmdb\Model\Movie:
36+
Use the setReleaseDates instead.
37+
'''
38+
identifier: method.deprecated
3339
count: 1
3440
path: lib/Tmdb/Factory/MovieFactory.php
3541

3642
-
37-
message: """
38-
#^Instantiation of deprecated class Tmdb\\\\Model\\\\Movie\\\\Release\\:
39-
Use ReleaseDate instead$#
40-
"""
43+
rawMessage: '''
44+
Instantiation of deprecated class Tmdb\Model\Movie\Release:
45+
Use ReleaseDate instead
46+
'''
47+
identifier: new.deprecatedClass
4148
count: 1
4249
path: lib/Tmdb/Factory/MovieFactory.php
4350

4451
-
45-
message: "#^Return type \\(Tmdb\\\\Model\\\\Collection\\\\People\\) of method Tmdb\\\\Factory\\\\PeopleFactory\\:\\:createCollection\\(\\) should be compatible with return type \\(Tmdb\\\\Model\\\\Common\\\\GenericCollection\\<Tmdb\\\\Model\\\\AbstractModel\\>\\) of method Tmdb\\\\Factory\\\\AbstractFactory\\<Tmdb\\\\Model\\\\AbstractModel\\>\\:\\:createCollection\\(\\)$#"
52+
rawMessage: 'Return type (Tmdb\Model\Collection\People) of method Tmdb\Factory\PeopleFactory::createCollection() should be compatible with return type (Tmdb\Model\Common\GenericCollection<Tmdb\Model\AbstractModel>) of method Tmdb\Factory\AbstractFactory<Tmdb\Model\AbstractModel>::createCollection()'
53+
identifier: method.childReturnType
4654
count: 1
4755
path: lib/Tmdb/Factory/PeopleFactory.php
4856

4957
-
50-
message: "#^Property Tmdb\\\\HttpClient\\\\HttpClient\\:\\:\\$sessionToken is never written, only read\\.$#"
58+
rawMessage: 'Property Tmdb\HttpClient\HttpClient::$sessionToken (Tmdb\Token\Session\SessionToken|null) is never assigned Tmdb\Token\Session\SessionToken so it can be removed from the property type.'
59+
identifier: property.unusedType
5160
count: 1
5261
path: lib/Tmdb/HttpClient/HttpClient.php
5362

5463
-
55-
message: """
56-
#^Access to deprecated property \\$releases of class Tmdb\\\\Model\\\\Movie\\:
57-
Use \\$release_dates instead$#
58-
"""
64+
rawMessage: 'Property Tmdb\HttpClient\HttpClient::$sessionToken is never written, only read.'
65+
identifier: property.onlyRead
66+
count: 1
67+
path: lib/Tmdb/HttpClient/HttpClient.php
68+
69+
-
70+
rawMessage: '''
71+
Access to deprecated property $releases of class Tmdb\Model\Movie:
72+
Use $release_dates instead
73+
'''
74+
identifier: property.deprecated
5975
count: 1
6076
path: lib/Tmdb/Model/Movie.php
6177

6278
-
63-
message: """
64-
#^Return type of method Tmdb\\\\Repository\\\\MovieRepository\\:\\:getReleases\\(\\) has typehint with deprecated class Tmdb\\\\Model\\\\Movie\\\\Release\\:
65-
Use ReleaseDate instead$#
66-
"""
79+
rawMessage: '''
80+
Return type of method Tmdb\Repository\MovieRepository::getReleases() has typehint with deprecated class Tmdb\Model\Movie\Release:
81+
Use ReleaseDate instead
82+
'''
83+
identifier: return.deprecatedClass
6784
count: 1
6885
path: lib/Tmdb/Repository/MovieRepository.php
6986

7087
-
71-
message: "#^Result of \\|\\| is always false\\.$#"
88+
rawMessage: Result of || is always false.
89+
identifier: booleanOr.alwaysFalse
7290
count: 1
7391
path: lib/Tmdb/Repository/TvSeasonRepository.php
7492

7593
-
76-
message: "#^Strict comparison using \\=\\=\\= between null and int will always evaluate to false\\.$#"
94+
rawMessage: 'Strict comparison using === between null and int will always evaluate to false.'
95+
identifier: identical.alwaysFalse
7796
count: 2
7897
path: lib/Tmdb/Repository/TvSeasonRepository.php

phpstan.neon.dist

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ includes:
99

1010
parameters:
1111
level: 5
12-
checkAlwaysTrueCheckTypeFunctionCall: true
13-
checkAlwaysTrueInstanceof: true
14-
checkAlwaysTrueStrictComparison: true
1512
checkExplicitMixedMissingReturn: true
1613
checkFunctionNameCase: true
1714
checkInternalClassCaseSensitivity: true

phpunit.xml.dist

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" bootstrap="test/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3-
<coverage>
4-
<include>
5-
<directory>lib</directory>
6-
</include>
7-
</coverage>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" bootstrap="test/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
83
<testsuites>
94
<testsuite name="php-tmdb-symfony Test Suite">
105
<directory suffix="Test.php">./test/</directory>
116
</testsuite>
127
</testsuites>
8+
<source>
9+
<include>
10+
<directory suffix=".php">lib</directory>
11+
</include>
12+
</source>
1313
</phpunit>

test/Tmdb/Tests/Api/TestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ protected function getMockedApi(array $methods = [], array $clientMethods = [],
6767
}
6868

6969
return $this->_api = $this->getMockBuilder($this->getApiClass())
70-
->setMethods($methods)
70+
->onlyMethods($methods)
7171
->setConstructorArgs([$this->_client])
7272
->getMock();
7373
}

test/Tmdb/Tests/TestCase.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ protected function getClientWithMockedHttpClient(array $options = array())
9090
$options['api_token'] = new ApiToken('abcdef');
9191
$options['http']['client'] = new \Http\Mock\Client();
9292
$response = $this->createMock('Psr\Http\Message\ResponseInterface');
93+
$streamFactory = Psr17FactoryDiscovery::findStreamFactory();
94+
$response->method('getBody')->willReturn($streamFactory->createStream('{}'));
9395
$options['http']['client']->setDefaultResponse($response);
9496

9597
$client = new Client($options);
@@ -170,7 +172,7 @@ protected function getMockedHttpClient(array $methods = [])
170172
$methods[] = 'send';
171173
}
172174

173-
return $this->getMockBuilder('Guzzle\Http\Client')->setMethods($methods)->getMock();
175+
return $this->getMockBuilder('Guzzle\Http\Client')->onlyMethods($methods)->getMock();
174176
}
175177

176178
/**

0 commit comments

Comments
 (0)