Skip to content

Commit 2fb503f

Browse files
Apply php-cs-fixer fix --rules nullable_type_declaration_for_default_null_value
1 parent cd6cce1 commit 2fb503f

23 files changed

+50
-50
lines changed

Countries.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public static function alpha3CodeExists(string $alpha3Code): bool
8989
*
9090
* @throws MissingResourceException if the country code does not exist
9191
*/
92-
public static function getName(string $country, string $displayLocale = null): string
92+
public static function getName(string $country, ?string $displayLocale = null): string
9393
{
9494
return self::readEntry(['Names', $country], $displayLocale);
9595
}
@@ -99,7 +99,7 @@ public static function getName(string $country, string $displayLocale = null): s
9999
*
100100
* @throws MissingResourceException if the country code does not exist
101101
*/
102-
public static function getAlpha3Name(string $alpha3Code, string $displayLocale = null): string
102+
public static function getAlpha3Name(string $alpha3Code, ?string $displayLocale = null): string
103103
{
104104
return self::getName(self::getAlpha2Code($alpha3Code), $displayLocale);
105105
}
@@ -109,7 +109,7 @@ public static function getAlpha3Name(string $alpha3Code, string $displayLocale =
109109
*
110110
* @return array<string, string>
111111
*/
112-
public static function getNames(string $displayLocale = null): array
112+
public static function getNames(?string $displayLocale = null): array
113113
{
114114
return self::asort(self::readEntry(['Names'], $displayLocale), $displayLocale);
115115
}
@@ -121,7 +121,7 @@ public static function getNames(string $displayLocale = null): array
121121
*
122122
* @return array<string, string>
123123
*/
124-
public static function getAlpha3Names(string $displayLocale = null): array
124+
public static function getAlpha3Names(?string $displayLocale = null): array
125125
{
126126
$alpha2Names = self::getNames($displayLocale);
127127
$alpha3Names = [];

Currencies.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ public static function exists(string $currency): bool
5050
/**
5151
* @throws MissingResourceException if the currency code does not exist
5252
*/
53-
public static function getName(string $currency, string $displayLocale = null): string
53+
public static function getName(string $currency, ?string $displayLocale = null): string
5454
{
5555
return self::readEntry(['Names', $currency, self::INDEX_NAME], $displayLocale);
5656
}
5757

5858
/**
5959
* @return string[]
6060
*/
61-
public static function getNames(string $displayLocale = null): array
61+
public static function getNames(?string $displayLocale = null): array
6262
{
6363
// ====================================================================
6464
// For reference: It is NOT possible to return names indexed by
@@ -82,7 +82,7 @@ public static function getNames(string $displayLocale = null): array
8282
/**
8383
* @throws MissingResourceException if the currency code does not exist
8484
*/
85-
public static function getSymbol(string $currency, string $displayLocale = null): string
85+
public static function getSymbol(string $currency, ?string $displayLocale = null): string
8686
{
8787
return self::readEntry(['Names', $currency, self::INDEX_SYMBOL], $displayLocale);
8888
}

Data/Generator/TimezoneDataGenerator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ private function generateZones(BundleEntryReaderInterface $reader, string $tempD
177177

178178
$regionFormat = $reader->readEntry($tempDir, $locale, ['zoneStrings', 'regionFormat']);
179179
$fallbackFormat = $reader->readEntry($tempDir, $locale, ['zoneStrings', 'fallbackFormat']);
180-
$resolveName = function (string $id, string $city = null) use ($reader, $tempDir, $locale, $regionFormat, $fallbackFormat): ?string {
180+
$resolveName = function (string $id, ?string $city = null) use ($reader, $tempDir, $locale, $regionFormat, $fallbackFormat): ?string {
181181
// Resolve default name as described per http://cldr.unicode.org/translation/timezones
182182
if (isset($this->zoneToCountryMapping[$id])) {
183183
try {

DateFormatter/DateFormat/Hour1200Transformer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function format(\DateTime $dateTime, int $length): string
3636
/**
3737
* {@inheritdoc}
3838
*/
39-
public function normalizeHour(int $hour, string $marker = null): int
39+
public function normalizeHour(int $hour, ?string $marker = null): int
4040
{
4141
if ('PM' === $marker) {
4242
$hour += 12;

DateFormatter/DateFormat/Hour1201Transformer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function format(\DateTime $dateTime, int $length): string
3333
/**
3434
* {@inheritdoc}
3535
*/
36-
public function normalizeHour(int $hour, string $marker = null): int
36+
public function normalizeHour(int $hour, ?string $marker = null): int
3737
{
3838
if ('PM' !== $marker && 12 === $hour) {
3939
$hour = 0;

DateFormatter/DateFormat/Hour2400Transformer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function format(\DateTime $dateTime, int $length): string
3333
/**
3434
* {@inheritdoc}
3535
*/
36-
public function normalizeHour(int $hour, string $marker = null): int
36+
public function normalizeHour(int $hour, ?string $marker = null): int
3737
{
3838
if ('AM' === $marker) {
3939
$hour = 0;

DateFormatter/DateFormat/Hour2401Transformer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function format(\DateTime $dateTime, int $length): string
3636
/**
3737
* {@inheritdoc}
3838
*/
39-
public function normalizeHour(int $hour, string $marker = null): int
39+
public function normalizeHour(int $hour, ?string $marker = null): int
4040
{
4141
if ((null === $marker && 24 === $hour) || 'AM' === $marker) {
4242
$hour = 0;

DateFormatter/DateFormat/HourTransformer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ abstract class HourTransformer extends Transformer
3030
*
3131
* @return int The normalized hour value
3232
*/
33-
abstract public function normalizeHour(int $hour, string $marker = null): int;
33+
abstract public function normalizeHour(int $hour, ?string $marker = null): int;
3434
}

DateFormatter/IntlDateFormatter.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ abstract class IntlDateFormatter
134134
* @throws MethodArgumentValueNotImplementedException When $locale different than "en" or null is passed
135135
* @throws MethodArgumentValueNotImplementedException When $calendar different than GREGORIAN is passed
136136
*/
137-
public function __construct(?string $locale, ?int $datetype, ?int $timetype, $timezone = null, ?int $calendar = self::GREGORIAN, string $pattern = null)
137+
public function __construct(?string $locale, ?int $datetype, ?int $timetype, $timezone = null, ?int $calendar = self::GREGORIAN, ?string $pattern = null)
138138
{
139139
if ('en' !== $locale && null !== $locale) {
140140
throw new MethodArgumentValueNotImplementedException(__METHOD__, 'locale', $locale, 'Only the locale "en" is supported');
@@ -174,7 +174,7 @@ public function __construct(?string $locale, ?int $datetype, ?int $timetype, $ti
174174
* @throws MethodArgumentValueNotImplementedException When $locale different than "en" or null is passed
175175
* @throws MethodArgumentValueNotImplementedException When $calendar different than GREGORIAN is passed
176176
*/
177-
public static function create(?string $locale, ?int $datetype, ?int $timetype, $timezone = null, int $calendar = self::GREGORIAN, string $pattern = null)
177+
public static function create(?string $locale, ?int $datetype, ?int $timetype, $timezone = null, int $calendar = self::GREGORIAN, ?string $pattern = null)
178178
{
179179
return new static($locale, $datetype, $timetype, $timezone, $calendar, $pattern);
180180
}
@@ -244,7 +244,7 @@ public function format($timestamp)
244244
*
245245
* @throws MethodNotImplementedException
246246
*/
247-
public static function formatObject(object $object, $format = null, string $locale = null)
247+
public static function formatObject(object $object, $format = null, ?string $locale = null)
248248
{
249249
throw new MethodNotImplementedException(__METHOD__);
250250
}
@@ -430,7 +430,7 @@ public function localtime(string $value, int &$position = 0)
430430
*
431431
* @throws MethodArgumentNotImplementedException When $position different than null, behavior not implemented
432432
*/
433-
public function parse(string $value, int &$position = null)
433+
public function parse(string $value, ?int &$position = null)
434434
{
435435
// We don't calculate the position when parsing the value
436436
if (null !== $position) {

Languages.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public static function exists(string $language): bool
5656
*
5757
* @throws MissingResourceException if the language code does not exist
5858
*/
59-
public static function getName(string $language, string $displayLocale = null): string
59+
public static function getName(string $language, ?string $displayLocale = null): string
6060
{
6161
try {
6262
return self::readEntry(['Names', $language], $displayLocale);
@@ -78,7 +78,7 @@ public static function getName(string $language, string $displayLocale = null):
7878
*
7979
* @return array<string, string>
8080
*/
81-
public static function getNames(string $displayLocale = null): array
81+
public static function getNames(?string $displayLocale = null): array
8282
{
8383
return self::asort(self::readEntry(['Names'], $displayLocale), $displayLocale);
8484
}
@@ -139,7 +139,7 @@ public static function alpha3CodeExists(string $language): bool
139139
*
140140
* @throws MissingResourceException if the country code does not exists
141141
*/
142-
public static function getAlpha3Name(string $language, string $displayLocale = null): string
142+
public static function getAlpha3Name(string $language, ?string $displayLocale = null): string
143143
{
144144
try {
145145
return self::getName(self::getAlpha2Code($language), $displayLocale);
@@ -159,7 +159,7 @@ public static function getAlpha3Name(string $language, string $displayLocale = n
159159
*
160160
* @return array<string, string>
161161
*/
162-
public static function getAlpha3Names(string $displayLocale = null): array
162+
public static function getAlpha3Names(?string $displayLocale = null): array
163163
{
164164
$alpha2Names = self::getNames($displayLocale);
165165
$alpha3Names = [];

Locale/Locale.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public static function getDefault()
161161
*
162162
* @throws MethodNotImplementedException
163163
*/
164-
public static function getDisplayLanguage(string $locale, string $inLocale = null)
164+
public static function getDisplayLanguage(string $locale, ?string $inLocale = null)
165165
{
166166
throw new MethodNotImplementedException(__METHOD__);
167167
}
@@ -178,7 +178,7 @@ public static function getDisplayLanguage(string $locale, string $inLocale = nul
178178
*
179179
* @throws MethodNotImplementedException
180180
*/
181-
public static function getDisplayName(string $locale, string $inLocale = null)
181+
public static function getDisplayName(string $locale, ?string $inLocale = null)
182182
{
183183
throw new MethodNotImplementedException(__METHOD__);
184184
}
@@ -195,7 +195,7 @@ public static function getDisplayName(string $locale, string $inLocale = null)
195195
*
196196
* @throws MethodNotImplementedException
197197
*/
198-
public static function getDisplayRegion(string $locale, string $inLocale = null)
198+
public static function getDisplayRegion(string $locale, ?string $inLocale = null)
199199
{
200200
throw new MethodNotImplementedException(__METHOD__);
201201
}
@@ -212,7 +212,7 @@ public static function getDisplayRegion(string $locale, string $inLocale = null)
212212
*
213213
* @throws MethodNotImplementedException
214214
*/
215-
public static function getDisplayScript(string $locale, string $inLocale = null)
215+
public static function getDisplayScript(string $locale, ?string $inLocale = null)
216216
{
217217
throw new MethodNotImplementedException(__METHOD__);
218218
}
@@ -229,7 +229,7 @@ public static function getDisplayScript(string $locale, string $inLocale = null)
229229
*
230230
* @throws MethodNotImplementedException
231231
*/
232-
public static function getDisplayVariant(string $locale, string $inLocale = null)
232+
public static function getDisplayVariant(string $locale, ?string $inLocale = null)
233233
{
234234
throw new MethodNotImplementedException(__METHOD__);
235235
}
@@ -310,7 +310,7 @@ public static function getScript(string $locale)
310310
*
311311
* @throws MethodNotImplementedException
312312
*/
313-
public static function lookup(array $langtag, string $locale, bool $canonicalize = false, string $default = null)
313+
public static function lookup(array $langtag, string $locale, bool $canonicalize = false, ?string $default = null)
314314
{
315315
throw new MethodNotImplementedException(__METHOD__);
316316
}

Locales.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static function exists(string $locale): bool
5151
/**
5252
* @throws MissingResourceException if the locale does not exist
5353
*/
54-
public static function getName(string $locale, string $displayLocale = null): string
54+
public static function getName(string $locale, ?string $displayLocale = null): string
5555
{
5656
try {
5757
return self::readEntry(['Names', $locale], $displayLocale);
@@ -67,7 +67,7 @@ public static function getName(string $locale, string $displayLocale = null): st
6767
/**
6868
* @return string[]
6969
*/
70-
public static function getNames(string $displayLocale = null): array
70+
public static function getNames(?string $displayLocale = null): array
7171
{
7272
return self::asort(self::readEntry(['Names'], $displayLocale), $displayLocale);
7373
}

NumberFormatter/NumberFormatter.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ abstract class NumberFormatter
259259
* @throws MethodArgumentValueNotImplementedException When the $style is not supported
260260
* @throws MethodArgumentNotImplementedException When the pattern value is different than null
261261
*/
262-
public function __construct(?string $locale = 'en', int $style = null, string $pattern = null)
262+
public function __construct(?string $locale = 'en', ?int $style = null, ?string $pattern = null)
263263
{
264264
if ('en' !== $locale && null !== $locale) {
265265
throw new MethodArgumentValueNotImplementedException(__METHOD__, 'locale', $locale, 'Only the locale "en" is supported');
@@ -298,7 +298,7 @@ public function __construct(?string $locale = 'en', int $style = null, string $p
298298
* @throws MethodArgumentValueNotImplementedException When the $style is not supported
299299
* @throws MethodArgumentNotImplementedException When the pattern value is different than null
300300
*/
301-
public static function create(?string $locale = 'en', int $style = null, string $pattern = null)
301+
public static function create(?string $locale = 'en', ?int $style = null, ?string $pattern = null)
302302
{
303303
return new static($locale, $style, $pattern);
304304
}
@@ -495,7 +495,7 @@ public function getTextAttribute(int $attr)
495495
*
496496
* @throws MethodNotImplementedException
497497
*/
498-
public function parseCurrency(string $value, string &$currency, int &$position = null)
498+
public function parseCurrency(string $value, string &$currency, ?int &$position = null)
499499
{
500500
throw new MethodNotImplementedException(__METHOD__);
501501
}

ResourceBundle.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ abstract protected static function getPath(): string;
4343
* @return mixed returns an array or {@link \ArrayAccess} instance for
4444
* complex data and a scalar value for simple data
4545
*/
46-
final protected static function readEntry(array $indices, string $locale = null, bool $fallback = true)
46+
final protected static function readEntry(array $indices, ?string $locale = null, bool $fallback = true)
4747
{
4848
if (null === self::$entryReader) {
4949
self::$entryReader = new BundleEntryReader(new BufferedBundleReader(
@@ -58,7 +58,7 @@ final protected static function readEntry(array $indices, string $locale = null,
5858
return self::$entryReader->readEntry(static::getPath(), $locale ?? \Locale::getDefault(), $indices, $fallback);
5959
}
6060

61-
final protected static function asort(iterable $list, string $locale = null): array
61+
final protected static function asort(iterable $list, ?string $locale = null): array
6262
{
6363
if ($list instanceof \Traversable) {
6464
$list = iterator_to_array($list);

Scripts.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ public static function exists(string $script): bool
4343
/**
4444
* @throws MissingResourceException if the script code does not exist
4545
*/
46-
public static function getName(string $script, string $displayLocale = null): string
46+
public static function getName(string $script, ?string $displayLocale = null): string
4747
{
4848
return self::readEntry(['Names', $script], $displayLocale);
4949
}
5050

5151
/**
5252
* @return string[]
5353
*/
54-
public static function getNames(string $displayLocale = null): array
54+
public static function getNames(?string $displayLocale = null): array
5555
{
5656
return self::asort(self::readEntry(['Names'], $displayLocale), $displayLocale);
5757
}

Tests/NumberFormatter/AbstractNumberFormatterTestCase.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ public function testParseWithNotNullPositionValue()
867867
/**
868868
* @return NumberFormatter|\NumberFormatter
869869
*/
870-
abstract protected static function getNumberFormatter(string $locale = 'en', string $style = null, string $pattern = null);
870+
abstract protected static function getNumberFormatter(string $locale = 'en', ?string $style = null, ?string $pattern = null);
871871

872872
abstract protected function getIntlErrorMessage(): string;
873873

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

881-
public static function throwOnWarning(int $errno, string $errstr, string $errfile = null, int $errline = null): bool
881+
public static function throwOnWarning(int $errno, string $errstr, ?string $errfile = null, ?int $errline = null): bool
882882
{
883883
if ($errno & (\E_WARNING | \E_USER_WARNING)) {
884884
throw new \ErrorException($errstr, 0, $errno, $errfile ?? __FILE__, $errline ?? __LINE__);

Tests/NumberFormatter/NumberFormatterTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public function testSetTextAttribute()
171171
$formatter->setTextAttribute(NumberFormatter::NEGATIVE_PREFIX, '-');
172172
}
173173

174-
protected static function getNumberFormatter(?string $locale = 'en', string $style = null, string $pattern = null): NumberFormatter
174+
protected static function getNumberFormatter(?string $locale = 'en', ?string $style = null, ?string $pattern = null): NumberFormatter
175175
{
176176
return new class($locale, $style, $pattern) extends NumberFormatter {
177177
};

Tests/NumberFormatter/Verification/NumberFormatterTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function testGetTextAttribute()
3939
parent::testGetTextAttribute();
4040
}
4141

42-
protected static function getNumberFormatter(?string $locale = 'en', string $style = null, string $pattern = null): \NumberFormatter
42+
protected static function getNumberFormatter(?string $locale = 'en', ?string $style = null, ?string $pattern = null): \NumberFormatter
4343
{
4444
return new \NumberFormatter($locale, $style, $pattern);
4545
}

Timezones.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ public static function exists(string $timezone): bool
4949
/**
5050
* @throws MissingResourceException if the timezone identifier does not exist or is an alias
5151
*/
52-
public static function getName(string $timezone, string $displayLocale = null): string
52+
public static function getName(string $timezone, ?string $displayLocale = null): string
5353
{
5454
return self::readEntry(['Names', $timezone], $displayLocale);
5555
}
5656

5757
/**
5858
* @return string[]
5959
*/
60-
public static function getNames(string $displayLocale = null): array
60+
public static function getNames(?string $displayLocale = null): array
6161
{
6262
return self::asort(self::readEntry(['Names'], $displayLocale), $displayLocale);
6363
}
@@ -66,14 +66,14 @@ public static function getNames(string $displayLocale = null): array
6666
* @throws \Exception if the timezone identifier does not exist
6767
* @throws RuntimeException if there's no timezone DST transition information available
6868
*/
69-
public static function getRawOffset(string $timezone, int $timestamp = null): int
69+
public static function getRawOffset(string $timezone, ?int $timestamp = null): int
7070
{
7171
$dateTimeImmutable = new \DateTimeImmutable(date('Y-m-d H:i:s', $timestamp ?? time()), new \DateTimeZone($timezone));
7272

7373
return $dateTimeImmutable->getOffset();
7474
}
7575

76-
public static function getGmtOffset(string $timezone, int $timestamp = null, string $displayLocale = null): string
76+
public static function getGmtOffset(string $timezone, ?int $timestamp = null, ?string $displayLocale = null): string
7777
{
7878
$offset = self::getRawOffset($timezone, $timestamp);
7979
$abs = abs($offset);

0 commit comments

Comments
 (0)