From 5c578680d40d2f9ad1f4ff6493dd61aef565d7a6 Mon Sep 17 00:00:00 2001 From: Filippo Tessarotto Date: Fri, 30 Apr 2021 09:27:44 +0200 Subject: [PATCH] Fix PHP 8 error: `Function libxml_disable_entity_loader() is deprecated` Signed-off-by: Filippo Tessarotto --- .github/workflows/php.yml | 1 + src/DOMDocumentFactory.php | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index f743917..c7e1089 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -21,6 +21,7 @@ jobs: uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php with: php-version: ${{ matrix.php-versions }} + ini-values: error_reporting=E_ALL extensions: mbstring, xml tools: composer:v2 coverage: pcov diff --git a/src/DOMDocumentFactory.php b/src/DOMDocumentFactory.php index fe25eb0..a953014 100644 --- a/src/DOMDocumentFactory.php +++ b/src/DOMDocumentFactory.php @@ -33,7 +33,9 @@ public static function fromString(string $xml): DOMDocument { Assert::stringNotEmpty(trim($xml)); - $entityLoader = libxml_disable_entity_loader(true); + if (\PHP_VERSION_ID < 80000) { + $entityLoader = libxml_disable_entity_loader(true); + } $internalErrors = libxml_use_internal_errors(true); libxml_clear_errors(); @@ -46,7 +48,9 @@ public static function fromString(string $xml): DOMDocument $loaded = $domDocument->loadXML($xml, $options); libxml_use_internal_errors($internalErrors); - libxml_disable_entity_loader($entityLoader); + if (\PHP_VERSION_ID < 80000) { + libxml_disable_entity_loader($entityLoader); + } if (!$loaded) { $error = libxml_get_last_error();