Skip to content

Commit b791f12

Browse files
authored
Merge pull request #560 from uzulla/fix-wrong-handling
fix: wrong mb_encoding_aliases() handling for PHP 8.0+
2 parents 86b2177 + 7b56403 commit b791f12

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Document.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ private function getValidEncoding(?string $encoding): ?string
7474
} else {
7575
// PHP 8.0+: ValueError exception is thrown for invalid/empty encoding
7676
try {
77-
$aliases = mb_encoding_aliases($encoding ?? '');
78-
// Check if aliases array is not empty (valid encoding should have at least one alias)
79-
return !empty($aliases) ? $encoding : null;
77+
mb_encoding_aliases($encoding ?? '');
78+
// If mb_encoding_aliases succeeds, return the input value as is. Some encodings do not have aliases.
79+
return $encoding;
8080
} catch (\ValueError $exception) {
8181
return null;
8282
}

0 commit comments

Comments
 (0)