Skip to content

Commit

Permalink
Enable PHPStan Level 6 (#1194)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jbelien authored Jul 31, 2023
1 parent 95a479e commit b5e7d31
Showing 1 changed file with 31 additions and 32 deletions.
63 changes: 31 additions & 32 deletions Tests/YandexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

use Geocoder\Collection;
use Geocoder\IntegrationTest\BaseTestCase;
use Geocoder\Location;
use Geocoder\Provider\Yandex\Model\YandexAddress;
use Geocoder\Provider\Yandex\Yandex;
use Geocoder\Query\GeocodeQuery;
Expand All @@ -25,18 +24,18 @@
*/
class YandexTest extends BaseTestCase
{
protected function getCacheDir()
protected function getCacheDir(): string
{
return __DIR__.'/.cached_responses';
}

public function testGetName()
public function testGetName(): void
{
$provider = new Yandex($this->getMockedHttpClient());
$this->assertEquals('yandex', $provider->getName());
}

public function testGeocodeWithLocalhostIPv4()
public function testGeocodeWithLocalhostIPv4(): void
{
$this->expectException(\Geocoder\Exception\UnsupportedOperation::class);
$this->expectExceptionMessage('The Yandex provider does not support IP addresses, only street addresses.');
Expand All @@ -45,7 +44,7 @@ public function testGeocodeWithLocalhostIPv4()
$provider->geocodeQuery(GeocodeQuery::create('127.0.0.1'));
}

public function testGeocodeWithLocalhostIPv6()
public function testGeocodeWithLocalhostIPv6(): void
{
$this->expectException(\Geocoder\Exception\UnsupportedOperation::class);
$this->expectExceptionMessage('The Yandex provider does not support IP addresses, only street addresses.');
Expand All @@ -54,7 +53,7 @@ public function testGeocodeWithLocalhostIPv6()
$provider->geocodeQuery(GeocodeQuery::create('::1'));
}

public function testGeocodeWithEmpty()
public function testGeocodeWithEmpty(): void
{
$provider = new Yandex($this->getMockedHttpClient('{"error":{"status":"400","message":"missing geocode parameter"}}'));
$result = $provider->geocodeQuery(GeocodeQuery::create('xx'));
Expand All @@ -63,7 +62,7 @@ public function testGeocodeWithEmpty()
$this->assertEquals(0, $result->count());
}

public function testGeocodeWithFakeAddress()
public function testGeocodeWithFakeAddress(): void
{
$provider = new Yandex($this->getHttpClient());
$result = $provider->geocodeQuery(GeocodeQuery::create('foobar'));
Expand All @@ -72,15 +71,15 @@ public function testGeocodeWithFakeAddress()
$this->assertEquals(0, $result->count());
}

public function testGeocodeWithRealAddress()
public function testGeocodeWithRealAddress(): void
{
$provider = new Yandex($this->getHttpClient());
$results = $provider->geocodeQuery(GeocodeQuery::create('10 avenue Gambetta, Paris, France'));

$this->assertInstanceOf('Geocoder\Model\AddressCollection', $results);
$this->assertCount(1, $results);

/** @var Location $result */
/** @var YandexAddress $result */
$result = $results->first();
$this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result);
$this->assertEqualsWithDelta(48.863277, $result->getCoordinates()->getLatitude(), 0.01);
Expand All @@ -107,15 +106,15 @@ public function testGeocodeWithRealAddress()
$this->assertNull($result->getTimezone());
}

public function testGeocodeWithRealAddressWithUALocale()
public function testGeocodeWithRealAddressWithUALocale(): void
{
$provider = new Yandex($this->getHttpClient());
$results = $provider->geocodeQuery(GeocodeQuery::create('Copenhagen, Denmark')->withLocale('uk-UA'));

$this->assertInstanceOf('Geocoder\Model\AddressCollection', $results);
$this->assertCount(3, $results);

/** @var Location $result */
/** @var YandexAddress $result */
$result = $results->first();
$this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result);
$this->assertEqualsWithDelta(55.675676, $result->getCoordinates()->getLatitude(), 0.01);
Expand All @@ -142,28 +141,28 @@ public function testGeocodeWithRealAddressWithUALocale()
$this->assertNull($result->getAdminLevels()->get(1)->getCode());
$this->assertNull($result->getTimezone());

/** @var Location $result */
/** @var YandexAddress $result */
$result = $results->get(1);
$this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result);
$this->assertEqualsWithDelta(55.716853, $result->getCoordinates()->getLatitude(), 0.01);
$this->assertEqualsWithDelta(12.463837, $result->getCoordinates()->getLongitude(), 0.01);

/** @var Location $result */
/** @var YandexAddress $result */
$result = $results->get(2);
$this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result);
$this->assertEqualsWithDelta(55.590338, $result->getCoordinates()->getLatitude(), 0.01);
$this->assertEqualsWithDelta(12.130041, $result->getCoordinates()->getLongitude(), 0.01);
}

public function testGeocodeWithRealAddressWithUSLocale()
public function testGeocodeWithRealAddressWithUSLocale(): void
{
$provider = new Yandex($this->getHttpClient());
$results = $provider->geocodeQuery(GeocodeQuery::create('1600 Pennsylvania Ave, Washington')->withLocale('en-US'));

$this->assertInstanceOf('Geocoder\Model\AddressCollection', $results);
$this->assertCount(5, $results);

/** @var Location $result */
/** @var YandexAddress $result */
$result = $results->first();
$this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result);
$this->assertEqualsWithDelta(38.897695, $result->getCoordinates()->getLatitude(), 0.01);
Expand All @@ -190,15 +189,15 @@ public function testGeocodeWithRealAddressWithUSLocale()
$this->assertNull($result->getTimezone());
}

public function testGeocodeWithRealAddressWithBYLocale()
public function testGeocodeWithRealAddressWithBYLocale(): void
{
$provider = new Yandex($this->getHttpClient());
$results = $provider->geocodeQuery(GeocodeQuery::create('ул.Ленина, 19, Минск 220030, Республика Беларусь')->withLocale('be-BY'));

$this->assertInstanceOf('Geocoder\Model\AddressCollection', $results);
$this->assertCount(1, $results);

/** @var Location $result */
/** @var YandexAddress $result */
$result = $results->first();
$this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result);
$this->assertEqualsWithDelta(53.898077, $result->getCoordinates()->getLatitude(), 0.01);
Expand All @@ -224,15 +223,15 @@ public function testGeocodeWithRealAddressWithBYLocale()
$this->assertNull($result->getTimezone());
}

public function testReverseWithRealCoordinates()
public function testReverseWithRealCoordinates(): void
{
$provider = new Yandex($this->getHttpClient());
$results = $provider->reverseQuery(ReverseQuery::fromCoordinates(48.863216489553, 2.388771995902061));

$this->assertInstanceOf('Geocoder\Model\AddressCollection', $results);
$this->assertCount(5, $results);

/** @var Location $result */
/** @var YandexAddress $result */
$result = $results->first();
$this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result);
$this->assertEqualsWithDelta(48.863212, $result->getCoordinates()->getLatitude(), 0.01);
Expand All @@ -259,28 +258,28 @@ public function testReverseWithRealCoordinates()
$this->assertNull($result->getAdminLevels()->get(1)->getCode());
$this->assertNull($result->getTimezone());

/** @var Location $result */
/** @var YandexAddress $result */
$result = $results->get(1);
$this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result);
$this->assertEqualsWithDelta(48.864848, $result->getCoordinates()->getLatitude(), 0.01);
$this->assertEqualsWithDelta(2.3993549, $result->getCoordinates()->getLongitude(), 0.01);

/** @var Location $result */
/** @var YandexAddress $result */
$result = $results->get(2);
$this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result);
$this->assertEqualsWithDelta(48.856929, $result->getCoordinates()->getLatitude(), 0.01);
$this->assertEqualsWithDelta(2.392115, $result->getCoordinates()->getLongitude(), 0.01);
}

public function testReverseWithRealCoordinatesWithUSLocaleAndStreeToponym()
public function testReverseWithRealCoordinatesWithUSLocaleAndStreeToponym(): void
{
$provider = new Yandex($this->getHttpClient(), 'street');
$results = $provider->reverseQuery(ReverseQuery::fromCoordinates(48.863216489553, 2.388771995902061)->withLocale('en-US'));

$this->assertInstanceOf('Geocoder\Model\AddressCollection', $results);
$this->assertCount(5, $results);

/** @var Location $result */
/** @var YandexAddress $result */
$result = $results->first();
$this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result);
$this->assertEqualsWithDelta(48.87132, $result->getCoordinates()->getLatitude(), 0.01);
Expand All @@ -307,40 +306,40 @@ public function testReverseWithRealCoordinatesWithUSLocaleAndStreeToponym()
$this->assertNull($result->getAdminLevels()->get(1)->getCode());
$this->assertNull($result->getTimezone());

/** @var Location $result */
/** @var YandexAddress $result */
$result = $results->get(1);
$this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result);
$this->assertEqualsWithDelta(48.863230, $result->getCoordinates()->getLatitude(), 0.01);
$this->assertEqualsWithDelta(2.388261, $result->getCoordinates()->getLongitude(), 0.01);

/** @var Location $result */
/** @var YandexAddress $result */
$result = $results->get(2);
$this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result);
$this->assertEqualsWithDelta(48.866022, $result->getCoordinates()->getLatitude(), 0.01);
$this->assertEqualsWithDelta(2.389662, $result->getCoordinates()->getLongitude(), 0.01);

/** @var Location $result */
/** @var YandexAddress $result */
$result = $results->get(3);
$this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result);
$this->assertEqualsWithDelta(48.863918, $result->getCoordinates()->getLatitude(), 0.01);
$this->assertEqualsWithDelta(2.387767, $result->getCoordinates()->getLongitude(), 0.01);

/** @var Location $result */
/** @var YandexAddress $result */
$result = $results->get(4);
$this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result);
$this->assertEqualsWithDelta(48.863787, $result->getCoordinates()->getLatitude(), 0.01);
$this->assertEqualsWithDelta(2.389600, $result->getCoordinates()->getLongitude(), 0.01);
}

public function testReverseWithRealCoordinatesWithUALocaleAndHouseToponym()
public function testReverseWithRealCoordinatesWithUALocaleAndHouseToponym(): void
{
$provider = new Yandex($this->getHttpClient(), 'house');
$results = $provider->reverseQuery(ReverseQuery::fromCoordinates(60.4539471768582, 22.2567842183875)->withLocale('uk-UA'));

$this->assertInstanceOf('Geocoder\Model\AddressCollection', $results);
$this->assertCount(5, $results);

/** @var Location $result */
/** @var YandexAddress $result */
$result = $results->first();
$this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result);
$this->assertEqualsWithDelta(60.454462, $result->getCoordinates()->getLatitude(), 0.01);
Expand All @@ -367,15 +366,15 @@ public function testReverseWithRealCoordinatesWithUALocaleAndHouseToponym()
$this->assertNull($result->getTimezone());
}

public function testReverseWithRealCoordinatesWithTRLocaleAndLocalityToponym()
public function testReverseWithRealCoordinatesWithTRLocaleAndLocalityToponym(): void
{
$provider = new Yandex($this->getHttpClient(), 'locality');
$results = $provider->reverseQuery(ReverseQuery::fromCoordinates(40.900640, 29.198184)->withLocale('tr-TR'));

$this->assertInstanceOf('Geocoder\Model\AddressCollection', $results);
$this->assertCount(5, $results);

/** @var Location $result */
/** @var YandexAddress $result */
$result = $results->first();
$this->assertInstanceOf('Geocoder\Provider\Yandex\Model\YandexAddress', $result);
$this->assertEqualsWithDelta(41.01117, $result->getCoordinates()->getLatitude(), 0.01);
Expand Down Expand Up @@ -403,7 +402,7 @@ public function testReverseWithRealCoordinatesWithTRLocaleAndLocalityToponym()
$this->assertNull($result->getTimezone());
}

public function testReverseMetroStationToGetName()
public function testReverseMetroStationToGetName(): void
{
$provider = new Yandex($this->getHttpClient(), 'metro');
$results = $provider->reverseQuery(ReverseQuery::fromCoordinates(60.036843, 30.324285));
Expand Down

0 comments on commit b5e7d31

Please sign in to comment.