Skip to content

Commit 37261a3

Browse files
norkunasjbelien
andauthored
Resolve some deprecations and remove igorw/get-in dependency (#1257)
* Remove `igorw/get-in` dependency to simplify code * Fix phpunit deprecation * Simplify phpunit's `->will($this->returnValue())` with `->willReturn()` * Simplify phpunit's `->will($this->returnCallback())` with `->willReturnCallback()` * Fix deprecated mock builder `setMethds` with `createPartialMock` * Remove deprecated phpstan `checkGenericClassInNonGenericObjectType` option * Bump phpunit to 9.6 --------- Co-authored-by: Jonathan Beliën <[email protected]>
1 parent c36dc82 commit 37261a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+88
-146
lines changed

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"homepage": "http://geocoder-php.org",
1919
"require": {
2020
"php": ">=8.2",
21-
"igorw/get-in": "^1.0",
2221
"php-http/discovery": "^1.17",
2322
"php-http/promise": "^1.0",
2423
"psr/http-client-implementation": "^1.0",
@@ -41,7 +40,7 @@
4140
"phpstan/extension-installer": "^1.3",
4241
"phpstan/phpstan": "^1.10",
4342
"phpstan/phpstan-phpunit": "^1.3",
44-
"phpunit/phpunit": "^9.6",
43+
"phpunit/phpunit": "^9.6.11",
4544
"symfony/http-client": "^5.4.45 || ^6.4 || ^7.0",
4645
"symfony/stopwatch": "^5.4 || ^6.4 || ^7.0"
4746
},

phpstan.neon

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@ parameters:
77
excludePaths:
88
- **/vendor/**
99
treatPhpDocTypesAsCertain: false
10-
checkGenericClassInNonGenericObjectType: false

src/Common/Tests/TimedGeocoderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function testGeocode(): void
4747
{
4848
$this->delegate->expects($this->once())
4949
->method('geocodeQuery')
50-
->will($this->returnValue(new AddressCollection([])));
50+
->willReturn(new AddressCollection([]));
5151

5252
$this->geocoder->geocode('foo');
5353

@@ -74,7 +74,7 @@ public function testReverse(): void
7474
{
7575
$this->delegate->expects($this->once())
7676
->method('reverseQuery')
77-
->will($this->returnValue(new AddressCollection([])));
77+
->willReturn(new AddressCollection([]));
7878

7979
$this->geocoder->reverse(0, 0);
8080

src/Common/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
"require-dev": {
2323
"nyholm/nsa": "^1.1",
24-
"phpunit/phpunit": "^9.5",
24+
"phpunit/phpunit": "^9.6.11",
2525
"symfony/stopwatch": "~2.5 || ~5.0 || ~7.0"
2626
},
2727
"suggest": {

src/Http/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"nyholm/psr7": "^1.0",
2525
"php-http/message": "^1.0",
2626
"php-http/mock-client": "^1.0",
27-
"phpunit/phpunit": "^9.5",
27+
"phpunit/phpunit": "^9.6.11",
2828
"symfony/stopwatch": "~2.5 || ~5.0"
2929
},
3030
"extra": {

src/Plugin/Tests/Plugin/CachePluginTest.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ public function testPluginMiss(): void
2727
$ttl = 4711;
2828
$query = GeocodeQuery::create('foo');
2929
$queryString = sha1($query->__toString());
30-
$cache = $this->getMockBuilder(VoidCachePool::class)
31-
->disableOriginalConstructor()
32-
->setMethods(['get', 'set'])
33-
->getMock();
30+
$cache = $this->createPartialMock(VoidCachePool::class, ['get', 'set']);
3431

3532
$cache->expects($this->once())
3633
->method('get')
@@ -69,10 +66,7 @@ public function getQueryProvider(): \Generator
6966
*/
7067
public function testPluginHit(Query $query, string $key): void
7168
{
72-
$cache = $this->getMockBuilder(VoidCachePool::class)
73-
->disableOriginalConstructor()
74-
->setMethods(['get', 'set'])
75-
->getMock();
69+
$cache = $this->createPartialMock(VoidCachePool::class, ['get', 'set']);
7670

7771
$cache->expects($this->once())
7872
->method('get')

src/Plugin/Tests/Plugin/LoggerPluginTest.php

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ class LoggerPluginTest extends TestCase
2525
{
2626
public function testPlugin(): void
2727
{
28-
$logger = $this->getMockBuilder(AbstractLogger::class)
29-
->disableOriginalConstructor()
30-
->setMethods(['log'])
31-
->getMock();
28+
$logger = $this->createPartialMock(AbstractLogger::class, ['log']);
3229
$logger->expects($this->once())
3330
->method('log')
3431
->with('info', $this->callback(function ($message) {
@@ -38,10 +35,7 @@ public function testPlugin(): void
3835
$geocodeQuery = GeocodeQuery::create('foo');
3936
$collection = new AddressCollection([]);
4037

41-
$provider = $this->getMockBuilder(Provider::class)
42-
->disableOriginalConstructor()
43-
->setMethods(['geocodeQuery', 'reverseQuery', 'getName'])
44-
->getMock();
38+
$provider = $this->createPartialMock(Provider::class, ['geocodeQuery', 'reverseQuery', 'getName']);
4539
$provider->expects($this->once())
4640
->method('geocodeQuery')
4741
->with($geocodeQuery)
@@ -56,21 +50,15 @@ public function testPlugin(): void
5650
public function testPluginException(): void
5751
{
5852
$this->expectException(QuotaExceeded::class);
59-
$logger = $this->getMockBuilder(AbstractLogger::class)
60-
->disableOriginalConstructor()
61-
->setMethods(['log'])
62-
->getMock();
53+
$logger = $this->createPartialMock(AbstractLogger::class, ['log']);
6354
$logger->expects($this->once())
6455
->method('log')
6556
->with('error', $this->callback(function ($message) {
6657
return false !== strstr($message, 'QuotaExceeded');
6758
}));
6859

6960
$geocodeQuery = GeocodeQuery::create('foo');
70-
$provider = $this->getMockBuilder(Provider::class)
71-
->disableOriginalConstructor()
72-
->setMethods(['geocodeQuery', 'reverseQuery', 'getName'])
73-
->getMock();
61+
$provider = $this->createPartialMock(Provider::class, ['geocodeQuery', 'reverseQuery', 'getName']);
7462
$provider->expects($this->once())
7563
->method('geocodeQuery')
7664
->willThrowException(new QuotaExceeded());

src/Plugin/Tests/PluginProviderTest.php

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ public function testDispatchQueries(): void
3030
$reverseQuery = ReverseQuery::fromCoordinates(47, 11);
3131
$collection = new AddressCollection([]);
3232

33-
$provider = $this->getMockBuilder(Provider::class)
34-
->disableOriginalConstructor()
35-
->setMethods(['geocodeQuery', 'reverseQuery', 'getName'])
36-
->getMock();
33+
$provider = $this->createPartialMock(Provider::class, ['geocodeQuery', 'reverseQuery', 'getName']);
3734
$provider->expects($this->once())
3835
->method('geocodeQuery')
3936
->with($geocodeQuery)
@@ -54,21 +51,15 @@ public function testPluginsIsBeingUsedWhenGeocoding(): void
5451
$geocodeQuery = GeocodeQuery::create('foo');
5552
$collection = new AddressCollection([]);
5653

57-
$provider = $this->getMockBuilder(Provider::class)
58-
->disableOriginalConstructor()
59-
->setMethods(['geocodeQuery', 'reverseQuery', 'getName'])
60-
->getMock();
54+
$provider = $this->createPartialMock(Provider::class, ['geocodeQuery', 'reverseQuery', 'getName']);
6155
$provider->expects($this->once())
6256
->method('geocodeQuery')
6357
->with($geocodeQuery)
6458
->willReturn($collection);
6559
$provider->expects($this->never())->method('reverseQuery');
6660
$provider->expects($this->never())->method('getName');
6761

68-
$pluginA = $this->getMockBuilder(Plugin::class)
69-
->disableOriginalConstructor()
70-
->setMethods(['handleQuery'])
71-
->getMock();
62+
$pluginA = $this->createPartialMock(Plugin::class, ['handleQuery']);
7263
$pluginA->expects($this->once())
7364
->method('handleQuery')
7465
->with($geocodeQuery, $this->isType('callable'), $this->isType('callable'))
@@ -85,21 +76,15 @@ public function testPluginsIsBeingUsedWhenReverse(): void
8576
$reverseQuery = ReverseQuery::fromCoordinates(47, 11);
8677
$collection = new AddressCollection([]);
8778

88-
$provider = $this->getMockBuilder(Provider::class)
89-
->disableOriginalConstructor()
90-
->setMethods(['geocodeQuery', 'reverseQuery', 'getName'])
91-
->getMock();
79+
$provider = $this->createPartialMock(Provider::class, ['geocodeQuery', 'reverseQuery', 'getName']);
9280
$provider->expects($this->never())->method('geocodeQuery');
9381
$provider->expects($this->never())->method('getName');
9482
$provider->expects($this->once())
9583
->method('reverseQuery')
9684
->with($reverseQuery)
9785
->willReturn($collection);
9886

99-
$pluginA = $this->getMockBuilder(Plugin::class)
100-
->disableOriginalConstructor()
101-
->setMethods(['handleQuery'])
102-
->getMock();
87+
$pluginA = $this->createPartialMock(Plugin::class, ['handleQuery']);
10388
$pluginA->expects($this->once())
10489
->method('handleQuery')
10590
->with($reverseQuery, $this->isType('callable'), $this->isType('callable'))
@@ -116,28 +101,19 @@ public function testLoopException(): void
116101
$this->expectException(LoopException::class);
117102
$geocodeQuery = GeocodeQuery::create('foo');
118103

119-
$provider = $this->getMockBuilder(Provider::class)
120-
->disableOriginalConstructor()
121-
->setMethods(['geocodeQuery', 'reverseQuery', 'getName'])
122-
->getMock();
104+
$provider = $this->createPartialMock(Provider::class, ['geocodeQuery', 'reverseQuery', 'getName']);
123105
$provider->expects($this->never())->method('geocodeQuery');
124106
$provider->expects($this->never())->method('reverseQuery');
125107
$provider->expects($this->never())->method('getName');
126108

127-
$pluginA = $this->getMockBuilder(Plugin::class)
128-
->disableOriginalConstructor()
129-
->setMethods(['handleQuery'])
130-
->getMock();
109+
$pluginA = $this->createPartialMock(Plugin::class, ['handleQuery']);
131110
$pluginA->expects($this->any())
132111
->method('handleQuery')
133112
->with($geocodeQuery, $this->isType('callable'), $this->isType('callable'))
134113
->willReturnCallback(function (Query $query, callable $next, callable $first) {
135114
return $next($query);
136115
});
137-
$pluginB = $this->getMockBuilder(Plugin::class)
138-
->disableOriginalConstructor()
139-
->setMethods(['handleQuery'])
140-
->getMock();
116+
$pluginB = $this->createPartialMock(Plugin::class, ['handleQuery']);
141117
$pluginB->expects($this->any())
142118
->method('handleQuery')
143119
->with($geocodeQuery, $this->isType('callable'), $this->isType('callable'))

src/Plugin/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323
"require-dev": {
2424
"cache/void-adapter": "^1.0",
25-
"phpunit/phpunit": "^9.5"
25+
"phpunit/phpunit": "^9.6.11"
2626
},
2727
"extra": {
2828
"branch-alias": {

src/Provider/AlgoliaPlaces/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"require-dev": {
2424
"geocoder-php/provider-integration-tests": "^1.6.3",
2525
"php-http/message": "^1.0",
26-
"phpunit/phpunit": "^9.5"
26+
"phpunit/phpunit": "^9.6.11"
2727
},
2828
"extra": {
2929
"branch-alias": {

src/Provider/ArcGISOnline/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"require-dev": {
2323
"geocoder-php/provider-integration-tests": "^1.6.3",
2424
"php-http/message": "^1.0",
25-
"phpunit/phpunit": "^9.5"
25+
"phpunit/phpunit": "^9.6.11"
2626
},
2727
"extra": {
2828
"branch-alias": {

src/Provider/AzureMaps/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"require-dev": {
2222
"geocoder-php/provider-integration-tests": "^1.6.3",
2323
"php-http/message": "^1.0",
24-
"phpunit/phpunit": "^9.5"
24+
"phpunit/phpunit": "^9.6.11"
2525
},
2626
"extra": {
2727
"branch-alias": {

src/Provider/BingMaps/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"require-dev": {
2323
"geocoder-php/provider-integration-tests": "^1.6.3",
2424
"php-http/message": "^1.0",
25-
"phpunit/phpunit": "^9.5"
25+
"phpunit/phpunit": "^9.6.11"
2626
},
2727
"extra": {
2828
"branch-alias": {

src/Provider/Cache/Tests/ProviderCacheTest.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,9 @@ protected function setUp(): void
4141
{
4242
parent::setUp();
4343

44-
$this->cacheMock = $this->getMockBuilder(CacheInterface::class)
45-
->setMethods(['get', 'set', 'delete', 'clear', 'setMultiple', 'getMultiple', 'deleteMultiple', 'has'])
44+
$this->cacheMock = $this->createPartialMock(CacheInterface::class, ['get', 'set', 'delete', 'clear', 'setMultiple', 'getMultiple', 'deleteMultiple', 'has']);
4645

47-
->getMock();
48-
49-
$this->providerMock = $this->getMockBuilder(Provider::class)
50-
->setMethods(['getFoo', 'getName', 'geocodeQuery', 'reverseQuery'])
51-
->getMock();
46+
$this->providerMock = $this->createPartialMock(Provider::class, ['getName', 'geocodeQuery', 'reverseQuery']);
5247
}
5348

5449
public function testName(): void

src/Provider/Cache/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"geocoder-php/provider-implementation": "1.0"
2121
},
2222
"require-dev": {
23-
"phpunit/phpunit": "^9.5"
23+
"phpunit/phpunit": "^9.6.11"
2424
},
2525
"extra": {
2626
"branch-alias": {

src/Provider/Chain/Tests/ChainTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ public function testReverse(): void
4545
$mockOne = $this->getMockBuilder(Provider::class)->getMock();
4646
$mockOne->expects($this->once())
4747
->method('reverseQuery')
48-
->will($this->returnCallback(function () {
48+
->willReturnCallback(function () {
4949
throw new \Exception();
50-
}));
50+
});
5151

5252
$mockTwo = $this->getMockBuilder(Provider::class)->getMock();
5353
$result = new AddressCollection(['foo' => 'bar']);
5454
$mockTwo->expects($this->once())
5555
->method('reverseQuery')
56-
->will($this->returnValue($result));
56+
->willReturn($result);
5757

5858
$chain = new Chain([$mockOne, $mockTwo]);
5959

@@ -66,16 +66,16 @@ public function testGeocode(): void
6666
$mockOne = $this->getMockBuilder(Provider::class)->getMock();
6767
$mockOne->expects($this->once())
6868
->method('geocodeQuery')
69-
->will($this->returnCallback(function () {
69+
->willReturnCallback(function () {
7070
throw new \Exception();
71-
}));
71+
});
7272

7373
$mockTwo = $this->getMockBuilder(Provider::class)->getMock();
7474
$result = new AddressCollection(['foo' => 'bar']);
7575
$mockTwo->expects($this->once())
7676
->method('geocodeQuery')
7777
->with($query)
78-
->will($this->returnValue($result));
78+
->willReturn($result);
7979

8080
$chain = new Chain([$mockOne, $mockTwo]);
8181

src/Provider/Chain/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"nyholm/nsa": "^1.1",
2424
"php-http/curl-client": "^2.2",
2525
"php-http/message": "^1.0",
26-
"phpunit/phpunit": "^9.5"
26+
"phpunit/phpunit": "^9.6.11"
2727
},
2828
"extra": {
2929
"branch-alias": {

src/Provider/FreeGeoIp/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"require-dev": {
2323
"geocoder-php/provider-integration-tests": "^1.6.3",
2424
"php-http/message": "^1.0",
25-
"phpunit/phpunit": "^9.5"
25+
"phpunit/phpunit": "^9.6.11"
2626
},
2727
"extra": {
2828
"branch-alias": {

0 commit comments

Comments
 (0)