From 86a62cf3de8e0e1cebb4354900add8cdb84d55fe Mon Sep 17 00:00:00 2001 From: ju!! Date: Thu, 12 May 2022 22:19:26 +0300 Subject: [PATCH] PHP 8.1 - DOMDocument::createTextNode Dear Array2XML people, I found an issue as I upgraded to PHP 8.1, the following exception came up from line 174: DOMDocument::createTextNode(): Passing null to parameter 1 ($data) of type string is deprecated It may has to do with the following from https://www.php.net/manual/en/domdocument.createtextnode "Version 8.1.0 - In case of an error, a DomException is thrown now. Previously, false was returned." I found a quick fix that works just fine in my situation... Please have a look, it might be the correct way! Thank you, --- LSS/Array2XML.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LSS/Array2XML.php b/LSS/Array2XML.php index 99e0659..a9ad148 100644 --- a/LSS/Array2XML.php +++ b/LSS/Array2XML.php @@ -170,7 +170,7 @@ private static function &convert($node_name, $arr = array()) { // after we are done with all the keys in the array (if it is one) // we check if it has any text value, if yes, append it. - if (!is_array($arr)) { + if (!is_array($arr) && $arr) { $node->appendChild($xml->createTextNode(self::bool2str($arr))); }