From da3c09203b79063b44d7c0839eb348667c4c7f3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Beli=C3=ABn?= Date: Mon, 31 Jul 2023 22:07:24 +0200 Subject: [PATCH] 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 --- Tests/MaxMindBinaryTest.php | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/Tests/MaxMindBinaryTest.php b/Tests/MaxMindBinaryTest.php index e5d0c54..af87f76 100644 --- a/Tests/MaxMindBinaryTest.php +++ b/Tests/MaxMindBinaryTest.php @@ -21,14 +21,14 @@ class MaxMindBinaryTest extends BaseTestCase { - private $binaryFile; + private string $binaryFile; public function setUp(): void { $this->binaryFile = __DIR__.'/fixtures/GeoLiteCity.dat'; } - protected function getCacheDir() + protected function getCacheDir(): string { return __DIR__.'/.cached_responses'; } @@ -44,7 +44,10 @@ public static function setUpBeforeClass(): void } } - public static function provideIps() + /** + * @return array + */ + public static function provideIps(): array { return [ '24.24.24.24' => ['24.24.24.24', 'East Syracuse', 'United States'], @@ -52,7 +55,7 @@ public static function provideIps() ]; } - public function testThrowIfNotExistBinaryFileGiven() + public function testThrowIfNotExistBinaryFileGiven(): void { $this->expectException(\Geocoder\Exception\InvalidArgument::class); $this->expectExceptionMessage('Given MaxMind dat file "not_exist.dat" does not exist.'); @@ -60,7 +63,7 @@ public function testThrowIfNotExistBinaryFileGiven() new MaxMindBinary('not_exist.dat'); } - public function testLocationResultContainsExpectedFieldsForAnAmericanIp() + public function testLocationResultContainsExpectedFieldsForAnAmericanIp(): void { $provider = new MaxMindBinary($this->binaryFile); $results = $provider->geocodeQuery(GeocodeQuery::create('24.24.24.24')); @@ -88,7 +91,7 @@ public function testLocationResultContainsExpectedFieldsForAnAmericanIp() $this->assertNull($result->getTimezone()); } - public function testLocationResultContainsExpectedFieldsForASpanishIp() + public function testLocationResultContainsExpectedFieldsForASpanishIp(): void { $provider = new MaxMindBinary($this->binaryFile); $results = $provider->geocodeQuery(GeocodeQuery::create('80.24.24.24')); @@ -119,7 +122,7 @@ public function testLocationResultContainsExpectedFieldsForASpanishIp() /** * @dataProvider provideIps */ - public function testFindLocationByIp($ip, $expectedCity, $expectedCountry) + public function testFindLocationByIp(string $ip, ?string $expectedCity, ?string $expectedCountry): void { $provider = new MaxMindBinary($this->binaryFile); $results = $provider->geocodeQuery(GeocodeQuery::create($ip)); @@ -134,7 +137,7 @@ public function testFindLocationByIp($ip, $expectedCity, $expectedCountry) $this->assertEquals($expectedCountry, $result->getCountry()->getName()); } - public function testShouldReturnResultsAsUtf8Encoded() + public function testShouldReturnResultsAsUtf8Encoded(): void { $provider = new MaxMindBinary($this->binaryFile); $results = $provider->geocodeQuery(GeocodeQuery::create('212.51.181.237')); @@ -145,14 +148,14 @@ public function testShouldReturnResultsAsUtf8Encoded() $this->assertSame('Châlette-sur-loing', $result->getLocality()); } - public function testGetName() + public function testGetName(): void { $provider = new MaxMindBinary($this->binaryFile); $this->assertEquals('maxmind_binary', $provider->getName()); } - public function testThrowIfIpAddressCouldNotBeLocated() + public function testThrowIfIpAddressCouldNotBeLocated(): void { $provider = new MaxMindBinary($this->binaryFile); $result = $provider->geocodeQuery(GeocodeQuery::create('127.0.0.1')); @@ -161,7 +164,7 @@ public function testThrowIfIpAddressCouldNotBeLocated() $this->assertEquals(0, $result->count()); } - public function testThrowIfIpAddressIsNotIpV4() + public function testThrowIfIpAddressIsNotIpV4(): void { $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); $this->expectExceptionMessage('The MaxMindBinary provider does not support IPv6 addresses.'); @@ -171,7 +174,7 @@ public function testThrowIfIpAddressIsNotIpV4() $provider->geocodeQuery(GeocodeQuery::create('2002:5018:1818:0:0:0:0:0')); } - public function testThrowIfInvalidIpAddressGiven() + public function testThrowIfInvalidIpAddressGiven(): void { $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); $this->expectExceptionMessage('The MaxMindBinary provider does not support street addresses.'); @@ -181,7 +184,7 @@ public function testThrowIfInvalidIpAddressGiven() $provider->geocodeQuery(GeocodeQuery::create('invalidIp')); } - public function testThrowOnReverseMethodUsage() + public function testThrowOnReverseMethodUsage(): void { $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); $this->expectExceptionMessage('The MaxMindBinary is not able to do reverse geocoding.');