Skip to content

Commit 82a2cb8

Browse files
committed
Merge branch '5.1' into master
* 5.1: fix merge [Cache] fix previous PR add mising sr (latn & cyrl) translations [Cache] fix ProxyAdapter not persisting items with infinite expiration [HttpClient] fail properly when the server replies with HTTP/0.9 Fix CS [Cache] Limit cache version character range [Mailer] Fixed Mailgun API bridge JsonException when API response is not applicaton/json [String] improve fix fix tests [DI] dump OS-indepent paths in the compiled container [DI] dump OS-indepent paths in the preload file Run postgres setup trigger in transaction allow consumers to mock all methods
2 parents 497c62c + d732ad8 commit 82a2cb8

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

UnicodeString.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,12 @@ public function indexOf($needle, int $offset = 0): ?int
143143
return null;
144144
}
145145

146-
if ($this->length() <= $offset) {
146+
try {
147+
$i = $this->ignoreCase ? grapheme_stripos($this->string, $needle, $offset) : grapheme_strpos($this->string, $needle, $offset);
148+
} catch (\ValueError $e) {
147149
return null;
148150
}
149151

150-
$i = $this->ignoreCase ? grapheme_stripos($this->string, $needle, $offset) : grapheme_strpos($this->string, $needle, $offset);
151-
152152
return false === $i ? null : $i;
153153
}
154154

@@ -266,12 +266,12 @@ public function replaceMatches(string $fromRegexp, $to): AbstractString
266266

267267
public function slice(int $start = 0, int $length = null): AbstractString
268268
{
269-
if ($this->length() <= $start) {
270-
return new self();
271-
}
272-
273269
$str = clone $this;
274-
$str->string = (string) grapheme_substr($this->string, $start, $length ?? \PHP_INT_MAX);
270+
try {
271+
$str->string = (string) grapheme_substr($this->string, $start, $length ?? \PHP_INT_MAX);
272+
} catch (\ValueError $e) {
273+
$str->string = '';
274+
}
275275

276276
return $str;
277277
}

0 commit comments

Comments
 (0)