Skip to content

Commit

Permalink
Apply php-cs-fixer fix --rules nullable_type_declaration_for_default_…
Browse files Browse the repository at this point in the history
…null_value
  • Loading branch information
nicolas-grekas committed Jan 23, 2024
1 parent cd6cce1 commit 2fb503f
Show file tree
Hide file tree
Showing 23 changed files with 50 additions and 50 deletions.
8 changes: 4 additions & 4 deletions Countries.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static function alpha3CodeExists(string $alpha3Code): 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);
}
Expand All @@ -99,7 +99,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);
}
Expand All @@ -109,7 +109,7 @@ public static function getAlpha3Name(string $alpha3Code, string $displayLocale =
*
* @return array<string, 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);
}
Expand All @@ -121,7 +121,7 @@ public static function getNames(string $displayLocale = null): array
*
* @return array<string, string>
*/
public static function getAlpha3Names(string $displayLocale = null): array
public static function getAlpha3Names(?string $displayLocale = null): array
{
$alpha2Names = self::getNames($displayLocale);
$alpha3Names = [];
Expand Down
6 changes: 3 additions & 3 deletions Currencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ 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);
}

/**
* @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
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion Data/Generator/TimezoneDataGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,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 {
Expand Down
2 changes: 1 addition & 1 deletion DateFormatter/DateFormat/Hour1200Transformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function format(\DateTime $dateTime, int $length): string
/**
* {@inheritdoc}
*/
public function normalizeHour(int $hour, string $marker = null): int
public function normalizeHour(int $hour, ?string $marker = null): int
{
if ('PM' === $marker) {
$hour += 12;
Expand Down
2 changes: 1 addition & 1 deletion DateFormatter/DateFormat/Hour1201Transformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function format(\DateTime $dateTime, int $length): string
/**
* {@inheritdoc}
*/
public function normalizeHour(int $hour, string $marker = null): int
public function normalizeHour(int $hour, ?string $marker = null): int
{
if ('PM' !== $marker && 12 === $hour) {
$hour = 0;
Expand Down
2 changes: 1 addition & 1 deletion DateFormatter/DateFormat/Hour2400Transformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function format(\DateTime $dateTime, int $length): string
/**
* {@inheritdoc}
*/
public function normalizeHour(int $hour, string $marker = null): int
public function normalizeHour(int $hour, ?string $marker = null): int
{
if ('AM' === $marker) {
$hour = 0;
Expand Down
2 changes: 1 addition & 1 deletion DateFormatter/DateFormat/Hour2401Transformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function format(\DateTime $dateTime, int $length): string
/**
* {@inheritdoc}
*/
public function normalizeHour(int $hour, string $marker = null): int
public function normalizeHour(int $hour, ?string $marker = null): int
{
if ((null === $marker && 24 === $hour) || 'AM' === $marker) {
$hour = 0;
Expand Down
2 changes: 1 addition & 1 deletion DateFormatter/DateFormat/HourTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ abstract class HourTransformer extends Transformer
*
* @return int The normalized hour value
*/
abstract public function normalizeHour(int $hour, string $marker = null): int;
abstract public function normalizeHour(int $hour, ?string $marker = null): int;
}
8 changes: 4 additions & 4 deletions DateFormatter/IntlDateFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ abstract class IntlDateFormatter
* @throws MethodArgumentValueNotImplementedException When $locale different than "en" or null is passed
* @throws MethodArgumentValueNotImplementedException When $calendar different than GREGORIAN is passed
*/
public function __construct(?string $locale, ?int $datetype, ?int $timetype, $timezone = null, ?int $calendar = self::GREGORIAN, string $pattern = null)
public function __construct(?string $locale, ?int $datetype, ?int $timetype, $timezone = null, ?int $calendar = self::GREGORIAN, ?string $pattern = null)
{
if ('en' !== $locale && null !== $locale) {
throw new MethodArgumentValueNotImplementedException(__METHOD__, 'locale', $locale, 'Only the locale "en" is supported');
Expand Down Expand Up @@ -174,7 +174,7 @@ public function __construct(?string $locale, ?int $datetype, ?int $timetype, $ti
* @throws MethodArgumentValueNotImplementedException When $locale different than "en" or null is passed
* @throws MethodArgumentValueNotImplementedException When $calendar different than GREGORIAN is passed
*/
public static function create(?string $locale, ?int $datetype, ?int $timetype, $timezone = null, int $calendar = self::GREGORIAN, string $pattern = null)
public static function create(?string $locale, ?int $datetype, ?int $timetype, $timezone = null, int $calendar = self::GREGORIAN, ?string $pattern = null)
{
return new static($locale, $datetype, $timetype, $timezone, $calendar, $pattern);
}
Expand Down Expand Up @@ -244,7 +244,7 @@ public function format($timestamp)
*
* @throws MethodNotImplementedException
*/
public static function formatObject(object $object, $format = null, string $locale = null)
public static function formatObject(object $object, $format = null, ?string $locale = null)
{
throw new MethodNotImplementedException(__METHOD__);
}
Expand Down Expand Up @@ -430,7 +430,7 @@ public function localtime(string $value, int &$position = 0)
*
* @throws MethodArgumentNotImplementedException When $position different than null, behavior not implemented
*/
public function parse(string $value, int &$position = null)
public function parse(string $value, ?int &$position = null)
{
// We don't calculate the position when parsing the value
if (null !== $position) {
Expand Down
8 changes: 4 additions & 4 deletions Languages.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -78,7 +78,7 @@ public static function getName(string $language, string $displayLocale = null):
*
* @return array<string, 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);
}
Expand Down Expand Up @@ -139,7 +139,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);
Expand All @@ -159,7 +159,7 @@ public static function getAlpha3Name(string $language, string $displayLocale = n
*
* @return array<string, string>
*/
public static function getAlpha3Names(string $displayLocale = null): array
public static function getAlpha3Names(?string $displayLocale = null): array
{
$alpha2Names = self::getNames($displayLocale);
$alpha3Names = [];
Expand Down
12 changes: 6 additions & 6 deletions Locale/Locale.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public static function getDefault()
*
* @throws MethodNotImplementedException
*/
public static function getDisplayLanguage(string $locale, string $inLocale = null)
public static function getDisplayLanguage(string $locale, ?string $inLocale = null)
{
throw new MethodNotImplementedException(__METHOD__);
}
Expand All @@ -178,7 +178,7 @@ public static function getDisplayLanguage(string $locale, string $inLocale = nul
*
* @throws MethodNotImplementedException
*/
public static function getDisplayName(string $locale, string $inLocale = null)
public static function getDisplayName(string $locale, ?string $inLocale = null)
{
throw new MethodNotImplementedException(__METHOD__);
}
Expand All @@ -195,7 +195,7 @@ public static function getDisplayName(string $locale, string $inLocale = null)
*
* @throws MethodNotImplementedException
*/
public static function getDisplayRegion(string $locale, string $inLocale = null)
public static function getDisplayRegion(string $locale, ?string $inLocale = null)
{
throw new MethodNotImplementedException(__METHOD__);
}
Expand All @@ -212,7 +212,7 @@ public static function getDisplayRegion(string $locale, string $inLocale = null)
*
* @throws MethodNotImplementedException
*/
public static function getDisplayScript(string $locale, string $inLocale = null)
public static function getDisplayScript(string $locale, ?string $inLocale = null)
{
throw new MethodNotImplementedException(__METHOD__);
}
Expand All @@ -229,7 +229,7 @@ public static function getDisplayScript(string $locale, string $inLocale = null)
*
* @throws MethodNotImplementedException
*/
public static function getDisplayVariant(string $locale, string $inLocale = null)
public static function getDisplayVariant(string $locale, ?string $inLocale = null)
{
throw new MethodNotImplementedException(__METHOD__);
}
Expand Down Expand Up @@ -310,7 +310,7 @@ public static function getScript(string $locale)
*
* @throws MethodNotImplementedException
*/
public static function lookup(array $langtag, string $locale, bool $canonicalize = false, string $default = null)
public static function lookup(array $langtag, string $locale, bool $canonicalize = false, ?string $default = null)
{
throw new MethodNotImplementedException(__METHOD__);
}
Expand Down
4 changes: 2 additions & 2 deletions Locales.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions NumberFormatter/NumberFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ abstract class NumberFormatter
* @throws MethodArgumentValueNotImplementedException When the $style is not supported
* @throws MethodArgumentNotImplementedException When the pattern value is different than null
*/
public function __construct(?string $locale = 'en', int $style = null, string $pattern = null)
public function __construct(?string $locale = 'en', ?int $style = null, ?string $pattern = null)
{
if ('en' !== $locale && null !== $locale) {
throw new MethodArgumentValueNotImplementedException(__METHOD__, 'locale', $locale, 'Only the locale "en" is supported');
Expand Down Expand Up @@ -298,7 +298,7 @@ public function __construct(?string $locale = 'en', int $style = null, string $p
* @throws MethodArgumentValueNotImplementedException When the $style is not supported
* @throws MethodArgumentNotImplementedException When the pattern value is different than null
*/
public static function create(?string $locale = 'en', int $style = null, string $pattern = null)
public static function create(?string $locale = 'en', ?int $style = null, ?string $pattern = null)
{
return new static($locale, $style, $pattern);
}
Expand Down Expand Up @@ -495,7 +495,7 @@ public function getTextAttribute(int $attr)
*
* @throws MethodNotImplementedException
*/
public function parseCurrency(string $value, string &$currency, int &$position = null)
public function parseCurrency(string $value, string &$currency, ?int &$position = null)
{
throw new MethodNotImplementedException(__METHOD__);
}
Expand Down
4 changes: 2 additions & 2 deletions ResourceBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
final protected static function readEntry(array $indices, ?string $locale = null, bool $fallback = true)
{
if (null === self::$entryReader) {
self::$entryReader = new BundleEntryReader(new BufferedBundleReader(
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions Scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ 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);
}

/**
* @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);
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/NumberFormatter/AbstractNumberFormatterTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ public function testParseWithNotNullPositionValue()
/**
* @return NumberFormatter|\NumberFormatter
*/
abstract protected static function getNumberFormatter(string $locale = 'en', string $style = null, string $pattern = null);
abstract protected static function getNumberFormatter(string $locale = 'en', ?string $style = null, ?string $pattern = null);

abstract protected function getIntlErrorMessage(): string;

Expand All @@ -878,7 +878,7 @@ abstract protected function getIntlErrorCode(): int;
*/
abstract protected function isIntlFailure($errorCode): bool;

public static function throwOnWarning(int $errno, string $errstr, string $errfile = null, int $errline = null): bool
public static function throwOnWarning(int $errno, string $errstr, ?string $errfile = null, ?int $errline = null): bool
{
if ($errno & (\E_WARNING | \E_USER_WARNING)) {
throw new \ErrorException($errstr, 0, $errno, $errfile ?? __FILE__, $errline ?? __LINE__);
Expand Down
2 changes: 1 addition & 1 deletion Tests/NumberFormatter/NumberFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public function testSetTextAttribute()
$formatter->setTextAttribute(NumberFormatter::NEGATIVE_PREFIX, '-');
}

protected static function getNumberFormatter(?string $locale = 'en', string $style = null, string $pattern = null): NumberFormatter
protected static function getNumberFormatter(?string $locale = 'en', ?string $style = null, ?string $pattern = null): NumberFormatter
{
return new class($locale, $style, $pattern) extends NumberFormatter {
};
Expand Down
2 changes: 1 addition & 1 deletion Tests/NumberFormatter/Verification/NumberFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function testGetTextAttribute()
parent::testGetTextAttribute();
}

protected static function getNumberFormatter(?string $locale = 'en', string $style = null, string $pattern = null): \NumberFormatter
protected static function getNumberFormatter(?string $locale = 'en', ?string $style = null, ?string $pattern = null): \NumberFormatter
{
return new \NumberFormatter($locale, $style, $pattern);
}
Expand Down
8 changes: 4 additions & 4 deletions Timezones.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ 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);
}

/**
* @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);
}
Expand All @@ -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);
Expand Down

0 comments on commit 2fb503f

Please sign in to comment.