Skip to content

Commit

Permalink
🚨 Apply PHP CS Fixer fixes (#1219)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbelien authored Mar 2, 2024
1 parent 6eef6d3 commit 2d749c5
Show file tree
Hide file tree
Showing 44 changed files with 134 additions and 134 deletions.
2 changes: 1 addition & 1 deletion src/Common/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function isEmpty(): bool;
/**
* @return Location[]
*/
public function slice(int $offset, int $length = null);
public function slice(int $offset, ?int $length = null);

public function has(int $index): bool;

Expand Down
4 changes: 2 additions & 2 deletions src/Common/Geocoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ interface Geocoder extends Provider
/**
* Geocodes a given value.
*
* @throws \Geocoder\Exception\Exception
* @throws Exception\Exception
*/
public function geocode(string $value): Collection;

/**
* Reverses geocode given latitude and longitude values.
*
* @throws \Geocoder\Exception\Exception
* @throws Exception\Exception
*/
public function reverse(float $latitude, float $longitude): Collection;
}
18 changes: 9 additions & 9 deletions src/Common/Model/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ class Address implements Location
final public function __construct(
string $providedBy,
AdminLevelCollection $adminLevels,
Coordinates $coordinates = null,
Bounds $bounds = null,
string $streetNumber = null,
string $streetName = null,
string $postalCode = null,
string $locality = null,
string $subLocality = null,
Country $country = null,
string $timezone = null
?Coordinates $coordinates = null,
?Bounds $bounds = null,
?string $streetNumber = null,
?string $streetName = null,
?string $postalCode = null,
?string $locality = null,
?string $subLocality = null,
?Country $country = null,
?string $timezone = null
) {
$this->providedBy = $providedBy;
$this->adminLevels = $adminLevels;
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Model/AddressBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function setCoordinates($latitude, $longitude): self
return $this;
}

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

Expand Down
2 changes: 1 addition & 1 deletion src/Common/Model/AddressCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function isEmpty(): bool
/**
* @return Location[]
*/
public function slice(int $offset, int $length = null)
public function slice(int $offset, ?int $length = null)
{
return array_slice($this->locations, $offset, $length);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Model/AdminLevel.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class AdminLevel
*/
private $code;

public function __construct(int $level, string $name, string $code = null)
public function __construct(int $level, string $name, ?string $code = null)
{
$this->level = $level;
$this->name = $name;
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Model/AdminLevelCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function first(): AdminLevel
/**
* @return AdminLevel[]
*/
public function slice(int $offset, int $length = null): array
public function slice(int $offset, ?int $length = null): array
{
return array_slice($this->adminLevels, $offset, $length, true);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Model/Country.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ final class Country
*/
private $code;

public function __construct(string $name = null, string $code = null)
public function __construct(?string $name = null, ?string $code = null)
{
if (null === $name && null === $code) {
throw new InvalidArgument('A country must have either a name or a code');
Expand Down
4 changes: 2 additions & 2 deletions src/Common/ProviderAggregator.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ProviderAggregator implements Geocoder
*/
private $decider;

public function __construct(callable $decider = null, int $limit = Geocoder::DEFAULT_RESULT_LIMIT)
public function __construct(?callable $decider = null, int $limit = Geocoder::DEFAULT_RESULT_LIMIT)
{
$this->limit = $limit;
$this->decider = $decider ?? __CLASS__.'::getProvider';
Expand Down Expand Up @@ -134,7 +134,7 @@ public function getProviders(): array
*
* @throws ProviderNotRegistered
*/
private static function getProvider($query, array $providers, Provider $currentProvider = null): Provider
private static function getProvider($query, array $providers, ?Provider $currentProvider = null): Provider
{
if (null !== $currentProvider) {
return $currentProvider;
Expand Down
2 changes: 1 addition & 1 deletion src/Common/StatefulGeocoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ final class StatefulGeocoder implements Geocoder
*/
private $provider;

public function __construct(Provider $provider, string $locale = null)
public function __construct(Provider $provider, ?string $locale = null)
{
$this->provider = $provider;
$this->locale = $locale;
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Provider/AbstractHttpProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ abstract class AbstractHttpProvider extends AbstractProvider
/**
* @param Psr17Factory|MessageFactory|null $factory Passing a MessageFactory is @deprecated
*/
public function __construct(ClientInterface $client, MessageFactory|Psr17Factory $factory = null)
public function __construct(ClientInterface $client, MessageFactory|Psr17Factory|null $factory = null)
{
$this->client = $client;
$this->messageFactory = $factory ?? ($client instanceof RequestFactoryInterface && $client instanceof StreamFactoryInterface ? $client : new Psr17Factory());
Expand All @@ -72,7 +72,7 @@ protected function getRequest(string $url): RequestInterface
/**
* @param array<string,string|string[]> $headers
*/
protected function createRequest(string $method, string $uri, array $headers = [], string $body = null): RequestInterface
protected function createRequest(string $method, string $uri, array $headers = [], ?string $body = null): RequestInterface
{
if ($this->messageFactory instanceof MessageFactory) {
return $this->messageFactory->createRequest($method, $uri, $headers, $body);
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin/Plugin/CachePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class CachePlugin implements Plugin
*/
private $precision;

public function __construct(CacheInterface $cache, int $lifetime = null, int $precision = null)
public function __construct(CacheInterface $cache, ?int $lifetime = null, ?int $precision = null)
{
$this->cache = $cache;
$this->lifetime = $lifetime;
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin/Promise/GeocoderFulfilledPromise.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct(Collection $collection)
$this->collection = $collection;
}

public function then(callable $onFulfilled = null, callable $onRejected = null): Promise
public function then(?callable $onFulfilled = null, ?callable $onRejected = null): Promise
{
if (null === $onFulfilled) {
return $this;
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin/Promise/GeocoderRejectedPromise.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(Exception $exception)
$this->exception = $exception;
}

public function then(callable $onFulfilled = null, callable $onRejected = null): Promise
public function then(?callable $onFulfilled = null, ?callable $onRejected = null): Promise
{
if (null === $onRejected) {
return $this;
Expand Down
6 changes: 3 additions & 3 deletions src/Provider/AlgoliaPlaces/AlgoliaPlaces.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class AlgoliaPlaces extends AbstractHttpProvider implements Provider
/** @var GeocodeQuery */
private $query;

public function __construct(ClientInterface $client, string $apiKey = null, string $appId = null)
public function __construct(ClientInterface $client, ?string $apiKey = null, ?string $appId = null)
{
parent::__construct($client);

Expand Down Expand Up @@ -180,7 +180,7 @@ private function buildHeaders(): array
/**
* @param array<string, mixed> $jsonResponse
*/
private function buildResult(array $jsonResponse, string $locale = null): AddressCollection
private function buildResult(array $jsonResponse, ?string $locale = null): AddressCollection
{
$results = [];

Expand Down Expand Up @@ -227,7 +227,7 @@ private function buildResult(array $jsonResponse, string $locale = null): Addres
*
* @return string|int|float
*/
private function getResultAttribute(array $result, string $attribute, string $locale = null)
private function getResultAttribute(array $result, string $attribute, ?string $locale = null)
{
if (!is_array($result[$attribute])) {
return $result[$attribute];
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/AlgoliaPlaces/Tests/AlgoliaPlacesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected function getCacheDir(): string
/**
* Get a real HTTP client. If a cache dir is set to a path it will use cached responses.
*/
protected function getHttpClient(string $apiKey = null, string $appCode = null): ClientInterface
protected function getHttpClient(?string $apiKey = null, ?string $appCode = null): ClientInterface
{
return new CachedResponseClient(new Psr18Client(), $this->getCacheDir(), $apiKey, $appCode);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Provider/ArcGISOnline/ArcGISOnline.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ final class ArcGISOnline extends AbstractHttpProvider implements Provider
public static function token(
ClientInterface $client,
string $token,
string $sourceCountry = null
?string $sourceCountry = null
) {
$provider = new self($client, $sourceCountry, $token);

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

Expand Down
4 changes: 2 additions & 2 deletions src/Provider/AzureMaps/Tests/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ class IntegrationTest extends ProviderIntegrationTest
];

/**
* @return \Geocoder\Provider\Provider that is used in the tests
* @return Geocoder\Provider\Provider that is used in the tests
*/
protected function createProvider(ClientInterface $httpClient)
{
return new \Geocoder\Provider\AzureMaps\AzureMaps($httpClient, $_SERVER['AZURE_MAPS_SUBSCRIPTION_KEY']);
return new Geocoder\Provider\AzureMaps\AzureMaps($httpClient, $_SERVER['AZURE_MAPS_SUBSCRIPTION_KEY']);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/BingMaps/BingMaps.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function getName(): string
return 'bing_maps';
}

private function executeQuery(string $url, string $locale = null, int $limit): Collection
private function executeQuery(string $url, ?string $locale = null, int $limit): Collection
{
if (null !== $locale) {
$url = sprintf('%s&culture=%s', $url, str_replace('_', '-', $locale));
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/Cache/ProviderCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ProviderCache implements Provider
*/
private bool $separateCache;

final public function __construct(Provider $realProvider, CacheInterface $cache, int $lifetime = null, bool $separateCache = false)
final public function __construct(Provider $realProvider, CacheInterface $cache, ?int $lifetime = null, bool $separateCache = false)
{
$this->realProvider = $realProvider;
$this->cache = $cache;
Expand Down
4 changes: 2 additions & 2 deletions src/Provider/Geonames/Geonames.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function reverseQuery(ReverseQuery $query): Collection
/**
* @return CountryInfo[]
*/
public function getCountryInfo(string $country = null, string $locale = null): array
public function getCountryInfo(?string $country = null, ?string $locale = null): array
{
$url = sprintf(self::BASE_ENDPOINT_URL, 'countryInfoJSON', $this->username);

Expand Down Expand Up @@ -154,7 +154,7 @@ public function getName(): string
return 'geonames';
}

private function executeQuery(string $url, string $locale = null): AddressCollection
private function executeQuery(string $url, ?string $locale = null): AddressCollection
{
if (null !== $locale) {
// Locale code transformation: for example from it_IT to it
Expand Down
22 changes: 11 additions & 11 deletions src/Provider/Geonames/Model/CountryInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function getContinent()
return $this->continent;
}

public function withContinent(string $continent = null): self
public function withContinent(?string $continent = null): self
{
$new = clone $this;
$new->continent = $continent;
Expand All @@ -135,7 +135,7 @@ public function getCapital()
return $this->capital;
}

public function withCapital(string $capital = null): self
public function withCapital(?string $capital = null): self
{
$new = clone $this;
$new->capital = $capital;
Expand Down Expand Up @@ -167,7 +167,7 @@ public function getGeonameId()
return $this->geonameId;
}

public function withGeonameId(int $geonameId = null): self
public function withGeonameId(?int $geonameId = null): self
{
$new = clone $this;
$new->geonameId = null === $geonameId ? null : (int) $geonameId;
Expand All @@ -183,7 +183,7 @@ public function getIsoAlpha3()
return $this->isoAlpha3;
}

public function withIsoAlpha3(string $isoAlpha3 = null): self
public function withIsoAlpha3(?string $isoAlpha3 = null): self
{
$new = clone $this;
$new->isoAlpha3 = $isoAlpha3;
Expand All @@ -199,7 +199,7 @@ public function getFipsCode()
return $this->fipsCode;
}

public function withFipsCode(string $fipsCode = null): self
public function withFipsCode(?string $fipsCode = null): self
{
$new = clone $this;
$new->fipsCode = $fipsCode;
Expand Down Expand Up @@ -234,7 +234,7 @@ public function getIsoNumeric()
return $this->isoNumeric;
}

public function withIsoNumeric(string $isoNumeric = null): self
public function withIsoNumeric(?string $isoNumeric = null): self
{
$new = clone $this;
$new->isoNumeric = null === $isoNumeric ? null : (int) $isoNumeric;
Expand All @@ -250,7 +250,7 @@ public function getAreaInSqKm()
return $this->areaInSqKm;
}

public function withAreaInSqKm(string $areaInSqKm = null): self
public function withAreaInSqKm(?string $areaInSqKm = null): self
{
$new = clone $this;
$new->areaInSqKm = null === $areaInSqKm ? null : (float) $areaInSqKm;
Expand All @@ -266,7 +266,7 @@ public function getCountryCode()
return $this->countryCode;
}

public function withCountryCode(string $countryCode = null): self
public function withCountryCode(?string $countryCode = null): self
{
$new = clone $this;
$new->countryCode = $countryCode;
Expand All @@ -282,7 +282,7 @@ public function getCountryName()
return $this->countryName;
}

public function withCountryName(string $countryName = null): self
public function withCountryName(?string $countryName = null): self
{
$new = clone $this;
$new->countryName = $countryName;
Expand All @@ -298,7 +298,7 @@ public function getContinentName()
return $this->continentName;
}

public function withContinentName(string $continentName = null): self
public function withContinentName(?string $continentName = null): self
{
$new = clone $this;
$new->continentName = $continentName;
Expand All @@ -314,7 +314,7 @@ public function getCurrencyCode()
return $this->currencyCode;
}

public function withCurrencyCode(string $currencyCode = null): self
public function withCurrencyCode(?string $currencyCode = null): self
{
$new = clone $this;
$new->currencyCode = $currencyCode;
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/Geonames/Model/GeonamesAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function getName()
return $this->name;
}

public function withName(string $name = null): self
public function withName(?string $name = null): self
{
$new = clone $this;
$new->name = $name;
Expand Down
Loading

0 comments on commit 2d749c5

Please sign in to comment.