Skip to content

Resolve some deprecations and remove igorw/get-in dependency #1257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"homepage": "http://geocoder-php.org",
"require": {
"php": ">=8.2",
"igorw/get-in": "^1.0",
"php-http/discovery": "^1.17",
"php-http/promise": "^1.0",
"psr/http-client-implementation": "^1.0",
Expand All @@ -41,7 +40,7 @@
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-phpunit": "^1.3",
"phpunit/phpunit": "^9.6",
"phpunit/phpunit": "^9.6.11",
"symfony/http-client": "^5.4.45 || ^6.4 || ^7.0",
"symfony/stopwatch": "^5.4 || ^6.4 || ^7.0"
},
Expand Down
1 change: 0 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ parameters:
excludePaths:
- **/vendor/**
treatPhpDocTypesAsCertain: false
checkGenericClassInNonGenericObjectType: false
4 changes: 2 additions & 2 deletions src/Common/Tests/TimedGeocoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function testGeocode(): void
{
$this->delegate->expects($this->once())
->method('geocodeQuery')
->will($this->returnValue(new AddressCollection([])));
->willReturn(new AddressCollection([]));

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion src/Common/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"require-dev": {
"nyholm/nsa": "^1.1",
"phpunit/phpunit": "^9.5",
"phpunit/phpunit": "^9.6.11",
"symfony/stopwatch": "~2.5 || ~5.0 || ~7.0"
},
"suggest": {
Expand Down
2 changes: 1 addition & 1 deletion src/Http/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"nyholm/psr7": "^1.0",
"php-http/message": "^1.0",
"php-http/mock-client": "^1.0",
"phpunit/phpunit": "^9.5",
"phpunit/phpunit": "^9.6.11",
"symfony/stopwatch": "~2.5 || ~5.0"
},
"extra": {
Expand Down
10 changes: 2 additions & 8 deletions src/Plugin/Tests/Plugin/CachePluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ public function testPluginMiss(): void
$ttl = 4711;
$query = GeocodeQuery::create('foo');
$queryString = sha1($query->__toString());
$cache = $this->getMockBuilder(VoidCachePool::class)
->disableOriginalConstructor()
->setMethods(['get', 'set'])
->getMock();
$cache = $this->createPartialMock(VoidCachePool::class, ['get', 'set']);

$cache->expects($this->once())
->method('get')
Expand Down Expand Up @@ -69,10 +66,7 @@ public function getQueryProvider(): \Generator
*/
public function testPluginHit(Query $query, string $key): void
{
$cache = $this->getMockBuilder(VoidCachePool::class)
->disableOriginalConstructor()
->setMethods(['get', 'set'])
->getMock();
$cache = $this->createPartialMock(VoidCachePool::class, ['get', 'set']);

$cache->expects($this->once())
->method('get')
Expand Down
20 changes: 4 additions & 16 deletions src/Plugin/Tests/Plugin/LoggerPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ class LoggerPluginTest extends TestCase
{
public function testPlugin(): void
{
$logger = $this->getMockBuilder(AbstractLogger::class)
->disableOriginalConstructor()
->setMethods(['log'])
->getMock();
$logger = $this->createPartialMock(AbstractLogger::class, ['log']);
$logger->expects($this->once())
->method('log')
->with('info', $this->callback(function ($message) {
Expand All @@ -38,10 +35,7 @@ public function testPlugin(): void
$geocodeQuery = GeocodeQuery::create('foo');
$collection = new AddressCollection([]);

$provider = $this->getMockBuilder(Provider::class)
->disableOriginalConstructor()
->setMethods(['geocodeQuery', 'reverseQuery', 'getName'])
->getMock();
$provider = $this->createPartialMock(Provider::class, ['geocodeQuery', 'reverseQuery', 'getName']);
$provider->expects($this->once())
->method('geocodeQuery')
->with($geocodeQuery)
Expand All @@ -56,21 +50,15 @@ public function testPlugin(): void
public function testPluginException(): void
{
$this->expectException(QuotaExceeded::class);
$logger = $this->getMockBuilder(AbstractLogger::class)
->disableOriginalConstructor()
->setMethods(['log'])
->getMock();
$logger = $this->createPartialMock(AbstractLogger::class, ['log']);
$logger->expects($this->once())
->method('log')
->with('error', $this->callback(function ($message) {
return false !== strstr($message, 'QuotaExceeded');
}));

$geocodeQuery = GeocodeQuery::create('foo');
$provider = $this->getMockBuilder(Provider::class)
->disableOriginalConstructor()
->setMethods(['geocodeQuery', 'reverseQuery', 'getName'])
->getMock();
$provider = $this->createPartialMock(Provider::class, ['geocodeQuery', 'reverseQuery', 'getName']);
$provider->expects($this->once())
->method('geocodeQuery')
->willThrowException(new QuotaExceeded());
Expand Down
40 changes: 8 additions & 32 deletions src/Plugin/Tests/PluginProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ public function testDispatchQueries(): void
$reverseQuery = ReverseQuery::fromCoordinates(47, 11);
$collection = new AddressCollection([]);

$provider = $this->getMockBuilder(Provider::class)
->disableOriginalConstructor()
->setMethods(['geocodeQuery', 'reverseQuery', 'getName'])
->getMock();
$provider = $this->createPartialMock(Provider::class, ['geocodeQuery', 'reverseQuery', 'getName']);
$provider->expects($this->once())
->method('geocodeQuery')
->with($geocodeQuery)
Expand All @@ -54,21 +51,15 @@ public function testPluginsIsBeingUsedWhenGeocoding(): void
$geocodeQuery = GeocodeQuery::create('foo');
$collection = new AddressCollection([]);

$provider = $this->getMockBuilder(Provider::class)
->disableOriginalConstructor()
->setMethods(['geocodeQuery', 'reverseQuery', 'getName'])
->getMock();
$provider = $this->createPartialMock(Provider::class, ['geocodeQuery', 'reverseQuery', 'getName']);
$provider->expects($this->once())
->method('geocodeQuery')
->with($geocodeQuery)
->willReturn($collection);
$provider->expects($this->never())->method('reverseQuery');
$provider->expects($this->never())->method('getName');

$pluginA = $this->getMockBuilder(Plugin::class)
->disableOriginalConstructor()
->setMethods(['handleQuery'])
->getMock();
$pluginA = $this->createPartialMock(Plugin::class, ['handleQuery']);
$pluginA->expects($this->once())
->method('handleQuery')
->with($geocodeQuery, $this->isType('callable'), $this->isType('callable'))
Expand All @@ -85,21 +76,15 @@ public function testPluginsIsBeingUsedWhenReverse(): void
$reverseQuery = ReverseQuery::fromCoordinates(47, 11);
$collection = new AddressCollection([]);

$provider = $this->getMockBuilder(Provider::class)
->disableOriginalConstructor()
->setMethods(['geocodeQuery', 'reverseQuery', 'getName'])
->getMock();
$provider = $this->createPartialMock(Provider::class, ['geocodeQuery', 'reverseQuery', 'getName']);
$provider->expects($this->never())->method('geocodeQuery');
$provider->expects($this->never())->method('getName');
$provider->expects($this->once())
->method('reverseQuery')
->with($reverseQuery)
->willReturn($collection);

$pluginA = $this->getMockBuilder(Plugin::class)
->disableOriginalConstructor()
->setMethods(['handleQuery'])
->getMock();
$pluginA = $this->createPartialMock(Plugin::class, ['handleQuery']);
$pluginA->expects($this->once())
->method('handleQuery')
->with($reverseQuery, $this->isType('callable'), $this->isType('callable'))
Expand All @@ -116,28 +101,19 @@ public function testLoopException(): void
$this->expectException(LoopException::class);
$geocodeQuery = GeocodeQuery::create('foo');

$provider = $this->getMockBuilder(Provider::class)
->disableOriginalConstructor()
->setMethods(['geocodeQuery', 'reverseQuery', 'getName'])
->getMock();
$provider = $this->createPartialMock(Provider::class, ['geocodeQuery', 'reverseQuery', 'getName']);
$provider->expects($this->never())->method('geocodeQuery');
$provider->expects($this->never())->method('reverseQuery');
$provider->expects($this->never())->method('getName');

$pluginA = $this->getMockBuilder(Plugin::class)
->disableOriginalConstructor()
->setMethods(['handleQuery'])
->getMock();
$pluginA = $this->createPartialMock(Plugin::class, ['handleQuery']);
$pluginA->expects($this->any())
->method('handleQuery')
->with($geocodeQuery, $this->isType('callable'), $this->isType('callable'))
->willReturnCallback(function (Query $query, callable $next, callable $first) {
return $next($query);
});
$pluginB = $this->getMockBuilder(Plugin::class)
->disableOriginalConstructor()
->setMethods(['handleQuery'])
->getMock();
$pluginB = $this->createPartialMock(Plugin::class, ['handleQuery']);
$pluginB->expects($this->any())
->method('handleQuery')
->with($geocodeQuery, $this->isType('callable'), $this->isType('callable'))
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"require-dev": {
"cache/void-adapter": "^1.0",
"phpunit/phpunit": "^9.5"
"phpunit/phpunit": "^9.6.11"
},
"extra": {
"branch-alias": {
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/AlgoliaPlaces/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"require-dev": {
"geocoder-php/provider-integration-tests": "^1.6.3",
"php-http/message": "^1.0",
"phpunit/phpunit": "^9.5"
"phpunit/phpunit": "^9.6.11"
},
"extra": {
"branch-alias": {
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/ArcGISOnline/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"require-dev": {
"geocoder-php/provider-integration-tests": "^1.6.3",
"php-http/message": "^1.0",
"phpunit/phpunit": "^9.5"
"phpunit/phpunit": "^9.6.11"
},
"extra": {
"branch-alias": {
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/AzureMaps/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"require-dev": {
"geocoder-php/provider-integration-tests": "^1.6.3",
"php-http/message": "^1.0",
"phpunit/phpunit": "^9.5"
"phpunit/phpunit": "^9.6.11"
},
"extra": {
"branch-alias": {
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/BingMaps/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"require-dev": {
"geocoder-php/provider-integration-tests": "^1.6.3",
"php-http/message": "^1.0",
"phpunit/phpunit": "^9.5"
"phpunit/phpunit": "^9.6.11"
},
"extra": {
"branch-alias": {
Expand Down
9 changes: 2 additions & 7 deletions src/Provider/Cache/Tests/ProviderCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,9 @@ protected function setUp(): void
{
parent::setUp();

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

->getMock();

$this->providerMock = $this->getMockBuilder(Provider::class)
->setMethods(['getFoo', 'getName', 'geocodeQuery', 'reverseQuery'])
->getMock();
$this->providerMock = $this->createPartialMock(Provider::class, ['getName', 'geocodeQuery', 'reverseQuery']);
}

public function testName(): void
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/Cache/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"geocoder-php/provider-implementation": "1.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5"
"phpunit/phpunit": "^9.6.11"
},
"extra": {
"branch-alias": {
Expand Down
12 changes: 6 additions & 6 deletions src/Provider/Chain/Tests/ChainTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ public function testReverse(): void
$mockOne = $this->getMockBuilder(Provider::class)->getMock();
$mockOne->expects($this->once())
->method('reverseQuery')
->will($this->returnCallback(function () {
->willReturnCallback(function () {
throw new \Exception();
}));
});

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

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

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

$mockTwo = $this->getMockBuilder(Provider::class)->getMock();
$result = new AddressCollection(['foo' => 'bar']);
$mockTwo->expects($this->once())
->method('geocodeQuery')
->with($query)
->will($this->returnValue($result));
->willReturn($result);

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

Expand Down
2 changes: 1 addition & 1 deletion src/Provider/Chain/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"nyholm/nsa": "^1.1",
"php-http/curl-client": "^2.2",
"php-http/message": "^1.0",
"phpunit/phpunit": "^9.5"
"phpunit/phpunit": "^9.6.11"
},
"extra": {
"branch-alias": {
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/FreeGeoIp/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"require-dev": {
"geocoder-php/provider-integration-tests": "^1.6.3",
"php-http/message": "^1.0",
"phpunit/phpunit": "^9.5"
"phpunit/phpunit": "^9.6.11"
},
"extra": {
"branch-alias": {
Expand Down
Loading