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 aea0cc8 commit c209c4d
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 31 deletions.
10 changes: 5 additions & 5 deletions AbstractString.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ public function isEmpty(): bool
/**
* @return static
*/
abstract public function join(array $strings, string $lastGlue = null): self;
abstract public function join(array $strings, ?string $lastGlue = null): self;

public function jsonSerialize(): string
{
Expand Down Expand Up @@ -477,7 +477,7 @@ abstract public function reverse(): self;
/**
* @return static
*/
abstract public function slice(int $start = 0, int $length = null): self;
abstract public function slice(int $start = 0, ?int $length = null): self;

/**
* @return static
Expand All @@ -487,12 +487,12 @@ abstract public function snake(): self;
/**
* @return static
*/
abstract public function splice(string $replacement, int $start = 0, int $length = null): self;
abstract public function splice(string $replacement, int $start = 0, ?int $length = null): self;

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

public function toByteString(string $toEncoding = null): ByteString
public function toByteString(?string $toEncoding = null): ByteString
{
$b = new ByteString();

Expand Down
2 changes: 1 addition & 1 deletion AbstractUnicodeString.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public function folded(bool $compat = true): parent
return $str;
}

public function join(array $strings, string $lastGlue = null): parent
public function join(array $strings, ?string $lastGlue = null): parent
{
$str = clone $this;

Expand Down
14 changes: 7 additions & 7 deletions ByteString.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(string $string = '')
* Copyright (c) 2004-2020, Facebook, Inc. (https://www.facebook.com/)
*/

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

public function join(array $strings, string $lastGlue = null): parent
public function join(array $strings, ?string $lastGlue = null): parent
{
$str = clone $this;

Expand Down Expand Up @@ -356,7 +356,7 @@ public function reverse(): parent
return $str;
}

public function slice(int $start = 0, int $length = null): parent
public function slice(int $start = 0, ?int $length = null): parent
{
$str = clone $this;
$str->string = (string) substr($this->string, $start, $length ?? \PHP_INT_MAX);
Expand All @@ -372,15 +372,15 @@ public function snake(): parent
return $str;
}

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

return $str;
}

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

public function toUnicodeString(string $fromEncoding = null): UnicodeString
public function toUnicodeString(?string $fromEncoding = null): UnicodeString
{
return new UnicodeString($this->toCodePointString($fromEncoding)->string);
}

public function toCodePointString(string $fromEncoding = null): CodePointString
public function toCodePointString(?string $fromEncoding = null): CodePointString
{
$u = new CodePointString();

Expand Down
6 changes: 3 additions & 3 deletions CodePointString.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,15 @@ public function replace(string $from, string $to): AbstractString
return $str;
}

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

return $str;
}

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

public function split(string $delimiter, int $limit = null, int $flags = null): array
public function split(string $delimiter, ?int $limit = null, ?int $flags = null): array
{
if (1 > $limit = $limit ?? \PHP_INT_MAX) {
throw new InvalidArgumentException('Split limit must be a positive integer.');
Expand Down
4 changes: 2 additions & 2 deletions Slugger/AsciiSlugger.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class AsciiSlugger implements SluggerInterface, LocaleAwareInterface
/**
* @param array|\Closure|null $symbolsMap
*/
public function __construct(string $defaultLocale = null, $symbolsMap = null)
public function __construct(?string $defaultLocale = null, $symbolsMap = null)
{
if (null !== $symbolsMap && !\is_array($symbolsMap) && !$symbolsMap instanceof \Closure) {
throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be array, Closure or null, "%s" given.', __METHOD__, \gettype($symbolsMap)));
Expand Down Expand Up @@ -98,7 +98,7 @@ public function getLocale()
/**
* {@inheritdoc}
*/
public function slug(string $string, string $separator = '-', string $locale = null): AbstractUnicodeString
public function slug(string $string, string $separator = '-', ?string $locale = null): AbstractUnicodeString
{
$locale = $locale ?? $this->defaultLocale;

Expand Down
2 changes: 1 addition & 1 deletion Slugger/SluggerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ interface SluggerInterface
/**
* Creates a slug for the given string and locale, using appropriate transliteration when needed.
*/
public function slug(string $string, string $separator = '-', string $locale = null): AbstractUnicodeString;
public function slug(string $string, string $separator = '-', ?string $locale = null): AbstractUnicodeString;
}
12 changes: 6 additions & 6 deletions Tests/AbstractAsciiTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function testCreateFromEmptyString()
/**
* @dataProvider provideBytesAt
*/
public function testBytesAt(array $expected, string $string, int $offset, int $form = null)
public function testBytesAt(array $expected, string $string, int $offset, ?int $form = null)
{
if (2 !== grapheme_strlen('च्छे') && 'नमस्ते' === $string) {
$this->markTestSkipped('Skipping due to issue ICU-21661.');
Expand Down Expand Up @@ -319,7 +319,7 @@ public static function provideIndexOfLastIgnoreCase(): array
/**
* @dataProvider provideSplit
*/
public function testSplit(string $string, string $delimiter, array $chunks, ?int $limit, int $flags = null)
public function testSplit(string $string, string $delimiter, array $chunks, ?int $limit, ?int $flags = null)
{
$this->assertEquals($chunks, static::createFromString($string)->split($delimiter, $limit, $flags));
}
Expand Down Expand Up @@ -595,7 +595,7 @@ public static function provideTitle()
/**
* @dataProvider provideSlice
*/
public function testSlice(string $expected, string $origin, int $start, int $length = null)
public function testSlice(string $expected, string $origin, int $start, ?int $length = null)
{
$this->assertEquals(
static::createFromString($expected),
Expand Down Expand Up @@ -623,7 +623,7 @@ public static function provideSlice()
/**
* @dataProvider provideSplice
*/
public function testSplice(string $expected, int $start, int $length = null)
public function testSplice(string $expected, int $start, ?int $length = null)
{
$this->assertEquals(
static::createFromString($expected),
Expand Down Expand Up @@ -1083,7 +1083,7 @@ public static function provideSnake()
/**
* @dataProvider provideStartsWith
*/
public function testStartsWith(bool $expected, string $origin, $prefix, int $form = null)
public function testStartsWith(bool $expected, string $origin, $prefix, ?int $form = null)
{
$instance = static::createFromString($origin);
$instance = $form ? $instance->normalize($form) : $instance;
Expand Down Expand Up @@ -1137,7 +1137,7 @@ public static function provideStartsWithIgnoreCase()
/**
* @dataProvider provideEndsWith
*/
public function testEndsWith(bool $expected, string $origin, $suffix, int $form = null)
public function testEndsWith(bool $expected, string $origin, $suffix, ?int $form = null)
{
$instance = static::createFromString($origin);
$instance = $form ? $instance->normalize($form) : $instance;
Expand Down
2 changes: 1 addition & 1 deletion Tests/AbstractUnicodeTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static function provideBytesAt(): array
/**
* @dataProvider provideCodePointsAt
*/
public function testCodePointsAt(array $expected, string $string, int $offset, int $form = null)
public function testCodePointsAt(array $expected, string $string, int $offset, ?int $form = null)
{
if (2 !== grapheme_strlen('च्छे') && 'नमस्ते' === $string) {
$this->markTestSkipped('Skipping due to issue ICU-21661.');
Expand Down
2 changes: 1 addition & 1 deletion Tests/Slugger/AsciiSluggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static function provideSlugTests(): iterable
}

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

Expand Down
8 changes: 4 additions & 4 deletions UnicodeString.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public function indexOfLast($needle, int $offset = 0): ?int
return false === $i ? null : $i;
}

public function join(array $strings, string $lastGlue = null): AbstractString
public function join(array $strings, ?string $lastGlue = null): AbstractString
{
$str = parent::join($strings, $lastGlue);
normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string);
Expand Down Expand Up @@ -264,7 +264,7 @@ public function replaceMatches(string $fromRegexp, $to): AbstractString
return $str;
}

public function slice(int $start = 0, int $length = null): AbstractString
public function slice(int $start = 0, ?int $length = null): AbstractString
{
$str = clone $this;

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

public function splice(string $replacement, int $start = 0, int $length = null): AbstractString
public function splice(string $replacement, int $start = 0, ?int $length = null): AbstractString
{
$str = clone $this;

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

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

0 comments on commit c209c4d

Please sign in to comment.