Skip to content

Commit c209c4d

Browse files
Apply php-cs-fixer fix --rules nullable_type_declaration_for_default_null_value
1 parent aea0cc8 commit c209c4d

10 files changed

+31
-31
lines changed

AbstractString.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ public function isEmpty(): bool
399399
/**
400400
* @return static
401401
*/
402-
abstract public function join(array $strings, string $lastGlue = null): self;
402+
abstract public function join(array $strings, ?string $lastGlue = null): self;
403403

404404
public function jsonSerialize(): string
405405
{
@@ -477,7 +477,7 @@ abstract public function reverse(): self;
477477
/**
478478
* @return static
479479
*/
480-
abstract public function slice(int $start = 0, int $length = null): self;
480+
abstract public function slice(int $start = 0, ?int $length = null): self;
481481

482482
/**
483483
* @return static
@@ -487,12 +487,12 @@ abstract public function snake(): self;
487487
/**
488488
* @return static
489489
*/
490-
abstract public function splice(string $replacement, int $start = 0, int $length = null): self;
490+
abstract public function splice(string $replacement, int $start = 0, ?int $length = null): self;
491491

492492
/**
493493
* @return static[]
494494
*/
495-
public function split(string $delimiter, int $limit = null, int $flags = null): array
495+
public function split(string $delimiter, ?int $limit = null, ?int $flags = null): array
496496
{
497497
if (null === $flags) {
498498
throw new \TypeError('Split behavior when $flags is null must be implemented by child classes.');
@@ -560,7 +560,7 @@ public function startsWith($prefix): bool
560560
*/
561561
abstract public function title(bool $allWords = false): self;
562562

563-
public function toByteString(string $toEncoding = null): ByteString
563+
public function toByteString(?string $toEncoding = null): ByteString
564564
{
565565
$b = new ByteString();
566566

AbstractUnicodeString.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ public function folded(bool $compat = true): parent
203203
return $str;
204204
}
205205

206-
public function join(array $strings, string $lastGlue = null): parent
206+
public function join(array $strings, ?string $lastGlue = null): parent
207207
{
208208
$str = clone $this;
209209

ByteString.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct(string $string = '')
4242
* Copyright (c) 2004-2020, Facebook, Inc. (https://www.facebook.com/)
4343
*/
4444

45-
public static function fromRandom(int $length = 16, string $alphabet = null): self
45+
public static function fromRandom(int $length = 16, ?string $alphabet = null): self
4646
{
4747
if ($length <= 0) {
4848
throw new InvalidArgumentException(sprintf('A strictly positive length is expected, "%d" given.', $length));
@@ -213,7 +213,7 @@ public function isUtf8(): bool
213213
return '' === $this->string || preg_match('//u', $this->string);
214214
}
215215

216-
public function join(array $strings, string $lastGlue = null): parent
216+
public function join(array $strings, ?string $lastGlue = null): parent
217217
{
218218
$str = clone $this;
219219

@@ -356,7 +356,7 @@ public function reverse(): parent
356356
return $str;
357357
}
358358

359-
public function slice(int $start = 0, int $length = null): parent
359+
public function slice(int $start = 0, ?int $length = null): parent
360360
{
361361
$str = clone $this;
362362
$str->string = (string) substr($this->string, $start, $length ?? \PHP_INT_MAX);
@@ -372,15 +372,15 @@ public function snake(): parent
372372
return $str;
373373
}
374374

375-
public function splice(string $replacement, int $start = 0, int $length = null): parent
375+
public function splice(string $replacement, int $start = 0, ?int $length = null): parent
376376
{
377377
$str = clone $this;
378378
$str->string = substr_replace($this->string, $replacement, $start, $length ?? \PHP_INT_MAX);
379379

380380
return $str;
381381
}
382382

383-
public function split(string $delimiter, int $limit = null, int $flags = null): array
383+
public function split(string $delimiter, ?int $limit = null, ?int $flags = null): array
384384
{
385385
if (1 > $limit = $limit ?? \PHP_INT_MAX) {
386386
throw new InvalidArgumentException('Split limit must be a positive integer.');
@@ -426,12 +426,12 @@ public function title(bool $allWords = false): parent
426426
return $str;
427427
}
428428

429-
public function toUnicodeString(string $fromEncoding = null): UnicodeString
429+
public function toUnicodeString(?string $fromEncoding = null): UnicodeString
430430
{
431431
return new UnicodeString($this->toCodePointString($fromEncoding)->string);
432432
}
433433

434-
public function toCodePointString(string $fromEncoding = null): CodePointString
434+
public function toCodePointString(?string $fromEncoding = null): CodePointString
435435
{
436436
$u = new CodePointString();
437437

CodePointString.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,15 +194,15 @@ public function replace(string $from, string $to): AbstractString
194194
return $str;
195195
}
196196

197-
public function slice(int $start = 0, int $length = null): AbstractString
197+
public function slice(int $start = 0, ?int $length = null): AbstractString
198198
{
199199
$str = clone $this;
200200
$str->string = mb_substr($this->string, $start, $length, 'UTF-8');
201201

202202
return $str;
203203
}
204204

205-
public function splice(string $replacement, int $start = 0, int $length = null): AbstractString
205+
public function splice(string $replacement, int $start = 0, ?int $length = null): AbstractString
206206
{
207207
if (!preg_match('//u', $replacement)) {
208208
throw new InvalidArgumentException('Invalid UTF-8 string.');
@@ -216,7 +216,7 @@ public function splice(string $replacement, int $start = 0, int $length = null):
216216
return $str;
217217
}
218218

219-
public function split(string $delimiter, int $limit = null, int $flags = null): array
219+
public function split(string $delimiter, ?int $limit = null, ?int $flags = null): array
220220
{
221221
if (1 > $limit = $limit ?? \PHP_INT_MAX) {
222222
throw new InvalidArgumentException('Split limit must be a positive integer.');

Slugger/AsciiSlugger.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class AsciiSlugger implements SluggerInterface, LocaleAwareInterface
6969
/**
7070
* @param array|\Closure|null $symbolsMap
7171
*/
72-
public function __construct(string $defaultLocale = null, $symbolsMap = null)
72+
public function __construct(?string $defaultLocale = null, $symbolsMap = null)
7373
{
7474
if (null !== $symbolsMap && !\is_array($symbolsMap) && !$symbolsMap instanceof \Closure) {
7575
throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be array, Closure or null, "%s" given.', __METHOD__, \gettype($symbolsMap)));
@@ -98,7 +98,7 @@ public function getLocale()
9898
/**
9999
* {@inheritdoc}
100100
*/
101-
public function slug(string $string, string $separator = '-', string $locale = null): AbstractUnicodeString
101+
public function slug(string $string, string $separator = '-', ?string $locale = null): AbstractUnicodeString
102102
{
103103
$locale = $locale ?? $this->defaultLocale;
104104

Slugger/SluggerInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ interface SluggerInterface
2323
/**
2424
* Creates a slug for the given string and locale, using appropriate transliteration when needed.
2525
*/
26-
public function slug(string $string, string $separator = '-', string $locale = null): AbstractUnicodeString;
26+
public function slug(string $string, string $separator = '-', ?string $locale = null): AbstractUnicodeString;
2727
}

Tests/AbstractAsciiTestCase.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function testCreateFromEmptyString()
4646
/**
4747
* @dataProvider provideBytesAt
4848
*/
49-
public function testBytesAt(array $expected, string $string, int $offset, int $form = null)
49+
public function testBytesAt(array $expected, string $string, int $offset, ?int $form = null)
5050
{
5151
if (2 !== grapheme_strlen('च्छे') && 'नमस्ते' === $string) {
5252
$this->markTestSkipped('Skipping due to issue ICU-21661.');
@@ -319,7 +319,7 @@ public static function provideIndexOfLastIgnoreCase(): array
319319
/**
320320
* @dataProvider provideSplit
321321
*/
322-
public function testSplit(string $string, string $delimiter, array $chunks, ?int $limit, int $flags = null)
322+
public function testSplit(string $string, string $delimiter, array $chunks, ?int $limit, ?int $flags = null)
323323
{
324324
$this->assertEquals($chunks, static::createFromString($string)->split($delimiter, $limit, $flags));
325325
}
@@ -595,7 +595,7 @@ public static function provideTitle()
595595
/**
596596
* @dataProvider provideSlice
597597
*/
598-
public function testSlice(string $expected, string $origin, int $start, int $length = null)
598+
public function testSlice(string $expected, string $origin, int $start, ?int $length = null)
599599
{
600600
$this->assertEquals(
601601
static::createFromString($expected),
@@ -623,7 +623,7 @@ public static function provideSlice()
623623
/**
624624
* @dataProvider provideSplice
625625
*/
626-
public function testSplice(string $expected, int $start, int $length = null)
626+
public function testSplice(string $expected, int $start, ?int $length = null)
627627
{
628628
$this->assertEquals(
629629
static::createFromString($expected),
@@ -1083,7 +1083,7 @@ public static function provideSnake()
10831083
/**
10841084
* @dataProvider provideStartsWith
10851085
*/
1086-
public function testStartsWith(bool $expected, string $origin, $prefix, int $form = null)
1086+
public function testStartsWith(bool $expected, string $origin, $prefix, ?int $form = null)
10871087
{
10881088
$instance = static::createFromString($origin);
10891089
$instance = $form ? $instance->normalize($form) : $instance;
@@ -1137,7 +1137,7 @@ public static function provideStartsWithIgnoreCase()
11371137
/**
11381138
* @dataProvider provideEndsWith
11391139
*/
1140-
public function testEndsWith(bool $expected, string $origin, $suffix, int $form = null)
1140+
public function testEndsWith(bool $expected, string $origin, $suffix, ?int $form = null)
11411141
{
11421142
$instance = static::createFromString($origin);
11431143
$instance = $form ? $instance->normalize($form) : $instance;

Tests/AbstractUnicodeTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public static function provideBytesAt(): array
8080
/**
8181
* @dataProvider provideCodePointsAt
8282
*/
83-
public function testCodePointsAt(array $expected, string $string, int $offset, int $form = null)
83+
public function testCodePointsAt(array $expected, string $string, int $offset, ?int $form = null)
8484
{
8585
if (2 !== grapheme_strlen('च्छे') && 'नमस्ते' === $string) {
8686
$this->markTestSkipped('Skipping due to issue ICU-21661.');

Tests/Slugger/AsciiSluggerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public static function provideSlugTests(): iterable
3838
}
3939

4040
/** @dataProvider provideSlugTests */
41-
public function testSlug(string $expected, string $string, string $separator = '-', string $locale = null)
41+
public function testSlug(string $expected, string $string, string $separator = '-', ?string $locale = null)
4242
{
4343
$slugger = new AsciiSlugger();
4444

UnicodeString.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public function indexOfLast($needle, int $offset = 0): ?int
184184
return false === $i ? null : $i;
185185
}
186186

187-
public function join(array $strings, string $lastGlue = null): AbstractString
187+
public function join(array $strings, ?string $lastGlue = null): AbstractString
188188
{
189189
$str = parent::join($strings, $lastGlue);
190190
normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string);
@@ -264,7 +264,7 @@ public function replaceMatches(string $fromRegexp, $to): AbstractString
264264
return $str;
265265
}
266266

267-
public function slice(int $start = 0, int $length = null): AbstractString
267+
public function slice(int $start = 0, ?int $length = null): AbstractString
268268
{
269269
$str = clone $this;
270270

@@ -276,7 +276,7 @@ public function slice(int $start = 0, int $length = null): AbstractString
276276
return $str;
277277
}
278278

279-
public function splice(string $replacement, int $start = 0, int $length = null): AbstractString
279+
public function splice(string $replacement, int $start = 0, ?int $length = null): AbstractString
280280
{
281281
$str = clone $this;
282282

@@ -295,7 +295,7 @@ public function splice(string $replacement, int $start = 0, int $length = null):
295295
return $str;
296296
}
297297

298-
public function split(string $delimiter, int $limit = null, int $flags = null): array
298+
public function split(string $delimiter, ?int $limit = null, ?int $flags = null): array
299299
{
300300
if (1 > $limit = $limit ?? 2147483647) {
301301
throw new InvalidArgumentException('Split limit must be a positive integer.');

0 commit comments

Comments
 (0)