Skip to content

Commit f1e8ad7

Browse files
Remove needless TypeErrors
1 parent cb329fb commit f1e8ad7

File tree

2 files changed

+1
-13
lines changed

2 files changed

+1
-13
lines changed

AbstractUnicodeString.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,6 @@ public function replaceMatches(string $fromRegexp, string|callable $to): static
304304
}
305305

306306
if (\is_array($to) || $to instanceof \Closure) {
307-
if (!\is_callable($to)) {
308-
throw new \TypeError(sprintf('Argument 2 passed to "%s::replaceMatches()" must be callable, array given.', static::class));
309-
}
310-
311307
$replace = 'preg_replace_callback';
312308
$to = static function (array $m) use ($to): string {
313309
$to = $to($m);

ByteString.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -303,15 +303,7 @@ public function replaceMatches(string $fromRegexp, string|callable $to): static
303303
$fromRegexp .= 'i';
304304
}
305305

306-
if (\is_array($to)) {
307-
if (!\is_callable($to)) {
308-
throw new \TypeError(sprintf('Argument 2 passed to "%s::replaceMatches()" must be callable, array given.', static::class));
309-
}
310-
311-
$replace = 'preg_replace_callback';
312-
} else {
313-
$replace = $to instanceof \Closure ? 'preg_replace_callback' : 'preg_replace';
314-
}
306+
$replace = \is_array($to) || $to instanceof \Closure ? 'preg_replace_callback' : 'preg_replace';
315307

316308
set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
317309

0 commit comments

Comments
 (0)