Skip to content

Commit b559fbb

Browse files
committed
#624: Provide PHP 8.1 compatibility
1 parent f401d85 commit b559fbb

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"sort-packages": true
2424
},
2525
"require": {
26-
"php": "^7.2 || ^8.0 <8.1",
26+
"php": "^7.2 || ^8.0",
2727
"ext-fileinfo": "*",
2828
"ext-iconv": "*",
2929
"ext-imap": "*",

src/PhpImap/Mailbox.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -453,13 +453,7 @@ public function hasImapStream(): bool
453453
*/
454454
public function encodeStringToUtf7Imap(string $str): string
455455
{
456-
$out = \mb_convert_encoding($str, 'UTF7-IMAP', \mb_detect_encoding($str, 'UTF-8, ISO-8859-1, ISO-8859-15', true));
457-
458-
if (!\is_string($out)) {
459-
throw new UnexpectedValueException('mb_convert_encoding($str, \'UTF-8\', {detected}) could not convert $str');
460-
}
461-
462-
return $out;
456+
return imap_utf7_encode($str);
463457
}
464458

465459
/**
@@ -469,7 +463,7 @@ public function encodeStringToUtf7Imap(string $str): string
469463
*/
470464
public function decodeStringFromUtf7ImapToUtf8(string $str): string
471465
{
472-
$out = \mb_convert_encoding($str, 'UTF-8', 'UTF7-IMAP');
466+
$out = imap_utf7_decode($str);
473467

474468
if (!\is_string($out)) {
475469
throw new UnexpectedValueException('mb_convert_encoding($str, \'UTF-8\', \'UTF7-IMAP\') could not convert $str');

0 commit comments

Comments
 (0)