Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nullable types must be explicit. #93

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Currency/CurrencyRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
* @param string|null $definitionPath The path to the currency definitions.
* Defaults to 'resources/currency'.
*/
public function __construct(string $defaultLocale = 'en', string $fallbackLocale = 'en', string $definitionPath = null)
public function __construct(string $defaultLocale = 'en', string $fallbackLocale = 'en', ?string $definitionPath = null)
{
$this->defaultLocale = $defaultLocale;
$this->fallbackLocale = $fallbackLocale;
Expand All @@ -76,7 +76,7 @@ public function __construct(string $defaultLocale = 'en', string $fallbackLocale
/**
* {@inheritdoc}
*/
public function get(string $currencyCode, string $locale = null): Currency
public function get(string $currencyCode, ?string $locale = null): Currency
{
$currencyCode = strtoupper($currencyCode);
$baseDefinitions = $this->getBaseDefinitions();
Expand All @@ -99,7 +99,7 @@ public function get(string $currencyCode, string $locale = null): Currency
/**
* {@inheritdoc}
*/
public function getAll(string $locale = null): array
public function getAll(?string $locale = null): array
{
$locale = $locale ?: $this->defaultLocale;
$locale = Locale::resolve($this->availableLocales, $locale, $this->fallbackLocale);
Expand All @@ -121,7 +121,7 @@ public function getAll(string $locale = null): array
/**
* {@inheritdoc}
*/
public function getList(string $locale = null): array
public function getList(?string $locale = null): array
{
$locale = $locale ?: $this->defaultLocale;
$locale = Locale::resolve($this->availableLocales, $locale, $this->fallbackLocale);
Expand Down
6 changes: 3 additions & 3 deletions src/Currency/CurrencyRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface CurrencyRepositoryInterface
*
* @throws UnknownCurrencyException
*/
public function get(string $currencyCode, string $locale = null): Currency;
public function get(string $currencyCode, ?string $locale = null): Currency;

/**
* Gets all currencies.
Expand All @@ -28,7 +28,7 @@ public function get(string $currencyCode, string $locale = null): Currency;
*
* @return Currency[] An array of currencies, keyed by currency code.
*/
public function getAll(string $locale = null): array;
public function getAll(?string $locale = null): array;

/**
* Gets a list of currencies.
Expand All @@ -37,5 +37,5 @@ public function getAll(string $locale = null): array;
*
* @return string[] An array of currency names, keyed by currency code.
*/
public function getList(string $locale = null): array;
public function getList(?string $locale = null): array;
}
8 changes: 4 additions & 4 deletions src/Language/LanguageRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class LanguageRepository implements LanguageRepositoryInterface
* @param string|null $definitionPath The path to the currency definitions.
* Defaults to 'resources/language'.
*/
public function __construct(string $defaultLocale = 'en', string $fallbackLocale = 'en', string $definitionPath = null)
public function __construct(string $defaultLocale = 'en', string $fallbackLocale = 'en', ?string $definitionPath = null)
{
$this->defaultLocale = $defaultLocale;
$this->fallbackLocale = $fallbackLocale;
Expand All @@ -78,7 +78,7 @@ public function __construct(string $defaultLocale = 'en', string $fallbackLocale
/**
* {@inheritdoc}
*/
public function get(string $languageCode, string $locale = null): Language
public function get(string $languageCode, ?string $locale = null): Language
{
$locale = $locale ?: $this->defaultLocale;
$locale = Locale::resolve($this->availableLocales, $locale, $this->fallbackLocale);
Expand All @@ -99,7 +99,7 @@ public function get(string $languageCode, string $locale = null): Language
/**
* {@inheritdoc}
*/
public function getAll(string $locale = null): array
public function getAll(?string $locale = null): array
{
$locale = $locale ?: $this->defaultLocale;
$locale = Locale::resolve($this->availableLocales, $locale, $this->fallbackLocale);
Expand All @@ -119,7 +119,7 @@ public function getAll(string $locale = null): array
/**
* {@inheritdoc}
*/
public function getList(string $locale = null): array
public function getList(?string $locale = null): array
{
$locale = $locale ?: $this->defaultLocale;
$locale = Locale::resolve($this->availableLocales, $locale, $this->fallbackLocale);
Expand Down
6 changes: 3 additions & 3 deletions src/Language/LanguageRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface LanguageRepositoryInterface
*
* @throws \CommerceGuys\Intl\Exception\UnknownLanguageException
*/
public function get(string $languageCode, string $locale = null): Language;
public function get(string $languageCode, ?string $locale = null): Language;

/**
* Gets all languages.
Expand All @@ -26,7 +26,7 @@ public function get(string $languageCode, string $locale = null): Language;
*
* @return Language[] An array of languages, keyed by language code.
*/
public function getAll(string $locale = null): array;
public function getAll(?string $locale = null): array;

/**
* Gets a list of languages.
Expand All @@ -35,5 +35,5 @@ public function getAll(string $locale = null): array;
*
* @return array An array of language names, keyed by language code.
*/
public function getList(string $locale = null): array;
public function getList(?string $locale = null): array;
}
4 changes: 2 additions & 2 deletions src/Locale.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public static function matchCandidates(string $firstLocale, string $secondLocale
*
* @throws UnknownLocaleException
*/
public static function resolve(array $availableLocales, string $locale, string $fallbackLocale = null): string
public static function resolve(array $availableLocales, string $locale, ?string $fallbackLocale = null): string
{
$locale = self::canonicalize($locale);
$resolvedLocale = null;
Expand Down Expand Up @@ -353,7 +353,7 @@ public static function canonicalize(string $locale): string
*
* @return array An array of all variants of a locale.
*/
public static function getCandidates(string $locale, string $fallbackLocale = null): array
public static function getCandidates(string $locale, ?string $fallbackLocale = null): array
{
$locale = self::replaceAlias($locale);
$candidates = [$locale];
Expand Down