]> git.mxchange.org Git - friendica.git/blobdiff - src/Util/XML.php
spelling: occurrences
[friendica.git] / src / Util / XML.php
index 7933f4415b6f9a21677cffe7e090e24c7dd278f2..5355d30f995b36bfa77fe8268c1fd7362ef601ab 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2022, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -37,14 +37,15 @@ class XML
        /**
         * Creates an XML structure out of a given array
         *
-        * @param array  $array         The array of the XML structure that will be generated
-        * @param object $xml           The created XML will be returned by reference
-        * @param bool   $remove_header Should the XML header be removed or not?
-        * @param array  $namespaces    List of namespaces
-        * @param bool   $root          interally used parameter. Mustn't be used from outside.
+        * @param array       $array         The array of the XML structure that will be generated
+        * @param object|null $xml           The created XML will be returned by reference
+        * @param bool        $remove_header Should the XML header be removed or not?
+        * @param array       $namespaces    List of namespaces
+        * @param bool        $root          interally used parameter. Mustn't be used from outside.
         * @return string
+        * @throws \Exception
         */
-       public static function fromArray(array $array, &$xml, bool $remove_header = false, array $namespaces = [], bool $root = true): string
+       public static function fromArray(array $array, object &$xml = null, bool $remove_header = false, array $namespaces = [], bool $root = true): string
        {
                if ($root) {
                        foreach ($array as $key => $value) {
@@ -125,7 +126,7 @@ class XML
 
                        if (!is_array($value)) {
                                $element = $xml->addChild($key, self::escape($value ?? ''), $namespace);
-                       } elseif (is_array($value)) {
+                       } else {
                                $element = $xml->addChild($key, null, $namespace);
                                self::fromArray($value, $element, $remove_header, $namespaces, false);
                        }
@@ -535,7 +536,7 @@ class XML
         *
         * @param string $str
         * @return string Escaped text.
-        * @todo Move this generic method to Util\Strings and also rewrite all other findingd
+        * @todo Move this generic method to Util\Strings and also rewrite all other occurrences
         */
        public static function escape(string $str): string
        {
@@ -547,7 +548,7 @@ class XML
         *
         * @param string $s xml escaped text
         * @return string unescaped text
-        * @todo Move this generic method to Util\Strings and also rewrite all other findingd
+        * @todo Move this generic method to Util\Strings and also rewrite all other occurrences
         */
        public static function unescape(string $s): string
        {