Skip to content

Commit

Permalink
Merge branch '5.1' into 5.x
Browse files Browse the repository at this point in the history
* 5.1:
  Remove "version" from composer.json files, use "branch-version" instead
  [String] fix "is too large" ValueError on PHP 8
  • Loading branch information
nicolas-grekas committed Oct 13, 2020
2 parents f6b50e4 + 615bde9 commit de97fc5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 4 additions & 4 deletions UnicodeString.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public function slice(int $start = 0, int $length = null): AbstractString
{
$str = clone $this;
try {
$str->string = (string) grapheme_substr($this->string, $start, $length ?? \PHP_INT_MAX);
$str->string = (string) grapheme_substr($this->string, $start, $length ?? 2147483647);
} catch (\ValueError $e) {
$str->string = '';
}
Expand All @@ -280,8 +280,8 @@ public function splice(string $replacement, int $start = 0, int $length = null):
{
$str = clone $this;
$start = $start ? \strlen(grapheme_substr($this->string, 0, $start)) : 0;
$length = $length ? \strlen(grapheme_substr($this->string, $start, $length ?? \PHP_INT_MAX)) : $length;
$str->string = substr_replace($this->string, $replacement, $start, $length ?? \PHP_INT_MAX);
$length = $length ? \strlen(grapheme_substr($this->string, $start, $length ?? 2147483647)) : $length;
$str->string = substr_replace($this->string, $replacement, $start, $length ?? 2147483647);
normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string);

if (false === $str->string) {
Expand All @@ -293,7 +293,7 @@ public function splice(string $replacement, int $start = 0, int $length = null):

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

Expand Down
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,7 @@
]
},
"minimum-stability": "dev",
"version": "5.2.x-dev"
"extra": {
"branch-version": "5.2-dev"
}
}

0 comments on commit de97fc5

Please sign in to comment.