diff --git a/.github/workflows/provider.yml b/.github/workflows/provider.yml index 6c837b2..590442d 100644 --- a/.github/workflows/provider.yml +++ b/.github/workflows/provider.yml @@ -13,9 +13,9 @@ jobs: strategy: fail-fast: false matrix: - php-version: ['7.4', '8.0', '8.1', '8.2'] + php-version: ['8.0', '8.1', '8.2', '8.3', '8.4'] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Use PHP ${{ matrix.php-version }} uses: shivammathur/setup-php@v2 with: diff --git a/CHANGELOG.md b/CHANGELOG.md index 777814a..b8ef065 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release. +## 4.8.0 + +### Added + +- Add support for PHP Geocoder 5 + ## 4.7.1 ### Fixed diff --git a/GoogleMaps.php b/GoogleMaps.php index e40a6c9..193f83a 100644 --- a/GoogleMaps.php +++ b/GoogleMaps.php @@ -34,12 +34,12 @@ final class GoogleMaps extends AbstractHttpProvider implements Provider /** * @var string */ - const GEOCODE_ENDPOINT_URL_SSL = 'https://maps.googleapis.com/maps/api/geocode/json?address=%s'; + public const GEOCODE_ENDPOINT_URL_SSL = 'https://maps.googleapis.com/maps/api/geocode/json?address=%s'; /** * @var string */ - const REVERSE_ENDPOINT_URL_SSL = 'https://maps.googleapis.com/maps/api/geocode/json?latlng=%F,%F'; + public const REVERSE_ENDPOINT_URL_SSL = 'https://maps.googleapis.com/maps/api/geocode/json?latlng=%F,%F'; /** * @var string|null @@ -83,10 +83,10 @@ final class GoogleMaps extends AbstractHttpProvider implements Provider public static function business( ClientInterface $client, string $clientId, - string $privateKey = null, - string $region = null, - string $apiKey = null, - string $channel = null + ?string $privateKey = null, + ?string $region = null, + ?string $apiKey = null, + ?string $channel = null, ) { $provider = new self($client, $region, $apiKey); $provider->clientId = $clientId; @@ -101,7 +101,7 @@ public static function business( * @param string $region Region biasing (optional) * @param string $apiKey Google Geocoding API key (optional) */ - public function __construct(ClientInterface $client, string $region = null, string $apiKey = null) + public function __construct(ClientInterface $client, ?string $region = null, ?string $apiKey = null) { parent::__construct($client); @@ -152,21 +152,15 @@ public function reverseQuery(ReverseQuery $query): Collection return $this->fetchUrl($url, $query->getLocale(), $query->getLimit(), $query->getData('region', $this->region)); } - /** - * {@inheritdoc} - */ public function getName(): string { return 'google_maps'; } /** - * @param string $url - * @param string $locale - * * @return string query with extra params */ - private function buildQuery(string $url, string $locale = null, string $region = null): string + private function buildQuery(string $url, ?string $locale = null, ?string $region = null): string { if (null === $this->apiKey && null === $this->clientId) { throw new InvalidCredentials('You must provide an API key. Keyless access was removed in June, 2016'); @@ -200,17 +194,10 @@ private function buildQuery(string $url, string $locale = null, string $region = } /** - * @param string $url - * @param string $locale - * @param int $limit - * @param string $region - * - * @return AddressCollection - * * @throws InvalidServerResponse * @throws InvalidCredentials */ - private function fetchUrl(string $url, string $locale = null, int $limit, string $region = null): AddressCollection + private function fetchUrl(string $url, ?string $locale = null, int $limit = 1, ?string $region = null): AddressCollection { $url = $this->buildQuery($url, $locale, $region); $content = $this->getUrlContents($url); @@ -280,11 +267,10 @@ private function fetchUrl(string $url, string $locale = null, int $limit, string /** * Update current resultSet with given key/value. * - * @param AddressBuilder $builder - * @param string $type Component type - * @param object $values The component values + * @param string $type Component type + * @param object $values The component values */ - private function updateAddressComponent(AddressBuilder $builder, string $type, $values) + private function updateAddressComponent(AddressBuilder $builder, string $type, $values): void { switch ($type) { case 'postal_code': @@ -395,9 +381,7 @@ private function signQuery(string $query): string /** * Serialize the component query parameter. * - * @param array $components - * - * @return string + * @param array $components */ private function serializeComponents(array $components): string { @@ -409,7 +393,6 @@ private function serializeComponents(array $components): string /** * Decode the response content and validate it to make sure it does not have any errors. * - * @param string $url * @param string $content * * @return \Stdclass result form json_decode() @@ -451,10 +434,9 @@ private function validateResponse(string $url, $content) /** * Parse coordinates and bounds. * - * @param AddressBuilder $builder - * @param \Stdclass $result + * @param \Stdclass $result */ - private function parseCoordinates(AddressBuilder $builder, $result) + private function parseCoordinates(AddressBuilder $builder, $result): void { $coordinates = $result->geometry->location; $builder->setCoordinates($coordinates->lat, $coordinates->lng); diff --git a/Model/GoogleAddress.php b/Model/GoogleAddress.php index 9579f1d..af648c4 100644 --- a/Model/GoogleAddress.php +++ b/Model/GoogleAddress.php @@ -32,7 +32,7 @@ final class GoogleAddress extends Address private $locationType; /** - * @var array + * @var string[] */ private $resultType = []; @@ -122,11 +122,9 @@ final class GoogleAddress extends Address private $partialMatch; /** - * @param string|null $id - * * @return GoogleAddress */ - public function withId(string $id = null) + public function withId(?string $id = null) { $new = clone $this; $new->id = $id; @@ -145,11 +143,9 @@ public function getId() } /** - * @param string|null $locationType - * * @return GoogleAddress */ - public function withLocationType(string $locationType = null) + public function withLocationType(?string $locationType = null) { $new = clone $this; $new->locationType = $locationType; @@ -166,7 +162,7 @@ public function getLocationType() } /** - * @return array + * @return string[] */ public function getResultType(): array { @@ -174,7 +170,7 @@ public function getResultType(): array } /** - * @param array $resultType + * @param string[] $resultType * * @return GoogleAddress */ @@ -195,11 +191,9 @@ public function getFormattedAddress() } /** - * @param string|null $formattedAddress - * * @return GoogleAddress */ - public function withFormattedAddress(string $formattedAddress = null) + public function withFormattedAddress(?string $formattedAddress = null) { $new = clone $this; $new->formattedAddress = $formattedAddress; @@ -216,11 +210,9 @@ public function getAirport() } /** - * @param string|null $airport - * * @return GoogleAddress */ - public function withAirport(string $airport = null) + public function withAirport(?string $airport = null) { $new = clone $this; $new->airport = $airport; @@ -237,11 +229,9 @@ public function getColloquialArea() } /** - * @param string|null $colloquialArea - * * @return GoogleAddress */ - public function withColloquialArea(string $colloquialArea = null) + public function withColloquialArea(?string $colloquialArea = null) { $new = clone $this; $new->colloquialArea = $colloquialArea; @@ -258,11 +248,9 @@ public function getIntersection() } /** - * @param string|null $intersection - * * @return GoogleAddress */ - public function withIntersection(string $intersection = null) + public function withIntersection(?string $intersection = null) { $new = clone $this; $new->intersection = $intersection; @@ -279,11 +267,9 @@ public function getPostalCodeSuffix() } /** - * @param string|null $postalCodeSuffix - * * @return GoogleAddress */ - public function withPostalCodeSuffix(string $postalCodeSuffix = null) + public function withPostalCodeSuffix(?string $postalCodeSuffix = null) { $new = clone $this; $new->postalCodeSuffix = $postalCodeSuffix; @@ -300,11 +286,9 @@ public function getNaturalFeature() } /** - * @param string|null $naturalFeature - * * @return GoogleAddress */ - public function withNaturalFeature(string $naturalFeature = null) + public function withNaturalFeature(?string $naturalFeature = null) { $new = clone $this; $new->naturalFeature = $naturalFeature; @@ -321,11 +305,9 @@ public function getNeighborhood() } /** - * @param string|null $neighborhood - * * @return GoogleAddress */ - public function withNeighborhood(string $neighborhood = null) + public function withNeighborhood(?string $neighborhood = null) { $new = clone $this; $new->neighborhood = $neighborhood; @@ -342,11 +324,9 @@ public function getPark() } /** - * @param string|null $park - * * @return GoogleAddress */ - public function withPark(string $park = null) + public function withPark(?string $park = null) { $new = clone $this; $new->park = $park; @@ -363,11 +343,9 @@ public function getPointOfInterest() } /** - * @param string|null $pointOfInterest - * * @return GoogleAddress */ - public function withPointOfInterest(string $pointOfInterest = null) + public function withPointOfInterest(?string $pointOfInterest = null) { $new = clone $this; $new->pointOfInterest = $pointOfInterest; @@ -384,11 +362,9 @@ public function getPolitical() } /** - * @param string|null $political - * * @return GoogleAddress */ - public function withPolitical(string $political = null) + public function withPolitical(?string $political = null) { $new = clone $this; $new->political = $political; @@ -405,11 +381,9 @@ public function getPremise() } /** - * @param string $premise - * * @return GoogleAddress */ - public function withPremise(string $premise = null) + public function withPremise(?string $premise = null) { $new = clone $this; $new->premise = $premise; @@ -426,11 +400,9 @@ public function getStreetAddress() } /** - * @param string|null $streetAddress - * * @return GoogleAddress */ - public function withStreetAddress(string $streetAddress = null) + public function withStreetAddress(?string $streetAddress = null) { $new = clone $this; $new->streetAddress = $streetAddress; @@ -447,11 +419,9 @@ public function getSubpremise() } /** - * @param string|null $subpremise - * * @return GoogleAddress */ - public function withSubpremise(string $subpremise = null) + public function withSubpremise(?string $subpremise = null) { $new = clone $this; $new->subpremise = $subpremise; @@ -468,11 +438,9 @@ public function getWard() } /** - * @param string|null $ward - * * @return GoogleAddress */ - public function withWard(string $ward = null) + public function withWard(?string $ward = null) { $new = clone $this; $new->ward = $ward; @@ -489,11 +457,9 @@ public function getEstablishment() } /** - * @param string|null $establishment - * * @return GoogleAddress */ - public function withEstablishment(string $establishment = null) + public function withEstablishment(?string $establishment = null) { $new = clone $this; $new->establishment = $establishment; @@ -510,7 +476,7 @@ public function getSubLocalityLevels() } /** - * @param array $subLocalityLevel + * @param array $subLocalityLevel * * @return $this */ @@ -552,8 +518,6 @@ public function isPartialMatch() } /** - * @param bool $partialMatch - * * @return $this */ public function withPartialMatch(bool $partialMatch) diff --git a/Readme.md b/Readme.md index 8702e98..2eb77df 100644 --- a/Readme.md +++ b/Readme.md @@ -13,7 +13,7 @@ This is the Google Maps provider from the PHP Geocoder. This is a **READ ONLY** ## Usage ```php -$httpClient = new \GuzzleHttp\Client(); +$httpClient = new \Http\Discovery\Psr18Client(); // You must provide an API key $provider = new \Geocoder\Provider\GoogleMaps\GoogleMaps($httpClient, null, 'your-api-key'); @@ -31,7 +31,7 @@ can use the static `business` method on the provider to create a client: ```php -$httpClient = new \GuzzleHttp\Client(); +$httpClient = new \Http\Discovery\Psr18Client(); // Client ID is required. Private key is optional. $provider = \Geocoder\Provider\GoogleMaps\GoogleMaps::business($httpClient, 'your-client-id', 'your-private-key'); diff --git a/Tests/GoogleMapsTest.php b/Tests/GoogleMapsTest.php index 9d62915..1e00b5e 100644 --- a/Tests/GoogleMapsTest.php +++ b/Tests/GoogleMapsTest.php @@ -16,10 +16,10 @@ use Geocoder\IntegrationTest\BaseTestCase; use Geocoder\Model\Address; use Geocoder\Model\AddressCollection; +use Geocoder\Provider\GoogleMaps\GoogleMaps; use Geocoder\Provider\GoogleMaps\Model\GoogleAddress; use Geocoder\Query\GeocodeQuery; use Geocoder\Query\ReverseQuery; -use Geocoder\Provider\GoogleMaps\GoogleMaps; use Psr\Http\Message\RequestInterface; class GoogleMapsTest extends BaseTestCase @@ -29,7 +29,7 @@ class GoogleMapsTest extends BaseTestCase */ private $testAPIKey = 'fake_key'; - protected function getCacheDir() + protected function getCacheDir(): ?string { if (isset($_SERVER['USE_CACHED_RESPONSES']) && true === $_SERVER['USE_CACHED_RESPONSES']) { return __DIR__.'/.cached_responses'; @@ -38,13 +38,13 @@ protected function getCacheDir() return null; } - public function testGetName() + public function testGetName(): void { $provider = new GoogleMaps($this->getMockedHttpClient(), null, 'mock-api-key'); $this->assertEquals('google_maps', $provider->getName()); } - public function testGeocodeWithLocalhostIPv4() + public function testGeocodeWithLocalhostIPv4(): void { $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); $this->expectExceptionMessage('The GoogleMaps provider does not support IP addresses, only street addresses.'); @@ -53,7 +53,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 GoogleMaps provider does not support IP addresses, only street addresses.'); @@ -62,7 +62,7 @@ public function testGeocodeWithLocalhostIPv6() $provider->geocodeQuery(GeocodeQuery::create('::1')); } - public function testGeocodeWithRealIp() + public function testGeocodeWithRealIp(): void { $this->expectException(\Geocoder\Exception\UnsupportedOperation::class); $this->expectExceptionMessage('The GoogleMaps provider does not support IP addresses, only street addresses.'); @@ -71,7 +71,7 @@ public function testGeocodeWithRealIp() $provider->geocodeQuery(GeocodeQuery::create('74.200.247.59')); } - public function testGeocodeWithQuotaExceeded() + public function testGeocodeWithQuotaExceeded(): void { $this->expectException(\Geocoder\Exception\QuotaExceeded::class); $this->expectExceptionMessage('Daily quota exceeded https://maps.googleapis.com/maps/api/geocode/json?address=10%20avenue%20Gambetta%2C%20Paris%2C%20France'); @@ -80,7 +80,7 @@ public function testGeocodeWithQuotaExceeded() $provider->geocodeQuery(GeocodeQuery::create('10 avenue Gambetta, Paris, France')); } - public function testGeocodeWithRealAddress() + public function testGeocodeWithRealAddress(): void { if (!isset($_SERVER['GOOGLE_GEOCODING_KEY'])) { $this->markTestSkipped('You need to configure the GOOGLE_GEOCODING_KEY value in phpunit.xml'); @@ -119,7 +119,7 @@ public function testGeocodeWithRealAddress() $this->assertNull($result->getPostalCodeSuffix()); } - public function testGeocodeBoundsWithRealAddressForNonRooftopLocation() + public function testGeocodeBoundsWithRealAddressForNonRooftopLocation(): void { $provider = $this->getGoogleMapsProvider(); $results = $provider->geocodeQuery(GeocodeQuery::create('Paris, France')); @@ -139,15 +139,15 @@ public function testGeocodeBoundsWithRealAddressForNonRooftopLocation() $this->assertEquals(false, $result->isPartialMatch()); } - public function testReverse() + public function testReverse(): void { - $this->expectException(\Geocoder\Exception\InvalidServerResponse::class); + $this->expectException(InvalidServerResponse::class); $provider = new GoogleMaps($this->getMockedHttpClient(), null, 'mock-api-key'); $provider->reverseQuery(ReverseQuery::fromCoordinates(1, 2)); } - public function testReverseWithRealCoordinates() + public function testReverseWithRealCoordinates(): void { $provider = $this->getGoogleMapsProvider(); $results = $provider->reverseQuery(ReverseQuery::fromCoordinates(48.8631507, 2.388911)); @@ -171,7 +171,7 @@ public function testReverseWithRealCoordinates() $this->assertEquals(false, $result->isPartialMatch()); } - public function testReverseWithRealCoordinatesAndLocale() + public function testReverseWithRealCoordinatesAndLocale(): void { $provider = $this->getGoogleMapsProvider(); $results = $provider->reverseQuery(ReverseQuery::fromCoordinates(48.8631507, 2.388911)->withLocale('fr-FR')); @@ -195,7 +195,7 @@ public function testReverseWithRealCoordinatesAndLocale() $this->assertEquals(false, $result->isPartialMatch()); } - public function testGeocodeWithCityDistrict() + public function testGeocodeWithCityDistrict(): void { $provider = $this->getGoogleMapsProvider(); $results = $provider->geocodeQuery(GeocodeQuery::create('Kalbacher Hauptstraße 10, 60437 Frankfurt, Germany')); @@ -210,7 +210,7 @@ public function testGeocodeWithCityDistrict() $this->assertEquals(false, $result->isPartialMatch()); } - public function testGeocodeWithInvalidApiKey() + public function testGeocodeWithInvalidApiKey(): void { $this->expectException(\Geocoder\Exception\InvalidCredentials::class); $this->expectExceptionMessage('API key is invalid https://maps.googleapis.com/maps/api/geocode/json?address=10%20avenue%20Gambetta%2C%20Paris%2C%20France'); @@ -219,7 +219,7 @@ public function testGeocodeWithInvalidApiKey() $provider->geocodeQuery(GeocodeQuery::create('10 avenue Gambetta, Paris, France')); } - public function testGeocodeWithRealValidApiKey() + public function testGeocodeWithRealValidApiKey(): void { $provider = $this->getGoogleMapsProvider(); $results = $provider->geocodeQuery(GeocodeQuery::create('Columbia University')); @@ -237,7 +237,7 @@ public function testGeocodeWithRealValidApiKey() $this->assertEquals(false, $result->isPartialMatch()); } - public function testGeocodeWithComponentFiltering() + public function testGeocodeWithComponentFiltering(): void { $provider = $this->getGoogleMapsProvider(); $query = GeocodeQuery::create('Sankt Petri')->withData('components', [ @@ -259,7 +259,7 @@ public function testGeocodeWithComponentFiltering() $this->assertEquals(false, $result->isPartialMatch()); } - public function testCorrectlySerializesComponents() + public function testCorrectlySerializesComponents(): void { $uri = ''; @@ -292,7 +292,7 @@ function (RequestInterface $request) use (&$uri) { ); } - public function testCorrectlySetsComponents() + public function testCorrectlySetsComponents(): void { $uri = ''; @@ -322,7 +322,7 @@ function (RequestInterface $request) use (&$uri) { ); } - public function testGeocodeWithRealInvalidApiKey() + public function testGeocodeWithRealInvalidApiKey(): void { $this->expectException(\Geocoder\Exception\InvalidCredentials::class); $this->expectExceptionMessage('API key is invalid https://maps.googleapis.com/maps/api/geocode/json?address=Columbia&key=fake_key'); @@ -331,7 +331,7 @@ public function testGeocodeWithRealInvalidApiKey() $provider->geocodeQuery(GeocodeQuery::create('Columbia')); } - public function testGeocodePostalTown() + public function testGeocodePostalTown(): void { $provider = $this->getGoogleMapsProvider(); $results = $provider->geocodeQuery(GeocodeQuery::create('CF37, United Kingdom')); @@ -346,7 +346,7 @@ public function testGeocodePostalTown() $this->assertEquals(false, $result->isPartialMatch()); } - public function testBusinessQueryWithoutPrivateKey() + public function testBusinessQueryWithoutPrivateKey(): void { $uri = ''; @@ -366,7 +366,7 @@ function (RequestInterface $request) use (&$uri) { $this->assertEquals('https://maps.googleapis.com/maps/api/geocode/json?address=blah&client=foo', $uri); } - public function testBusinessQueryWithPrivateKey() + public function testBusinessQueryWithPrivateKey(): void { $uri = ''; @@ -390,7 +390,7 @@ function (RequestInterface $request) use (&$uri) { ); } - public function testBusinessQueryWithPrivateKeyAndChannel() + public function testBusinessQueryWithPrivateKeyAndChannel(): void { $uri = ''; @@ -417,7 +417,7 @@ function (RequestInterface $request) use (&$uri) { ); } - public function testGeocodeWithInvalidClientIdAndKey() + public function testGeocodeWithInvalidClientIdAndKey(): void { $this->expectException(\Geocoder\Exception\InvalidCredentials::class); @@ -425,7 +425,7 @@ public function testGeocodeWithInvalidClientIdAndKey() $provider->geocodeQuery(GeocodeQuery::create('Columbia University')); } - public function testGeocodeWithInvalidClientIdAndKeyNoSsl() + public function testGeocodeWithInvalidClientIdAndKeyNoSsl(): void { $this->expectException(\Geocoder\Exception\InvalidCredentials::class); @@ -433,7 +433,7 @@ public function testGeocodeWithInvalidClientIdAndKeyNoSsl() $provider->geocodeQuery(GeocodeQuery::create('Columbia University')); } - public function testGeocodeWithSupremise() + public function testGeocodeWithSupremise(): void { $provider = $this->getGoogleMapsProvider(); $results = $provider->geocodeQuery(GeocodeQuery::create('2123 W Mineral Ave Apt 61,Littleton,CO8 0120')); @@ -448,7 +448,7 @@ public function testGeocodeWithSupremise() $this->assertEquals(true, $result->isPartialMatch()); // 2123 W Mineral Ave #61, Littleton, CO 80120, USA } - public function testGeocodeWithNaturalFeatureComponent() + public function testGeocodeWithNaturalFeatureComponent(): void { $provider = $this->getGoogleMapsProvider(); $results = $provider->geocodeQuery(GeocodeQuery::create('Durmitor Nacionalni Park')); @@ -467,7 +467,7 @@ public function testGeocodeWithNaturalFeatureComponent() $this->assertEquals(false, $result->isPartialMatch()); } - public function testGeocodeWithAirportComponent() + public function testGeocodeWithAirportComponent(): void { $provider = $this->getGoogleMapsProvider(); $results = $provider->geocodeQuery(GeocodeQuery::create('Brisbane Airport')); @@ -484,7 +484,7 @@ public function testGeocodeWithAirportComponent() $this->assertEquals(false, $result->isPartialMatch()); } - public function testGeocodeWithPremiseComponent() + public function testGeocodeWithPremiseComponent(): void { $provider = $this->getGoogleMapsProvider(); $results = $provider->geocodeQuery(GeocodeQuery::create('1125 17th St, Denver, CO 80202')); @@ -502,7 +502,7 @@ public function testGeocodeWithPremiseComponent() $this->assertEquals(false, $result->isPartialMatch()); } - public function testGeocodeWithColloquialAreaComponent() + public function testGeocodeWithColloquialAreaComponent(): void { $provider = $this->getGoogleMapsProvider(); $results = $provider->geocodeQuery(GeocodeQuery::create('darwin')); @@ -517,7 +517,7 @@ public function testGeocodeWithColloquialAreaComponent() $this->assertEquals(false, $result->isPartialMatch()); } - public function testReverseWithSubLocalityLevels() + public function testReverseWithSubLocalityLevels(): void { $provider = $this->getGoogleMapsProvider(); $results = $provider->reverseQuery(ReverseQuery::fromCoordinates(36.2745084, 136.9003169)); @@ -528,12 +528,12 @@ public function testReverseWithSubLocalityLevels() /** @var GoogleAddress $result */ $result = $results->first(); $this->assertInstanceOf(Address::class, $result); - $this->assertInstanceOf('\Geocoder\Model\AdminLevelCollection', $result->getSubLocalityLevels()); + $this->assertInstanceOf(\Geocoder\Model\AdminLevelCollection::class, $result->getSubLocalityLevels()); $this->assertEquals('Iijima', $result->getSubLocalityLevels()->get(2)->getName()); $this->assertEquals(false, $result->isPartialMatch()); } - public function testGeocodeWithPostalCodeSuffixComponent() + public function testGeocodeWithPostalCodeSuffixComponent(): void { $provider = $this->getGoogleMapsProvider(); $results = $provider->geocodeQuery(GeocodeQuery::create('900 S Oak Park Ave, Oak Park, IL 60304')); @@ -549,7 +549,7 @@ public function testGeocodeWithPostalCodeSuffixComponent() $this->assertEquals(false, $result->isPartialMatch()); } - public function testGeocodeBoundsWithRealAddressWithViewportOnly() + public function testGeocodeBoundsWithRealAddressWithViewportOnly(): void { $provider = $this->getGoogleMapsProvider(); $results = $provider->geocodeQuery(GeocodeQuery::create('Sibbe, Netherlands')); @@ -568,7 +568,7 @@ public function testGeocodeBoundsWithRealAddressWithViewportOnly() $this->assertEquals(false, $result->isPartialMatch()); } - public function testGeocodeDuplicateSubLocalityLevel() + public function testGeocodeDuplicateSubLocalityLevel(): void { $provider = $this->getGoogleMapsProvider(); $results = $provider->geocodeQuery(GeocodeQuery::create('Rue de Pont-A-Migneloux, 6210 Wayaux, Belgique')); @@ -584,7 +584,7 @@ public function testGeocodeDuplicateSubLocalityLevel() $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Région Wallonne', $result->getAdminLevels()->get(1)->getName()); $this->assertEquals('Hainaut', $result->getAdminLevels()->get(2)->getName()); - $this->assertInstanceOf('\Geocoder\Model\AdminLevelCollection', $result->getSubLocalityLevels()); + $this->assertInstanceOf(\Geocoder\Model\AdminLevelCollection::class, $result->getSubLocalityLevels()); $this->assertEquals(1, $result->getSubLocalityLevels()->get(1)->getLevel()); $this->assertEquals('Wayaux / Les Bons Villers', $result->getSubLocalityLevels()->get(1)->getName()); $this->assertEquals('Wayaux / Les Bons Villers', $result->getSubLocalityLevels()->get(1)->getCode()); diff --git a/Tests/IntegrationTest.php b/Tests/IntegrationTest.php index 080949e..34fef81 100644 --- a/Tests/IntegrationTest.php +++ b/Tests/IntegrationTest.php @@ -21,21 +21,21 @@ */ class IntegrationTest extends ProviderIntegrationTest { - protected $testIpv4 = false; + protected bool $testIpv4 = false; - protected $testIpv6 = false; + protected bool $testIpv6 = false; protected function createProvider(ClientInterface $httpClient) { return new GoogleMaps($httpClient, null, $_SERVER['GOOGLE_GEOCODING_KEY']); } - protected function getCacheDir() + protected function getCacheDir(): string { return __DIR__.'/.cached_responses'; } - protected function getApiKey() + protected function getApiKey(): string { return $_SERVER['GOOGLE_GEOCODING_KEY']; } diff --git a/composer.json b/composer.json index f631cf9..a306f10 100644 --- a/composer.json +++ b/composer.json @@ -12,18 +12,17 @@ } ], "require": { - "php": "^7.4 || ^8.0", + "php": "^8.0", "geocoder-php/common-http": "^4.0", - "willdurand/geocoder": "^4.0" + "willdurand/geocoder": "^4.0|^5.0" }, "provide": { "geocoder-php/provider-implementation": "1.0" }, "require-dev": { - "geocoder-php/provider-integration-tests": "^1.0", - "php-http/curl-client": "^2.2", + "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": { @@ -44,4 +43,4 @@ "test": "vendor/bin/phpunit", "test-ci": "vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml" } -} \ No newline at end of file +}