Skip to content

Commit 2d749c5

Browse files
authored
🚨 Apply PHP CS Fixer fixes (#1219)
1 parent 6eef6d3 commit 2d749c5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+134
-134
lines changed

src/Common/Collection.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function isEmpty(): bool;
3535
/**
3636
* @return Location[]
3737
*/
38-
public function slice(int $offset, int $length = null);
38+
public function slice(int $offset, ?int $length = null);
3939

4040
public function has(int $index): bool;
4141

src/Common/Geocoder.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ interface Geocoder extends Provider
3434
/**
3535
* Geocodes a given value.
3636
*
37-
* @throws \Geocoder\Exception\Exception
37+
* @throws Exception\Exception
3838
*/
3939
public function geocode(string $value): Collection;
4040

4141
/**
4242
* Reverses geocode given latitude and longitude values.
4343
*
44-
* @throws \Geocoder\Exception\Exception
44+
* @throws Exception\Exception
4545
*/
4646
public function reverse(float $latitude, float $longitude): Collection;
4747
}

src/Common/Model/Address.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,15 @@ class Address implements Location
7777
final public function __construct(
7878
string $providedBy,
7979
AdminLevelCollection $adminLevels,
80-
Coordinates $coordinates = null,
81-
Bounds $bounds = null,
82-
string $streetNumber = null,
83-
string $streetName = null,
84-
string $postalCode = null,
85-
string $locality = null,
86-
string $subLocality = null,
87-
Country $country = null,
88-
string $timezone = null
80+
?Coordinates $coordinates = null,
81+
?Bounds $bounds = null,
82+
?string $streetNumber = null,
83+
?string $streetName = null,
84+
?string $postalCode = null,
85+
?string $locality = null,
86+
?string $subLocality = null,
87+
?Country $country = null,
88+
?string $timezone = null
8989
) {
9090
$this->providedBy = $providedBy;
9191
$this->adminLevels = $adminLevels;

src/Common/Model/AddressBuilder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public function setCoordinates($latitude, $longitude): self
152152
return $this;
153153
}
154154

155-
public function addAdminLevel(int $level, string $name, string $code = null): self
155+
public function addAdminLevel(int $level, string $name, ?string $code = null): self
156156
{
157157
$this->adminLevels[] = new AdminLevel($level, $name, $code);
158158

src/Common/Model/AddressCollection.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function isEmpty(): bool
5959
/**
6060
* @return Location[]
6161
*/
62-
public function slice(int $offset, int $length = null)
62+
public function slice(int $offset, ?int $length = null)
6363
{
6464
return array_slice($this->locations, $offset, $length);
6565
}

src/Common/Model/AdminLevel.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ final class AdminLevel
3232
*/
3333
private $code;
3434

35-
public function __construct(int $level, string $name, string $code = null)
35+
public function __construct(int $level, string $name, ?string $code = null)
3636
{
3737
$this->level = $level;
3838
$this->name = $name;

src/Common/Model/AdminLevelCollection.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function first(): AdminLevel
7777
/**
7878
* @return AdminLevel[]
7979
*/
80-
public function slice(int $offset, int $length = null): array
80+
public function slice(int $offset, ?int $length = null): array
8181
{
8282
return array_slice($this->adminLevels, $offset, $length, true);
8383
}

src/Common/Model/Country.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ final class Country
3131
*/
3232
private $code;
3333

34-
public function __construct(string $name = null, string $code = null)
34+
public function __construct(?string $name = null, ?string $code = null)
3535
{
3636
if (null === $name && null === $code) {
3737
throw new InvalidArgument('A country must have either a name or a code');

src/Common/ProviderAggregator.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class ProviderAggregator implements Geocoder
4545
*/
4646
private $decider;
4747

48-
public function __construct(callable $decider = null, int $limit = Geocoder::DEFAULT_RESULT_LIMIT)
48+
public function __construct(?callable $decider = null, int $limit = Geocoder::DEFAULT_RESULT_LIMIT)
4949
{
5050
$this->limit = $limit;
5151
$this->decider = $decider ?? __CLASS__.'::getProvider';
@@ -134,7 +134,7 @@ public function getProviders(): array
134134
*
135135
* @throws ProviderNotRegistered
136136
*/
137-
private static function getProvider($query, array $providers, Provider $currentProvider = null): Provider
137+
private static function getProvider($query, array $providers, ?Provider $currentProvider = null): Provider
138138
{
139139
if (null !== $currentProvider) {
140140
return $currentProvider;

src/Common/StatefulGeocoder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ final class StatefulGeocoder implements Geocoder
4242
*/
4343
private $provider;
4444

45-
public function __construct(Provider $provider, string $locale = null)
45+
public function __construct(Provider $provider, ?string $locale = null)
4646
{
4747
$this->provider = $provider;
4848
$this->locale = $locale;

src/Http/Provider/AbstractHttpProvider.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ abstract class AbstractHttpProvider extends AbstractProvider
4646
/**
4747
* @param Psr17Factory|MessageFactory|null $factory Passing a MessageFactory is @deprecated
4848
*/
49-
public function __construct(ClientInterface $client, MessageFactory|Psr17Factory $factory = null)
49+
public function __construct(ClientInterface $client, MessageFactory|Psr17Factory|null $factory = null)
5050
{
5151
$this->client = $client;
5252
$this->messageFactory = $factory ?? ($client instanceof RequestFactoryInterface && $client instanceof StreamFactoryInterface ? $client : new Psr17Factory());
@@ -72,7 +72,7 @@ protected function getRequest(string $url): RequestInterface
7272
/**
7373
* @param array<string,string|string[]> $headers
7474
*/
75-
protected function createRequest(string $method, string $uri, array $headers = [], string $body = null): RequestInterface
75+
protected function createRequest(string $method, string $uri, array $headers = [], ?string $body = null): RequestInterface
7676
{
7777
if ($this->messageFactory instanceof MessageFactory) {
7878
return $this->messageFactory->createRequest($method, $uri, $headers, $body);

src/Plugin/Plugin/CachePlugin.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class CachePlugin implements Plugin
4242
*/
4343
private $precision;
4444

45-
public function __construct(CacheInterface $cache, int $lifetime = null, int $precision = null)
45+
public function __construct(CacheInterface $cache, ?int $lifetime = null, ?int $precision = null)
4646
{
4747
$this->cache = $cache;
4848
$this->lifetime = $lifetime;

src/Plugin/Promise/GeocoderFulfilledPromise.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function __construct(Collection $collection)
3030
$this->collection = $collection;
3131
}
3232

33-
public function then(callable $onFulfilled = null, callable $onRejected = null): Promise
33+
public function then(?callable $onFulfilled = null, ?callable $onRejected = null): Promise
3434
{
3535
if (null === $onFulfilled) {
3636
return $this;

src/Plugin/Promise/GeocoderRejectedPromise.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function __construct(Exception $exception)
2929
$this->exception = $exception;
3030
}
3131

32-
public function then(callable $onFulfilled = null, callable $onRejected = null): Promise
32+
public function then(?callable $onFulfilled = null, ?callable $onRejected = null): Promise
3333
{
3434
if (null === $onRejected) {
3535
return $this;

src/Provider/AlgoliaPlaces/AlgoliaPlaces.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class AlgoliaPlaces extends AbstractHttpProvider implements Provider
5353
/** @var GeocodeQuery */
5454
private $query;
5555

56-
public function __construct(ClientInterface $client, string $apiKey = null, string $appId = null)
56+
public function __construct(ClientInterface $client, ?string $apiKey = null, ?string $appId = null)
5757
{
5858
parent::__construct($client);
5959

@@ -180,7 +180,7 @@ private function buildHeaders(): array
180180
/**
181181
* @param array<string, mixed> $jsonResponse
182182
*/
183-
private function buildResult(array $jsonResponse, string $locale = null): AddressCollection
183+
private function buildResult(array $jsonResponse, ?string $locale = null): AddressCollection
184184
{
185185
$results = [];
186186

@@ -227,7 +227,7 @@ private function buildResult(array $jsonResponse, string $locale = null): Addres
227227
*
228228
* @return string|int|float
229229
*/
230-
private function getResultAttribute(array $result, string $attribute, string $locale = null)
230+
private function getResultAttribute(array $result, string $attribute, ?string $locale = null)
231231
{
232232
if (!is_array($result[$attribute])) {
233233
return $result[$attribute];

src/Provider/AlgoliaPlaces/Tests/AlgoliaPlacesTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected function getCacheDir(): string
3333
/**
3434
* Get a real HTTP client. If a cache dir is set to a path it will use cached responses.
3535
*/
36-
protected function getHttpClient(string $apiKey = null, string $appCode = null): ClientInterface
36+
protected function getHttpClient(?string $apiKey = null, ?string $appCode = null): ClientInterface
3737
{
3838
return new CachedResponseClient(new Psr18Client(), $this->getCacheDir(), $apiKey, $appCode);
3939
}

src/Provider/ArcGISOnline/ArcGISOnline.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ final class ArcGISOnline extends AbstractHttpProvider implements Provider
7171
public static function token(
7272
ClientInterface $client,
7373
string $token,
74-
string $sourceCountry = null
74+
?string $sourceCountry = null
7575
) {
7676
$provider = new self($client, $sourceCountry, $token);
7777

@@ -84,7 +84,7 @@ public static function token(
8484
* @param string $token ArcGIS World Geocoding Service token
8585
* Required for the geocodeAddresses endpoint
8686
*/
87-
public function __construct(ClientInterface $client, string $sourceCountry = null, string $token = null)
87+
public function __construct(ClientInterface $client, ?string $sourceCountry = null, ?string $token = null)
8888
{
8989
parent::__construct($client);
9090

src/Provider/AzureMaps/Tests/IntegrationTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ class IntegrationTest extends ProviderIntegrationTest
1818
];
1919

2020
/**
21-
* @return \Geocoder\Provider\Provider that is used in the tests
21+
* @return Geocoder\Provider\Provider that is used in the tests
2222
*/
2323
protected function createProvider(ClientInterface $httpClient)
2424
{
25-
return new \Geocoder\Provider\AzureMaps\AzureMaps($httpClient, $_SERVER['AZURE_MAPS_SUBSCRIPTION_KEY']);
25+
return new Geocoder\Provider\AzureMaps\AzureMaps($httpClient, $_SERVER['AZURE_MAPS_SUBSCRIPTION_KEY']);
2626
}
2727

2828
/**

src/Provider/BingMaps/BingMaps.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function getName(): string
8282
return 'bing_maps';
8383
}
8484

85-
private function executeQuery(string $url, string $locale = null, int $limit): Collection
85+
private function executeQuery(string $url, ?string $locale = null, int $limit): Collection
8686
{
8787
if (null !== $locale) {
8888
$url = sprintf('%s&culture=%s', $url, str_replace('_', '-', $locale));

src/Provider/Cache/ProviderCache.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class ProviderCache implements Provider
4545
*/
4646
private bool $separateCache;
4747

48-
final public function __construct(Provider $realProvider, CacheInterface $cache, int $lifetime = null, bool $separateCache = false)
48+
final public function __construct(Provider $realProvider, CacheInterface $cache, ?int $lifetime = null, bool $separateCache = false)
4949
{
5050
$this->realProvider = $realProvider;
5151
$this->cache = $cache;

src/Provider/Geonames/Geonames.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function reverseQuery(ReverseQuery $query): Collection
9494
/**
9595
* @return CountryInfo[]
9696
*/
97-
public function getCountryInfo(string $country = null, string $locale = null): array
97+
public function getCountryInfo(?string $country = null, ?string $locale = null): array
9898
{
9999
$url = sprintf(self::BASE_ENDPOINT_URL, 'countryInfoJSON', $this->username);
100100

@@ -154,7 +154,7 @@ public function getName(): string
154154
return 'geonames';
155155
}
156156

157-
private function executeQuery(string $url, string $locale = null): AddressCollection
157+
private function executeQuery(string $url, ?string $locale = null): AddressCollection
158158
{
159159
if (null !== $locale) {
160160
// Locale code transformation: for example from it_IT to it

src/Provider/Geonames/Model/CountryInfo.php

+11-11
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function getContinent()
119119
return $this->continent;
120120
}
121121

122-
public function withContinent(string $continent = null): self
122+
public function withContinent(?string $continent = null): self
123123
{
124124
$new = clone $this;
125125
$new->continent = $continent;
@@ -135,7 +135,7 @@ public function getCapital()
135135
return $this->capital;
136136
}
137137

138-
public function withCapital(string $capital = null): self
138+
public function withCapital(?string $capital = null): self
139139
{
140140
$new = clone $this;
141141
$new->capital = $capital;
@@ -167,7 +167,7 @@ public function getGeonameId()
167167
return $this->geonameId;
168168
}
169169

170-
public function withGeonameId(int $geonameId = null): self
170+
public function withGeonameId(?int $geonameId = null): self
171171
{
172172
$new = clone $this;
173173
$new->geonameId = null === $geonameId ? null : (int) $geonameId;
@@ -183,7 +183,7 @@ public function getIsoAlpha3()
183183
return $this->isoAlpha3;
184184
}
185185

186-
public function withIsoAlpha3(string $isoAlpha3 = null): self
186+
public function withIsoAlpha3(?string $isoAlpha3 = null): self
187187
{
188188
$new = clone $this;
189189
$new->isoAlpha3 = $isoAlpha3;
@@ -199,7 +199,7 @@ public function getFipsCode()
199199
return $this->fipsCode;
200200
}
201201

202-
public function withFipsCode(string $fipsCode = null): self
202+
public function withFipsCode(?string $fipsCode = null): self
203203
{
204204
$new = clone $this;
205205
$new->fipsCode = $fipsCode;
@@ -234,7 +234,7 @@ public function getIsoNumeric()
234234
return $this->isoNumeric;
235235
}
236236

237-
public function withIsoNumeric(string $isoNumeric = null): self
237+
public function withIsoNumeric(?string $isoNumeric = null): self
238238
{
239239
$new = clone $this;
240240
$new->isoNumeric = null === $isoNumeric ? null : (int) $isoNumeric;
@@ -250,7 +250,7 @@ public function getAreaInSqKm()
250250
return $this->areaInSqKm;
251251
}
252252

253-
public function withAreaInSqKm(string $areaInSqKm = null): self
253+
public function withAreaInSqKm(?string $areaInSqKm = null): self
254254
{
255255
$new = clone $this;
256256
$new->areaInSqKm = null === $areaInSqKm ? null : (float) $areaInSqKm;
@@ -266,7 +266,7 @@ public function getCountryCode()
266266
return $this->countryCode;
267267
}
268268

269-
public function withCountryCode(string $countryCode = null): self
269+
public function withCountryCode(?string $countryCode = null): self
270270
{
271271
$new = clone $this;
272272
$new->countryCode = $countryCode;
@@ -282,7 +282,7 @@ public function getCountryName()
282282
return $this->countryName;
283283
}
284284

285-
public function withCountryName(string $countryName = null): self
285+
public function withCountryName(?string $countryName = null): self
286286
{
287287
$new = clone $this;
288288
$new->countryName = $countryName;
@@ -298,7 +298,7 @@ public function getContinentName()
298298
return $this->continentName;
299299
}
300300

301-
public function withContinentName(string $continentName = null): self
301+
public function withContinentName(?string $continentName = null): self
302302
{
303303
$new = clone $this;
304304
$new->continentName = $continentName;
@@ -314,7 +314,7 @@ public function getCurrencyCode()
314314
return $this->currencyCode;
315315
}
316316

317-
public function withCurrencyCode(string $currencyCode = null): self
317+
public function withCurrencyCode(?string $currencyCode = null): self
318318
{
319319
$new = clone $this;
320320
$new->currencyCode = $currencyCode;

src/Provider/Geonames/Model/GeonamesAddress.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function getName()
6666
return $this->name;
6767
}
6868

69-
public function withName(string $name = null): self
69+
public function withName(?string $name = null): self
7070
{
7171
$new = clone $this;
7272
$new->name = $name;

0 commit comments

Comments
 (0)