Skip to content

Commit 9298496

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 58f5fc3 commit 9298496

File tree

5 files changed

+28
-20
lines changed

5 files changed

+28
-20
lines changed

Geonames.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function reverseQuery(ReverseQuery $query): Collection
9292
}
9393

9494
/**
95-
* @throws \Geocoder\Exception\Exception
95+
* @return CountryInfo[]
9696
*/
9797
public function getCountryInfo(string $country = null, string $locale = null): array
9898
{

Model/CountryInfo.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ final class CountryInfo
3636
private $capital;
3737

3838
/**
39-
* @var array
39+
* @var string[]
4040
*/
4141
private $languages = [];
4242

@@ -143,6 +143,9 @@ public function withCapital(string $capital = null): self
143143
return $new;
144144
}
145145

146+
/**
147+
* @return string[]
148+
*/
146149
public function getLanguages(): array
147150
{
148151
return $this->languages;

Model/GeonamesAddress.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ final class GeonamesAddress extends Address
4747
private $name;
4848

4949
/**
50-
* @var array
50+
* @var string[]
5151
*/
5252
private $alternateNames = [];
5353

@@ -158,12 +158,17 @@ public function withGeonameId($geonameId)
158158
return $new;
159159
}
160160

161+
/**
162+
* @return string[]
163+
*/
161164
public function getAlternateNames(): array
162165
{
163166
return $this->alternateNames;
164167
}
165168

166169
/**
170+
* @param string[] $alternateNames
171+
*
167172
* @return GeonamesAddress
168173
*/
169174
public function withAlternateNames(array $alternateNames)

Tests/CountryInfoTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818

1919
class CountryInfoTest extends BaseTestCase
2020
{
21-
protected function getCacheDir()
21+
protected function getCacheDir(): string
2222
{
2323
return __DIR__.'/.cached_responses';
2424
}
2525

26-
public function testCountryInfoWithOneCountry()
26+
public function testCountryInfoWithOneCountry(): void
2727
{
2828
if (!isset($_SERVER['GEONAMES_USERNAME'])) {
2929
$this->markTestSkipped('You need to configure the GEONAMES_USERNAME value in phpunit.xml');
@@ -55,7 +55,7 @@ public function testCountryInfoWithOneCountry()
5555
$this->assertEquals('INR', $result->getCurrencyCode());
5656
}
5757

58-
public function testCountryInfoWithMultipleCountries()
58+
public function testCountryInfoWithMultipleCountries(): void
5959
{
6060
if (!isset($_SERVER['GEONAMES_USERNAME'])) {
6161
$this->markTestSkipped('You need to configure the GEONAMES_USERNAME value in phpunit.xml');
@@ -67,7 +67,7 @@ public function testCountryInfoWithMultipleCountries()
6767
$this->assertEquals(2, count($results));
6868
}
6969

70-
public function testCountryInfoWithInvalidCountry()
70+
public function testCountryInfoWithInvalidCountry(): void
7171
{
7272
if (!isset($_SERVER['GEONAMES_USERNAME'])) {
7373
$this->markTestSkipped('You need to configure the GEONAMES_USERNAME value in phpunit.xml');
@@ -79,7 +79,7 @@ public function testCountryInfoWithInvalidCountry()
7979
$this->assertEquals(0, count($results));
8080
}
8181

82-
public function testCountryInfoWithLocale()
82+
public function testCountryInfoWithLocale(): void
8383
{
8484
if (!isset($_SERVER['GEONAMES_USERNAME'])) {
8585
$this->markTestSkipped('You need to configure the GEONAMES_USERNAME value in phpunit.xml');
@@ -94,7 +94,7 @@ public function testCountryInfoWithLocale()
9494
$this->assertEquals('Nuova Delhi', $result->getCapital());
9595
}
9696

97-
public function testCountryInfoWithNoCountry()
97+
public function testCountryInfoWithNoCountry(): void
9898
{
9999
if (!isset($_SERVER['GEONAMES_USERNAME'])) {
100100
$this->markTestSkipped('You need to configure the GEONAMES_USERNAME value in phpunit.xml');

Tests/GeonamesTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@
2222

2323
class GeonamesTest extends BaseTestCase
2424
{
25-
protected function getCacheDir()
25+
protected function getCacheDir(): string
2626
{
2727
return __DIR__.'/.cached_responses';
2828
}
2929

30-
public function testGetName()
30+
public function testGetName(): void
3131
{
3232
$provider = new Geonames($this->getMockedHttpClient(), 'username');
3333
$this->assertEquals('geonames', $provider->getName());
3434
}
3535

36-
public function testGeocodeWithLocalhostIPv4()
36+
public function testGeocodeWithLocalhostIPv4(): void
3737
{
3838
$this->expectException(\Geocoder\Exception\UnsupportedOperation::class);
3939
$this->expectExceptionMessage('The Geonames provider does not support IP addresses.');
@@ -42,7 +42,7 @@ public function testGeocodeWithLocalhostIPv4()
4242
$provider->geocodeQuery(GeocodeQuery::create('127.0.0.1'));
4343
}
4444

45-
public function testGeocodeWithLocalhostIPv6()
45+
public function testGeocodeWithLocalhostIPv6(): void
4646
{
4747
$this->expectException(\Geocoder\Exception\UnsupportedOperation::class);
4848
$this->expectExceptionMessage('The Geonames provider does not support IP addresses.');
@@ -51,7 +51,7 @@ public function testGeocodeWithLocalhostIPv6()
5151
$provider->geocodeQuery(GeocodeQuery::create('::1'));
5252
}
5353

54-
public function testGeocodeWithUnknownCity()
54+
public function testGeocodeWithUnknownCity(): void
5555
{
5656
$noPlacesFoundResponse = <<<'JSON'
5757
{
@@ -66,7 +66,7 @@ public function testGeocodeWithUnknownCity()
6666
$this->assertEquals(0, $result->count());
6767
}
6868

69-
public function testGeocodeWithRealPlace()
69+
public function testGeocodeWithRealPlace(): void
7070
{
7171
if (!isset($_SERVER['GEONAMES_USERNAME'])) {
7272
$this->markTestSkipped('You need to configure the GEONAMES_USERNAME value in phpunit.xml');
@@ -95,7 +95,7 @@ public function testGeocodeWithRealPlace()
9595
$this->assertCount(10, $result->getAlternateNames());
9696
}
9797

98-
public function testGeocodeWithMultipleRealPlaces()
98+
public function testGeocodeWithMultipleRealPlaces(): void
9999
{
100100
if (!isset($_SERVER['GEONAMES_USERNAME'])) {
101101
$this->markTestSkipped('You need to configure the GEONAMES_USERNAME value in phpunit.xml');
@@ -199,7 +199,7 @@ public function testGeocodeWithMultipleRealPlaces()
199199
$this->assertEquals('America/New_York', $result->getTimezone());
200200
}
201201

202-
public function testGeocodeWithMultipleRealPlacesWithLocale()
202+
public function testGeocodeWithMultipleRealPlacesWithLocale(): void
203203
{
204204
if (!isset($_SERVER['GEONAMES_USERNAME'])) {
205205
$this->markTestSkipped('You need to configure the GEONAMES_USERNAME value in phpunit.xml');
@@ -303,7 +303,7 @@ public function testGeocodeWithMultipleRealPlacesWithLocale()
303303
$this->assertEquals('America/New_York', $result->getTimezone());
304304
}
305305

306-
public function testReverseWithRealCoordinates()
306+
public function testReverseWithRealCoordinates(): void
307307
{
308308
if (!isset($_SERVER['GEONAMES_USERNAME'])) {
309309
$this->markTestSkipped('You need to configure the GEONAMES_USERNAME value in phpunit.xml');
@@ -329,7 +329,7 @@ public function testReverseWithRealCoordinates()
329329
$this->assertEquals('Europe/London', $result->getTimezone());
330330
}
331331

332-
public function testReverseWithRealCoordinatesWithLocale()
332+
public function testReverseWithRealCoordinatesWithLocale(): void
333333
{
334334
if (!isset($_SERVER['GEONAMES_USERNAME'])) {
335335
$this->markTestSkipped('You need to configure the GEONAMES_USERNAME value in phpunit.xml');
@@ -355,7 +355,7 @@ public function testReverseWithRealCoordinatesWithLocale()
355355
$this->assertEquals('Europe/London', $result->getTimezone());
356356
}
357357

358-
public function testReverseWithBadCoordinates()
358+
public function testReverseWithBadCoordinates(): void
359359
{
360360
$badCoordinateResponse = <<<'JSON'
361361
{

0 commit comments

Comments
 (0)