Skip to content

Commit 32a803f

Browse files
authored
Enable PHPStan Level 6 (#1194)
* Update phpstan.neon * Update YandexTest.php * Update TomTomTest.php * Update PickPointTest.php * Update PickPoint.php * Update PhotonTest.php * Update PeliasTest.php * Update OpenRouteServiceTest.php * Update OpenCageTest.php * Update OpenCage.php * Update NominatimTest.php * Update MaxMindBinaryTest.php * Update MaxMindTest.php * [WIP] Apply PHPStan fixes * Apply PHPCSFixer fixes * [WIP] Apply PHPStan fixes * [WIP] Apply PHPStan fixes * Revert "[WIP] Apply PHPStan fixes" This reverts commit 734c5c52fbcba4bc12cbda07b58d902a79d47891. * [WIP] Apply PHPStan fixes * [WIP] Apply PHPStan fixes * Update phpstan-baseline.neon
1 parent ec2cf27 commit 32a803f

File tree

2 files changed

+46
-19
lines changed

2 files changed

+46
-19
lines changed

MapQuest.php

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,12 @@ public function getName(): string
184184
return 'map_quest';
185185
}
186186

187-
private function extractAddressFromQuery(GeocodeQuery $query)
187+
private function extractAddressFromQuery(GeocodeQuery $query): mixed
188188
{
189189
return $query->getData(static::DATA_KEY_ADDRESS);
190190
}
191191

192-
private function getUrl($endpoint): string
192+
private function getUrl(string $endpoint): string
193193
{
194194
if ($this->licensed) {
195195
$baseUrl = static::LICENSED_BASE_URL;
@@ -200,11 +200,20 @@ private function getUrl($endpoint): string
200200
return $baseUrl.$endpoint;
201201
}
202202

203+
/**
204+
* @param array<string, mixed> $params
205+
*/
203206
private function addGetQuery(string $url, array $params): string
204207
{
205208
return $url.'?'.http_build_query($params, '', '&', PHP_QUERY_RFC3986);
206209
}
207210

211+
/**
212+
* @param array<string, mixed> $params
213+
* @param array<string, mixed> $options
214+
*
215+
* @return array<string, mixed>
216+
*/
208217
private function addOptionsForGetQuery(array $params, array $options): array
209218
{
210219
foreach ($options as $key => $value) {
@@ -219,14 +228,23 @@ private function addOptionsForGetQuery(array $params, array $options): array
219228
return $params;
220229
}
221230

231+
/**
232+
* @param array<string, mixed> $params
233+
* @param array<string, mixed> $options
234+
*
235+
* @return array<string, mixed>
236+
*/
222237
private function addOptionsForPostQuery(array $params, array $options): array
223238
{
224239
$params['options'] = $options;
225240

226241
return $params;
227242
}
228243

229-
private function executePostQuery(string $endpoint, array $params)
244+
/**
245+
* @param array<string, mixed> $params
246+
*/
247+
private function executePostQuery(string $endpoint, array $params): AddressCollection
230248
{
231249
$url = $this->getUrl($endpoint);
232250

@@ -243,6 +261,9 @@ private function executePostQuery(string $endpoint, array $params)
243261
return $this->parseResponseContent($content);
244262
}
245263

264+
/**
265+
* @param array<string, mixed> $params
266+
*/
246267
private function executeGetQuery(string $endpoint, array $params): AddressCollection
247268
{
248269
$baseUrl = $this->getUrl($endpoint);
@@ -314,6 +335,9 @@ private function parseResponseContent(string $content): AddressCollection
314335
return new AddressCollection($results);
315336
}
316337

338+
/**
339+
* @return array<string, mixed>
340+
*/
317341
private function mapAddressToArray(Location $address): array
318342
{
319343
$location = [];
@@ -374,7 +398,10 @@ private function mapAddressToArray(Location $address): array
374398
return $location;
375399
}
376400

377-
private function mapBoundsToArray(Bounds $bounds)
401+
/**
402+
* @return array<string, array<string,float>>
403+
*/
404+
private function mapBoundsToArray(Bounds $bounds): array
378405
{
379406
return [
380407
'ul' => [static::KEY_LAT => $bounds->getNorth(), static::KEY_LNG => $bounds->getWest()],

Tests/MapQuestTest.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@
2727
*/
2828
class MapQuestTest extends BaseTestCase
2929
{
30-
protected function getCacheDir()
30+
protected function getCacheDir(): string
3131
{
3232
return __DIR__.'/.cached_responses';
3333
}
3434

35-
public function testGetName()
35+
public function testGetName(): void
3636
{
3737
$provider = new MapQuest($this->getMockedHttpClient(), 'api_key');
3838
$this->assertEquals('map_quest', $provider->getName());
3939
}
4040

41-
public function testGeocode()
41+
public function testGeocode(): void
4242
{
4343
$provider = new MapQuest($this->getMockedHttpClient('{}'), 'api_key');
4444
$result = $provider->geocodeQuery(GeocodeQuery::create('foobar'));
@@ -47,7 +47,7 @@ public function testGeocode()
4747
$this->assertEquals(0, $result->count());
4848
}
4949

50-
public function testGetNotRelevantData()
50+
public function testGetNotRelevantData(): void
5151
{
5252
$json = '{"results":[{"locations":[{"street":"","postalCode":"","adminArea5":"","adminArea4":"","adminArea3":"","adminArea1":""}]}]}';
5353

@@ -58,7 +58,7 @@ public function testGetNotRelevantData()
5858
$this->assertEquals(0, $result->count());
5959
}
6060

61-
public function testGeocodeWithRealAddress()
61+
public function testGeocodeWithRealAddress(): void
6262
{
6363
if (!isset($_SERVER['MAPQUEST_API_KEY'])) {
6464
$this->markTestSkipped('You need to configure the MAPQUEST_API_KEY value in phpunit.xml');
@@ -108,7 +108,7 @@ public function testGeocodeWithRealAddress()
108108
$this->assertNull($result->getTimezone());
109109
}
110110

111-
public function testGeocodeWithRealSpecificAddress()
111+
public function testGeocodeWithRealSpecificAddress(): void
112112
{
113113
if (!isset($_SERVER['MAPQUEST_API_KEY'])) {
114114
$this->markTestSkipped('You need to configure the MAPQUEST_API_KEY value in phpunit.xml');
@@ -157,7 +157,7 @@ public function testGeocodeWithRealSpecificAddress()
157157
$this->assertNull($result->getTimezone());
158158
}
159159

160-
public function testReverseWithRealCoordinates()
160+
public function testReverseWithRealCoordinates(): void
161161
{
162162
if (!isset($_SERVER['MAPQUEST_API_KEY'])) {
163163
$this->markTestSkipped('You need to configure the MAPQUEST_API_KEY value in phpunit.xml');
@@ -188,7 +188,7 @@ public function testReverseWithRealCoordinates()
188188
$this->assertNull($result->getTimezone());
189189
}
190190

191-
public function testGeocodeWithCity()
191+
public function testGeocodeWithCity(): void
192192
{
193193
if (!isset($_SERVER['MAPQUEST_API_KEY'])) {
194194
$this->markTestSkipped('You need to configure the MAPQUEST_API_KEY value in phpunit.xml');
@@ -262,7 +262,7 @@ public function testGeocodeWithCity()
262262
$this->assertEquals('US', $result->getCountry()->getCode());
263263
}
264264

265-
public function testGeocodeWithSpecificCity()
265+
public function testGeocodeWithSpecificCity(): void
266266
{
267267
if (!isset($_SERVER['MAPQUEST_API_KEY'])) {
268268
$this->markTestSkipped('You need to configure the MAPQUEST_API_KEY value in phpunit.xml');
@@ -344,7 +344,7 @@ public function testGeocodeWithSpecificCity()
344344
$this->assertEquals('US', $result->getCountry()->getCode());
345345
}
346346

347-
public function testGeocodeWithSpecificCityAndBounds()
347+
public function testGeocodeWithSpecificCityAndBounds(): void
348348
{
349349
if (!isset($_SERVER['MAPQUEST_API_KEY'])) {
350350
$this->markTestSkipped('You need to configure the MAPQUEST_API_KEY value in phpunit.xml');
@@ -429,7 +429,7 @@ public function testGeocodeWithSpecificCityAndBounds()
429429
$this->assertEquals('DE', $result->getCountry()->getCode());
430430
}
431431

432-
public function testGeocodeWithCityDistrict()
432+
public function testGeocodeWithCityDistrict(): void
433433
{
434434
if (!isset($_SERVER['MAPQUEST_API_KEY'])) {
435435
$this->markTestSkipped('You need to configure the MAPQUEST_API_KEY value in phpunit.xml');
@@ -461,7 +461,7 @@ public function testGeocodeWithCityDistrict()
461461
$this->assertNull($result->getTimezone());
462462
}
463463

464-
public function testGeocodeWithLocalhostIPv4()
464+
public function testGeocodeWithLocalhostIPv4(): void
465465
{
466466
$this->expectException(\Geocoder\Exception\UnsupportedOperation::class);
467467
$this->expectExceptionMessage('The MapQuest provider does not support IP addresses, only street addresses.');
@@ -470,7 +470,7 @@ public function testGeocodeWithLocalhostIPv4()
470470
$provider->geocodeQuery(GeocodeQuery::create('127.0.0.1'));
471471
}
472472

473-
public function testGeocodeWithLocalhostIPv6()
473+
public function testGeocodeWithLocalhostIPv6(): void
474474
{
475475
$this->expectException(\Geocoder\Exception\UnsupportedOperation::class);
476476
$this->expectExceptionMessage('The MapQuest provider does not support IP addresses, only street addresses.');
@@ -479,7 +479,7 @@ public function testGeocodeWithLocalhostIPv6()
479479
$provider->geocodeQuery(GeocodeQuery::create('::1'));
480480
}
481481

482-
public function testGeocodeWithRealIPv4()
482+
public function testGeocodeWithRealIPv4(): void
483483
{
484484
$this->expectException(\Geocoder\Exception\UnsupportedOperation::class);
485485
$this->expectExceptionMessage('The MapQuest provider does not support IP addresses, only street addresses.');
@@ -488,7 +488,7 @@ public function testGeocodeWithRealIPv4()
488488
$provider->geocodeQuery(GeocodeQuery::create('74.200.247.59'));
489489
}
490490

491-
public function testGeocodeWithRealIPv6()
491+
public function testGeocodeWithRealIPv6(): void
492492
{
493493
$this->expectException(\Geocoder\Exception\UnsupportedOperation::class);
494494
$this->expectExceptionMessage('The MapQuest provider does not support IP addresses, only street addresses.');

0 commit comments

Comments
 (0)