From 681d5c47094462fe7ad2945cecb904cd3d645280 Mon Sep 17 00:00:00 2001 From: Libor M Date: Sat, 2 Jan 2021 09:08:43 +0100 Subject: [PATCH] fix PHP 8.0 compatibility --- src/PhpWord/Shared/XMLReader.php | 8 ++++++-- tests/PhpWord/Shared/XMLWriterTest.php | 1 - 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/PhpWord/Shared/XMLReader.php b/src/PhpWord/Shared/XMLReader.php index 77013f6c..ca5cb558 100644 --- a/src/PhpWord/Shared/XMLReader.php +++ b/src/PhpWord/Shared/XMLReader.php @@ -72,10 +72,14 @@ class XMLReader */ public function getDomFromString($content) { - $originalLibXMLEntityValue = libxml_disable_entity_loader(true); + if (\PHP_VERSION_ID < 80000) { + $originalLibXMLEntityValue = libxml_disable_entity_loader(true); + } $this->dom = new \DOMDocument(); $this->dom->loadXML($content); - libxml_disable_entity_loader($originalLibXMLEntityValue); + if (\PHP_VERSION_ID < 80000) { + libxml_disable_entity_loader($originalLibXMLEntityValue); + } return $this->dom; } diff --git a/tests/PhpWord/Shared/XMLWriterTest.php b/tests/PhpWord/Shared/XMLWriterTest.php index e717ba03..843ae716 100644 --- a/tests/PhpWord/Shared/XMLWriterTest.php +++ b/tests/PhpWord/Shared/XMLWriterTest.php @@ -66,7 +66,6 @@ class XMLWriterTest extends \PHPUnit\Framework\TestCase setlocale(LC_NUMERIC, 'de_DE.UTF-8', 'de'); - $this->assertSame('1,2', (string)$value); $this->assertSame('' . chr(10), $xmlWriter->getData()); setlocale(LC_NUMERIC, $currentLocale);