diff --git a/Countries.php b/Countries.php index fd17c3f0..256bd54e 100644 --- a/Countries.php +++ b/Countries.php @@ -127,7 +127,7 @@ public static function numericCodeExists(string $numericCode): bool * * @throws MissingResourceException if the country code does not exist */ - public static function getName(string $country, string $displayLocale = null): string + public static function getName(string $country, ?string $displayLocale = null): string { return self::readEntry(['Names', $country], $displayLocale); } @@ -137,7 +137,7 @@ public static function getName(string $country, string $displayLocale = null): s * * @throws MissingResourceException if the country code does not exist */ - public static function getAlpha3Name(string $alpha3Code, string $displayLocale = null): string + public static function getAlpha3Name(string $alpha3Code, ?string $displayLocale = null): string { return self::getName(self::getAlpha2Code($alpha3Code), $displayLocale); } @@ -147,7 +147,7 @@ public static function getAlpha3Name(string $alpha3Code, string $displayLocale = * * @return array */ - public static function getNames(string $displayLocale = null): array + public static function getNames(?string $displayLocale = null): array { return self::asort(self::readEntry(['Names'], $displayLocale), $displayLocale); } @@ -159,7 +159,7 @@ public static function getNames(string $displayLocale = null): array * * @return array */ - public static function getAlpha3Names(string $displayLocale = null): array + public static function getAlpha3Names(?string $displayLocale = null): array { $alpha2Names = self::getNames($displayLocale); $alpha3Names = []; diff --git a/Currencies.php b/Currencies.php index 2f52576d..ce7fe5e2 100644 --- a/Currencies.php +++ b/Currencies.php @@ -50,7 +50,7 @@ public static function exists(string $currency): bool /** * @throws MissingResourceException if the currency code does not exist */ - public static function getName(string $currency, string $displayLocale = null): string + public static function getName(string $currency, ?string $displayLocale = null): string { return self::readEntry(['Names', $currency, self::INDEX_NAME], $displayLocale); } @@ -58,7 +58,7 @@ public static function getName(string $currency, string $displayLocale = null): /** * @return string[] */ - public static function getNames(string $displayLocale = null): array + public static function getNames(?string $displayLocale = null): array { // ==================================================================== // For reference: It is NOT possible to return names indexed by @@ -82,7 +82,7 @@ public static function getNames(string $displayLocale = null): array /** * @throws MissingResourceException if the currency code does not exist */ - public static function getSymbol(string $currency, string $displayLocale = null): string + public static function getSymbol(string $currency, ?string $displayLocale = null): string { return self::readEntry(['Names', $currency, self::INDEX_SYMBOL], $displayLocale); } diff --git a/Data/Generator/TimezoneDataGenerator.php b/Data/Generator/TimezoneDataGenerator.php index a0573e36..9de6a0cd 100644 --- a/Data/Generator/TimezoneDataGenerator.php +++ b/Data/Generator/TimezoneDataGenerator.php @@ -159,7 +159,7 @@ private function generateZones(BundleEntryReaderInterface $reader, string $tempD $regionFormat = $reader->readEntry($tempDir, $locale, ['zoneStrings', 'regionFormat']); $fallbackFormat = $reader->readEntry($tempDir, $locale, ['zoneStrings', 'fallbackFormat']); - $resolveName = function (string $id, string $city = null) use ($reader, $tempDir, $locale, $regionFormat, $fallbackFormat): ?string { + $resolveName = function (string $id, ?string $city = null) use ($reader, $tempDir, $locale, $regionFormat, $fallbackFormat): ?string { // Resolve default name as described per http://cldr.unicode.org/translation/timezones if (isset($this->zoneToCountryMapping[$id])) { try { diff --git a/Languages.php b/Languages.php index e00b89fa..bff314b9 100644 --- a/Languages.php +++ b/Languages.php @@ -56,7 +56,7 @@ public static function exists(string $language): bool * * @throws MissingResourceException if the language code does not exist */ - public static function getName(string $language, string $displayLocale = null): string + public static function getName(string $language, ?string $displayLocale = null): string { try { return self::readEntry(['Names', $language], $displayLocale); @@ -78,7 +78,7 @@ public static function getName(string $language, string $displayLocale = null): * * @return array */ - public static function getNames(string $displayLocale = null): array + public static function getNames(?string $displayLocale = null): array { return self::asort(self::readEntry(['Names'], $displayLocale), $displayLocale); } @@ -137,7 +137,7 @@ public static function alpha3CodeExists(string $language): bool * * @throws MissingResourceException if the country code does not exists */ - public static function getAlpha3Name(string $language, string $displayLocale = null): string + public static function getAlpha3Name(string $language, ?string $displayLocale = null): string { try { return self::getName(self::getAlpha2Code($language), $displayLocale); @@ -157,7 +157,7 @@ public static function getAlpha3Name(string $language, string $displayLocale = n * * @return array */ - public static function getAlpha3Names(string $displayLocale = null): array + public static function getAlpha3Names(?string $displayLocale = null): array { $alpha2Names = self::getNames($displayLocale); $alpha3Names = []; diff --git a/Locales.php b/Locales.php index 10d3dcef..ea4f50a7 100644 --- a/Locales.php +++ b/Locales.php @@ -51,7 +51,7 @@ public static function exists(string $locale): bool /** * @throws MissingResourceException if the locale does not exist */ - public static function getName(string $locale, string $displayLocale = null): string + public static function getName(string $locale, ?string $displayLocale = null): string { try { return self::readEntry(['Names', $locale], $displayLocale); @@ -67,7 +67,7 @@ public static function getName(string $locale, string $displayLocale = null): st /** * @return string[] */ - public static function getNames(string $displayLocale = null): array + public static function getNames(?string $displayLocale = null): array { return self::asort(self::readEntry(['Names'], $displayLocale), $displayLocale); } diff --git a/ResourceBundle.php b/ResourceBundle.php index f1bc4825..be5017ce 100644 --- a/ResourceBundle.php +++ b/ResourceBundle.php @@ -43,7 +43,7 @@ abstract protected static function getPath(): string; * @return mixed returns an array or {@link \ArrayAccess} instance for * complex data and a scalar value for simple data */ - final protected static function readEntry(array $indices, string $locale = null, bool $fallback = true): mixed + final protected static function readEntry(array $indices, ?string $locale = null, bool $fallback = true): mixed { if (!isset(self::$entryReader)) { self::$entryReader = new BundleEntryReader(new BufferedBundleReader( @@ -58,7 +58,7 @@ final protected static function readEntry(array $indices, string $locale = null, return self::$entryReader->readEntry(static::getPath(), $locale ?? \Locale::getDefault(), $indices, $fallback); } - final protected static function asort(iterable $list, string $locale = null): array + final protected static function asort(iterable $list, ?string $locale = null): array { if ($list instanceof \Traversable) { $list = iterator_to_array($list); diff --git a/Scripts.php b/Scripts.php index d21ed6fa..27e46067 100644 --- a/Scripts.php +++ b/Scripts.php @@ -43,7 +43,7 @@ public static function exists(string $script): bool /** * @throws MissingResourceException if the script code does not exist */ - public static function getName(string $script, string $displayLocale = null): string + public static function getName(string $script, ?string $displayLocale = null): string { return self::readEntry(['Names', $script], $displayLocale); } @@ -51,7 +51,7 @@ public static function getName(string $script, string $displayLocale = null): st /** * @return string[] */ - public static function getNames(string $displayLocale = null): array + public static function getNames(?string $displayLocale = null): array { return self::asort(self::readEntry(['Names'], $displayLocale), $displayLocale); } diff --git a/Timezones.php b/Timezones.php index 0f9f4e3d..53d054f2 100644 --- a/Timezones.php +++ b/Timezones.php @@ -49,7 +49,7 @@ public static function exists(string $timezone): bool /** * @throws MissingResourceException if the timezone identifier does not exist or is an alias */ - public static function getName(string $timezone, string $displayLocale = null): string + public static function getName(string $timezone, ?string $displayLocale = null): string { return self::readEntry(['Names', $timezone], $displayLocale); } @@ -57,7 +57,7 @@ public static function getName(string $timezone, string $displayLocale = null): /** * @return string[] */ - public static function getNames(string $displayLocale = null): array + public static function getNames(?string $displayLocale = null): array { return self::asort(self::readEntry(['Names'], $displayLocale), $displayLocale); } @@ -66,14 +66,14 @@ public static function getNames(string $displayLocale = null): array * @throws \Exception if the timezone identifier does not exist * @throws RuntimeException if there's no timezone DST transition information available */ - public static function getRawOffset(string $timezone, int $timestamp = null): int + public static function getRawOffset(string $timezone, ?int $timestamp = null): int { $dateTimeImmutable = new \DateTimeImmutable(date('Y-m-d H:i:s', $timestamp ?? time()), new \DateTimeZone($timezone)); return $dateTimeImmutable->getOffset(); } - public static function getGmtOffset(string $timezone, int $timestamp = null, string $displayLocale = null): string + public static function getGmtOffset(string $timezone, ?int $timestamp = null, ?string $displayLocale = null): string { $offset = self::getRawOffset($timezone, $timestamp); $abs = abs($offset); diff --git a/Util/GitRepository.php b/Util/GitRepository.php index acbe8c49..1f8870cc 100644 --- a/Util/GitRepository.php +++ b/Util/GitRepository.php @@ -69,7 +69,7 @@ public function getLastAuthoredDate(): \DateTimeImmutable return new \DateTimeImmutable($this->getLastLine($this->execInPath('git log -1 --format="%ai"'))); } - public function getLastTag(callable $filter = null): string + public function getLastTag(?callable $filter = null): string { $tags = $this->execInPath('git tag -l --sort=v:refname'); @@ -90,7 +90,7 @@ private function execInPath(string $command): array return self::exec(sprintf('cd %s && %s', escapeshellarg($this->path), $command)); } - private static function exec(string $command, string $customErrorMessage = null): array + private static function exec(string $command, ?string $customErrorMessage = null): array { exec(sprintf('%s 2>&1', $command), $output, $result); diff --git a/Util/IcuVersion.php b/Util/IcuVersion.php index b75987f7..22c15ae2 100644 --- a/Util/IcuVersion.php +++ b/Util/IcuVersion.php @@ -48,7 +48,7 @@ class IcuVersion * * @see normalize() */ - public static function compare(string $version1, string $version2, string $operator, int $precision = null): bool + public static function compare(string $version1, string $version2, string $operator, ?int $precision = null): bool { $version1 = self::normalize($version1, $precision); $version2 = self::normalize($version2, $precision); diff --git a/Util/IntlTestHelper.php b/Util/IntlTestHelper.php index f937f2eb..dd875f3c 100644 --- a/Util/IntlTestHelper.php +++ b/Util/IntlTestHelper.php @@ -30,7 +30,7 @@ class IntlTestHelper /** * Should be called before tests that work fine with the stub implementation. */ - public static function requireIntl(TestCase $testCase, string $minimumIcuVersion = null): void + public static function requireIntl(TestCase $testCase, ?string $minimumIcuVersion = null): void { $minimumIcuVersion ??= Intl::getIcuStubVersion(); @@ -62,7 +62,7 @@ public static function requireIntl(TestCase $testCase, string $minimumIcuVersion * Should be called before tests that require a feature-complete intl * implementation. */ - public static function requireFullIntl(TestCase $testCase, string $minimumIcuVersion = null): void + public static function requireFullIntl(TestCase $testCase, ?string $minimumIcuVersion = null): void { // We only run tests if the intl extension is loaded... if (!Intl::isExtensionLoaded()) { diff --git a/Util/Version.php b/Util/Version.php index 8d72c3af..f30709ec 100644 --- a/Util/Version.php +++ b/Util/Version.php @@ -38,7 +38,7 @@ class Version * * @see normalize() */ - public static function compare(string $version1, string $version2, string $operator, int $precision = null): bool + public static function compare(string $version1, string $version2, string $operator, ?int $precision = null): bool { $version1 = self::normalize($version1, $precision); $version2 = self::normalize($version2, $precision);