Skip to content

Commit e8ef324

Browse files
author
Martin Brecht-Precht
committed
Added a missing validation.
1 parent 59e791f commit e8ef324

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/SimpleStringBuilder.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,9 @@ public function lastIndexOf($string, $offset = 0)
257257
$type = is_object($string) ? get_class($string) : gettype($string);
258258
throw new \InvalidArgumentException('Expected a scalar value. Got ' . $type . '.');
259259
}
260+
if (mb_strlen((string)$string) === 0) {
261+
throw new \InvalidArgumentException('Empty string is invalid.');
262+
}
260263
if (!is_int($offset)) {
261264
$type = is_object($offset) ? get_class($offset) : gettype($offset);
262265
throw new \InvalidArgumentException('Offset invalid. Expected integer. Got ' . $type . '.');

0 commit comments

Comments
 (0)