[String] fix beforeLast/afterLast

This commit is contained in:
Gregor Harlan 2019-10-01 20:07:29 +02:00
parent c75098ed37
commit 80b4f81ebf
No known key found for this signature in database
GPG Key ID: A43C725D9D2AE675
2 changed files with 3 additions and 2 deletions

View File

@ -139,7 +139,7 @@ abstract class AbstractString implements \JsonSerializable
$n = (string) $n;
$j = $this->indexOfLast($n, $offset);
if (null !== $j && $j > $i) {
if (null !== $j && $j >= $i) {
$i = $offset = $j;
$str->string = $n;
}
@ -208,7 +208,7 @@ abstract class AbstractString implements \JsonSerializable
$n = (string) $n;
$j = $this->indexOfLast($n, $offset);
if (null !== $j && $j > $i) {
if (null !== $j && $j >= $i) {
$i = $offset = $j;
$str->string = $n;
}

View File

@ -711,6 +711,7 @@ abstract class AbstractAsciiTestCase extends TestCase
['orld', 'o', 'hello world', 0, false],
['abacab', 'ab', 'abacabab', 1, true],
['ab', 'ab', 'abacabab', 1, false],
['hello world', 'hello', 'hello world', 0, false],
];
}