Skip to content

Commit

Permalink
Fix warning "PHP Deprecated: mb_convert_encoding(): Handling HTML ent…
Browse files Browse the repository at this point in the history
…ities via mbstring is deprecated"
  • Loading branch information
Imangazaliev committed Mar 5, 2023
1 parent cc8ec6e commit 50fa659
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ jobs:
dist: focal
php: 8.1

- language: php
dist: jammy
php: 8.2

before_script:
- composer self-update
- composer install
Expand Down
3 changes: 2 additions & 1 deletion src/DiDom/Encoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class Encoder
*/
public static function convertToHtmlEntities(string $string, string $encoding): string
{
if (function_exists('mb_convert_encoding')) {
// handling HTML entities via mbstring is deprecated in PHP 8.2
if (function_exists('mb_convert_encoding') && PHP_VERSION_ID < 80200) {
return mb_convert_encoding($string, 'HTML-ENTITIES', $encoding);
}

Expand Down

0 comments on commit 50fa659

Please sign in to comment.