Skip to content

Commit afab7ff

Browse files
committed
remove error handler not needed on PHP 8
1 parent 3f6c023 commit afab7ff

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

AbstractString.php

+6-15
Original file line numberDiff line numberDiff line change
@@ -507,23 +507,14 @@ public function toByteString(string $toEncoding = null): ByteString
507507
return $b;
508508
}
509509

510-
set_error_handler(static fn ($t, $m) => throw new InvalidArgumentException($m));
511-
512510
try {
513-
try {
514-
$b->string = mb_convert_encoding($this->string, $toEncoding, 'UTF-8');
515-
} catch (InvalidArgumentException|\ValueError $e) {
516-
if (!\function_exists('iconv')) {
517-
if ($e instanceof \ValueError) {
518-
throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
519-
}
520-
throw $e;
521-
}
522-
523-
$b->string = iconv('UTF-8', $toEncoding, $this->string);
511+
$b->string = mb_convert_encoding($this->string, $toEncoding, 'UTF-8');
512+
} catch (\ValueError $e) {
513+
if (!\function_exists('iconv')) {
514+
throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
524515
}
525-
} finally {
526-
restore_error_handler();
516+
517+
$b->string = iconv('UTF-8', $toEncoding, $this->string);
527518
}
528519

529520
return $b;

0 commit comments

Comments
 (0)