X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FXML.php;h=5355d30f995b36bfa77fe8268c1fd7362ef601ab;hb=46cd39fb34613f4b331793f19c0e562f93125066;hp=50ecc6d2cbe4bb1dffca672cfee9c3096d5669ca;hpb=360614d2cf3aceeb763ef1281ad5236878f5d735;p=friendica.git diff --git a/src/Util/XML.php b/src/Util/XML.php index 50ecc6d2cb..5355d30f99 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); } @@ -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 {