diff --git a/GoogleMaps.php b/GoogleMaps.php index 2027745..0aa75ed 100644 --- a/GoogleMaps.php +++ b/GoogleMaps.php @@ -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); @@ -160,7 +160,7 @@ public function getName(): string /** * @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'); @@ -197,7 +197,7 @@ private function buildQuery(string $url, string $locale = null, string $region = * @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, ?string $region = null): AddressCollection { $url = $this->buildQuery($url, $locale, $region); $content = $this->getUrlContents($url); diff --git a/Model/GoogleAddress.php b/Model/GoogleAddress.php index fbd96c9..af648c4 100644 --- a/Model/GoogleAddress.php +++ b/Model/GoogleAddress.php @@ -124,7 +124,7 @@ final class GoogleAddress extends Address /** * @return GoogleAddress */ - public function withId(string $id = null) + public function withId(?string $id = null) { $new = clone $this; $new->id = $id; @@ -145,7 +145,7 @@ public function getId() /** * @return GoogleAddress */ - public function withLocationType(string $locationType = null) + public function withLocationType(?string $locationType = null) { $new = clone $this; $new->locationType = $locationType; @@ -193,7 +193,7 @@ public function getFormattedAddress() /** * @return GoogleAddress */ - public function withFormattedAddress(string $formattedAddress = null) + public function withFormattedAddress(?string $formattedAddress = null) { $new = clone $this; $new->formattedAddress = $formattedAddress; @@ -212,7 +212,7 @@ public function getAirport() /** * @return GoogleAddress */ - public function withAirport(string $airport = null) + public function withAirport(?string $airport = null) { $new = clone $this; $new->airport = $airport; @@ -231,7 +231,7 @@ public function getColloquialArea() /** * @return GoogleAddress */ - public function withColloquialArea(string $colloquialArea = null) + public function withColloquialArea(?string $colloquialArea = null) { $new = clone $this; $new->colloquialArea = $colloquialArea; @@ -250,7 +250,7 @@ public function getIntersection() /** * @return GoogleAddress */ - public function withIntersection(string $intersection = null) + public function withIntersection(?string $intersection = null) { $new = clone $this; $new->intersection = $intersection; @@ -269,7 +269,7 @@ public function getPostalCodeSuffix() /** * @return GoogleAddress */ - public function withPostalCodeSuffix(string $postalCodeSuffix = null) + public function withPostalCodeSuffix(?string $postalCodeSuffix = null) { $new = clone $this; $new->postalCodeSuffix = $postalCodeSuffix; @@ -288,7 +288,7 @@ public function getNaturalFeature() /** * @return GoogleAddress */ - public function withNaturalFeature(string $naturalFeature = null) + public function withNaturalFeature(?string $naturalFeature = null) { $new = clone $this; $new->naturalFeature = $naturalFeature; @@ -307,7 +307,7 @@ public function getNeighborhood() /** * @return GoogleAddress */ - public function withNeighborhood(string $neighborhood = null) + public function withNeighborhood(?string $neighborhood = null) { $new = clone $this; $new->neighborhood = $neighborhood; @@ -326,7 +326,7 @@ public function getPark() /** * @return GoogleAddress */ - public function withPark(string $park = null) + public function withPark(?string $park = null) { $new = clone $this; $new->park = $park; @@ -345,7 +345,7 @@ public function getPointOfInterest() /** * @return GoogleAddress */ - public function withPointOfInterest(string $pointOfInterest = null) + public function withPointOfInterest(?string $pointOfInterest = null) { $new = clone $this; $new->pointOfInterest = $pointOfInterest; @@ -364,7 +364,7 @@ public function getPolitical() /** * @return GoogleAddress */ - public function withPolitical(string $political = null) + public function withPolitical(?string $political = null) { $new = clone $this; $new->political = $political; @@ -383,7 +383,7 @@ public function getPremise() /** * @return GoogleAddress */ - public function withPremise(string $premise = null) + public function withPremise(?string $premise = null) { $new = clone $this; $new->premise = $premise; @@ -402,7 +402,7 @@ public function getStreetAddress() /** * @return GoogleAddress */ - public function withStreetAddress(string $streetAddress = null) + public function withStreetAddress(?string $streetAddress = null) { $new = clone $this; $new->streetAddress = $streetAddress; @@ -421,7 +421,7 @@ public function getSubpremise() /** * @return GoogleAddress */ - public function withSubpremise(string $subpremise = null) + public function withSubpremise(?string $subpremise = null) { $new = clone $this; $new->subpremise = $subpremise; @@ -440,7 +440,7 @@ public function getWard() /** * @return GoogleAddress */ - public function withWard(string $ward = null) + public function withWard(?string $ward = null) { $new = clone $this; $new->ward = $ward; @@ -459,7 +459,7 @@ public function getEstablishment() /** * @return GoogleAddress */ - public function withEstablishment(string $establishment = null) + public function withEstablishment(?string $establishment = null) { $new = clone $this; $new->establishment = $establishment; diff --git a/Tests/GoogleMapsTest.php b/Tests/GoogleMapsTest.php index 6b5ba25..d56d86b 100644 --- a/Tests/GoogleMapsTest.php +++ b/Tests/GoogleMapsTest.php @@ -141,7 +141,7 @@ public function testGeocodeBoundsWithRealAddressForNonRooftopLocation(): void 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));