X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FXML.php;h=58ba84c4a7fc42686bb1e3279d8d2fa76423ada7;hb=3bca4fe2a64671d09e08346456cdfa6c12f996e9;hp=50ecc6d2cbe4bb1dffca672cfee9c3096d5669ca;hpb=6aa1dcfad371f34fea1f8e39b73de2cc3dd05784;p=friendica.git diff --git a/src/Util/XML.php b/src/Util/XML.php index 50ecc6d2cb..58ba84c4a7 100644 --- a/src/Util/XML.php +++ b/src/Util/XML.php @@ -1,6 +1,6 @@ $value) { @@ -117,7 +117,7 @@ class XML $namespace = null; } - $element->addAttribute($attr_key, $attr_value, $namespace); + $element->addAttribute($attr_key, $attr_value ?? '', $namespace); } continue; @@ -125,7 +125,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); } @@ -258,7 +258,7 @@ class XML * @param integer $get_attributes 1 or 0. If this is 1 the function will get the attributes as well as the tag values - * this results in a different array structure in the return value. * @param string $priority Can be 'tag' or 'attribute'. This will change the way the resulting - * array sturcture. For 'tag', the tags are given more importance. + * array structure. For 'tag', the tags are given more importance. * * @return array The parsed XML in an array form. Use print_r() to see the resulting array structure. * @throws \Exception @@ -396,7 +396,7 @@ class XML } $repeated_tag_index[$tag . '_' . $level]++; } else { // If it is not an array... - $current[$tag] = [$current[$tag], $result]; //...Make it an array using using the existing value and the new value + $current[$tag] = [$current[$tag], $result]; //...Make it an array using the existing value and the new value $repeated_tag_index[$tag . '_' . $level] = 1; if ($priority == 'tag' and $get_attributes) { if (isset($current[$tag.'_attr'])) { // The attribute of the last(0th) tag must be moved as well @@ -440,7 +440,7 @@ class XML * Parse XML string * * @param string $s XML string to parse into object - * @param boolean $suppress_log Whether to supressing logging + * @param boolean $suppress_log Whether to suppressing logging * @return SimpleXMLElement|bool SimpleXMLElement or false on failure */ public static function parseString(string $s, bool $suppress_log = false) @@ -450,7 +450,7 @@ class XML $x = @simplexml_load_string($s); if (!$x) { if (!$suppress_log) { - Logger::error('Error(s) while parsing XML string.', ['callstack' => System::callstack()]); + Logger::error('Error(s) while parsing XML string.'); foreach (libxml_get_errors() as $err) { Logger::info('libxml error', ['code' => $err->code, 'position' => $err->line . ':' . $err->column, 'message' => $err->message]); } @@ -535,7 +535,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 +547,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 {