Skip to content

Commit

Permalink
Merge branch '5.4' into 6.3
Browse files Browse the repository at this point in the history
* 5.4:
  Fix implicitly-required parameters
  List CS fix in .git-blame-ignore-revs
  Apply php-cs-fixer fix --rules nullable_type_declaration_for_default_null_value
  [Messenger][AmazonSqs] Allow async-aws/sqs version 2
  • Loading branch information
nicolas-grekas committed Jan 23, 2024
2 parents 8a8cd3f + c209c4d commit bce7504
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 @@ -383,7 +383,7 @@ public function isEmpty(): bool
return '' === $this->string;
}

abstract public function join(array $strings, string $lastGlue = null): static;
abstract public function join(array $strings, ?string $lastGlue = null): static;

public function jsonSerialize(): string
{
Expand Down Expand Up @@ -429,16 +429,16 @@ abstract public function replaceMatches(string $fromRegexp, string|callable $to)

abstract public function reverse(): static;

abstract public function slice(int $start = 0, int $length = null): static;
abstract public function slice(int $start = 0, ?int $length = null): static;

abstract public function snake(): static;

abstract public function splice(string $replacement, int $start = 0, int $length = null): static;
abstract public function splice(string $replacement, int $start = 0, ?int $length = null): static;

/**
* @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 @@ -495,7 +495,7 @@ public function startsWith(string|iterable $prefix): bool

abstract public function title(bool $allWords = false): static;

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 @@ -198,7 +198,7 @@ public function folded(bool $compat = true): static
return $str;
}

public function join(array $strings, string $lastGlue = null): static
public function join(array $strings, ?string $lastGlue = null): static
{
$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 @@ -205,7 +205,7 @@ public function isUtf8(): bool
return '' === $this->string || preg_match('//u', $this->string);
}

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

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

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

public function splice(string $replacement, int $start = 0, int $length = null): static
public function splice(string $replacement, int $start = 0, ?int $length = null): static
{
$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 ??= \PHP_INT_MAX) {
throw new InvalidArgumentException('Split limit must be a positive integer.');
Expand Down Expand Up @@ -402,12 +402,12 @@ public function title(bool $allWords = false): static
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 @@ -186,15 +186,15 @@ public function replace(string $from, string $to): static
return $str;
}

public function slice(int $start = 0, int $length = null): static
public function slice(int $start = 0, ?int $length = null): static
{
$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): static
public function splice(string $replacement, int $start = 0, ?int $length = null): static
{
if (!preg_match('//u', $replacement)) {
throw new InvalidArgumentException('Invalid UTF-8 string.');
Expand All @@ -208,7 +208,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 ??= \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 @@ -68,7 +68,7 @@ class AsciiSlugger implements SluggerInterface, LocaleAwareInterface
*/
private array $transliterators = [];

public function __construct(string $defaultLocale = null, array|\Closure $symbolsMap = null)
public function __construct(?string $defaultLocale = null, array|\Closure|null $symbolsMap = null)
{
$this->defaultLocale = $defaultLocale;
$this->symbolsMap = $symbolsMap ?? $this->symbolsMap;
Expand Down Expand Up @@ -104,7 +104,7 @@ public function withEmoji(bool|string $emoji = true): static
return $new;
}

public function slug(string $string, string $separator = '-', string $locale = null): AbstractUnicodeString
public function slug(string $string, string $separator = '-', ?string $locale = null): AbstractUnicodeString
{
$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 @@ -1081,7 +1081,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 @@ -1135,7 +1135,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 @@ -78,7 +78,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 @@ -19,7 +19,7 @@ class AsciiSluggerTest extends TestCase
/**
* @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 @@ -176,7 +176,7 @@ public function indexOfLast(string|iterable|AbstractString $needle, int $offset
return false === $i ? null : $i;
}

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

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

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

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

Expand All @@ -278,7 +278,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 ??= 2147483647) {
throw new InvalidArgumentException('Split limit must be a positive integer.');
Expand Down

0 comments on commit bce7504

Please sign in to comment.