From e0a07d5f277b869213a6fb23089eb6a040e72fa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Thu, 10 May 2018 13:19:50 +0200 Subject: [PATCH] Continued: - used x() to make sure the array key is there, else an E_NOTICE is triggered - added type-hints where it is safe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- include/api.php | 4 ++-- include/conversation.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/api.php b/include/api.php index 6f2566b97d..f8c384990d 100644 --- a/include/api.php +++ b/include/api.php @@ -935,7 +935,7 @@ function api_reformat_xml(&$item, &$key) * * @return string The XML data */ -function api_create_xml($data, $root_element) +function api_create_xml(array $data, $root_element) { $childname = key($data); $data2 = array_pop($data); @@ -960,7 +960,7 @@ function api_create_xml($data, $root_element) $i = 1; foreach ($data2 as $item) { - $data4[$i++.":".$childname] = $item; + $data4[$i++ . ":" . $childname] = $item; } $data2 = $data4; diff --git a/include/conversation.php b/include/conversation.php index 8ae8296442..de3b2aaf45 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1609,16 +1609,16 @@ function sort_thr_commented(array $a, array $b) } function render_location_dummy(array $item) { - if ($item['location'] != "") { + if (x($item, 'location') && !empty($item['location'])) { return $item['location']; } - if ($item['coord'] != "") { + if (x($item, 'coord') && !empty($item['coord'])) { return $item['coord']; } } -function get_responses(array $conv_responses, array $response_verbs, $ob, $item) { +function get_responses(array $conv_responses, array $response_verbs, $ob, array $item) { $ret = []; foreach ($response_verbs as $v) { $ret[$v] = [];