]> git.mxchange.org Git - friendica.git/blobdiff - include/api.php
Merge branch 'master' into develop
[friendica.git] / include / api.php
index a70c18f3ca6a149417d50ea813c5d3eb2e2b12e2..8ffe27e74921cb7426e020550b7bc66b6894d474 100644 (file)
@@ -54,7 +54,7 @@ define('API_METHOD_POST', 'POST,PUT');
 define('API_METHOD_DELETE', 'POST,DELETE');
 
 $API = [];
-$called_api = null;
+$called_api = [];
 
 /**
  * It is not sufficient to use local_user() to check whether someone is allowed to use the API,
@@ -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;
@@ -2216,7 +2216,7 @@ function api_statuses_repeat($type)
        }
 
        // this should output the last post (the one we just posted).
-       $called_api = null;
+       $called_api = [];
        return api_status_show($type);
 }
 
@@ -2732,7 +2732,7 @@ function api_convert_item($item)
  *
  * @param string $body
  *
- * @return array|false
+ * @return array
  */
 function api_get_attachments(&$body)
 {
@@ -2743,7 +2743,7 @@ function api_get_attachments(&$body)
        $ret = preg_match_all("/\[img\]([$URLSearchString]*)\[\/img\]/ism", $text, $images);
 
        if (!$ret) {
-               return false;
+               return [];
        }
 
        $attachments = [];
@@ -4395,7 +4395,6 @@ function api_fr_photo_create_update($type)
        throw new InternalServerErrorException("unknown error - this error on uploading or updating a photo should never happen");
 }
 
-
 /**
  * @brief delete a single photo from the database through api
  *
@@ -4534,6 +4533,7 @@ function api_account_update_profile_image($type)
        } else {
                throw new InternalServerErrorException('Unsupported filetype');
        }
+
        // change specified profile or all profiles to the new resource-id
        if ($is_default_profile) {
                $condition = ["`profile` AND `resource-id` != ? AND `uid` = ?", $data['photo']['id'], api_user()];
@@ -4547,7 +4547,6 @@ function api_account_update_profile_image($type)
        Contact::updateSelfFromUserID(api_user(), true);
 
        // Update global directory in background
-       //$user = api_get_user(get_app());
        $url = System::baseUrl() . '/profile/' . get_app()->user['nickname'];
        if ($url && strlen(Config::get('system', 'directory'))) {
                Worker::add(PRIORITY_LOW, "Directory", $url);
@@ -5289,27 +5288,27 @@ function api_in_reply_to($item)
 
 /**
  *
- * @param string $Text
+ * @param string $text
  *
  * @return string
  */
-function api_clean_plain_items($Text)
+function api_clean_plain_items($text)
 {
        $include_entities = strtolower(x($_REQUEST, 'include_entities') ? $_REQUEST['include_entities'] : "false");
 
-       $Text = BBCode::cleanPictureLinks($Text);
+       $text = BBCode::cleanPictureLinks($text);
        $URLSearchString = "^\[\]";
 
-       $Text = preg_replace("/([!#@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$1$3', $Text);
+       $text = preg_replace("/([!#@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$1$3', $text);
 
        if ($include_entities == "true") {
-               $Text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '[url=$1]$1[/url]', $Text);
+               $text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '[url=$1]$1[/url]', $text);
        }
 
        // Simplify "attachment" element
-       $Text = api_clean_attachments($Text);
+       $text = api_clean_attachments($text);
 
-       return($Text);
+       return $text;
 }
 
 /**