X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FXML.php;h=0cdf1f34ed2f48db15e2b12bb6a214cf38487132;hb=df6cda8a4de30f55c126b95095c026e5b961c27c;hp=50ecc6d2cbe4bb1dffca672cfee9c3096d5669ca;hpb=6aa1dcfad371f34fea1f8e39b73de2cc3dd05784;p=friendica.git diff --git a/src/Util/XML.php b/src/Util/XML.php index 50ecc6d2cb..0cdf1f34ed 100644 --- a/src/Util/XML.php +++ b/src/Util/XML.php @@ -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); }