]> git.mxchange.org Git - friendica.git/blobdiff - src/Network/Probe.php
Standards
[friendica.git] / src / Network / Probe.php
index 51ed6e18455578ae82b9319e6cdd553f561c41b1..c54ddc8e997a337dc245aba64f5f8384f378d30d 100644 (file)
@@ -141,7 +141,7 @@ class Probe
        }
 
        /**
-        * Probes for webfinger path via 'host-meta'
+        * Probes for webfinger path via "host-meta"
         *
         * We have to check if the servers in the future still will offer this.
         * It seems as if it was dropped from the standard.
@@ -685,13 +685,13 @@ class Probe
 
                $result = [];
 
-               if (in_array($network, ["", Protocol::DFRN])) {
+               if (in_array($network, ['', Protocol::DFRN])) {
                        $result = self::dfrn($webfinger);
                }
-               if ((!$result && ($network == "")) || ($network == Protocol::DIASPORA)) {
+               if ((!$result && ($network == '')) || ($network == Protocol::DIASPORA)) {
                        $result = self::diaspora($webfinger);
                }
-               if ((!$result && ($network == "")) || ($network == Protocol::OSTATUS)) {
+               if ((!$result && ($network == '')) || ($network == Protocol::OSTATUS)) {
                        $result = self::ostatus($webfinger);
                }
                if (in_array($network, ['', Protocol::ZOT])) {
@@ -788,7 +788,7 @@ class Probe
                return $data;
        }
 
-       public static function pollZot($url, $data)
+       public static function pollZot(string $url, array $data): array
        {
                $curlResult = DI::httpClient()->get($url, HttpClientAccept::JSON);
                if ($curlResult->isTimeout()) {
@@ -1160,7 +1160,6 @@ class Probe
                        } elseif (($link['rel'] == 'diaspora-public-key') && !empty($link['href'])) {
                                $data['pubkey'] = base64_decode($link['href']);
 
-                               //if (strstr($data['pubkey'], 'RSA ') || ($link['type'] == 'RSA'))
                                if (strstr($data['pubkey'], 'RSA ')) {
                                        $data['pubkey'] = Crypto::rsaToPem($data['pubkey']);
                                }
@@ -1239,8 +1238,8 @@ class Probe
                        return [];
                }
 
-               if (!isset($data["baseurl"])) {
-                       $data["baseurl"] = "";
+               if (!isset($data['baseurl'])) {
+                       $data['baseurl'] = '';
                }
 
                if ($vcards->length > 0) {
@@ -1249,23 +1248,23 @@ class Probe
                        // We have to discard the guid from the hcard in favour of the guid from lrdd
                        // Reason: Hubzilla doesn't use the value "uid" in the hcard like Diaspora does.
                        $search = $xpath->query("//*[contains(concat(' ', @class, ' '), ' uid ')]", $vcard); // */
-                       if (($search->length > 0) && empty($data["guid"])) {
-                               $data["guid"] = $search->item(0)->nodeValue;
+                       if (($search->length > 0) && empty($data['guid'])) {
+                               $data['guid'] = $search->item(0)->nodeValue;
                        }
 
                        $search = $xpath->query("//*[contains(concat(' ', @class, ' '), ' nickname ')]", $vcard); // */
                        if ($search->length > 0) {
-                               $data["nick"] = $search->item(0)->nodeValue;
+                               $data['nick'] = $search->item(0)->nodeValue;
                        }
 
                        $search = $xpath->query("//*[contains(concat(' ', @class, ' '), ' fn ')]", $vcard); // */
                        if ($search->length > 0) {
-                               $data["name"] = $search->item(0)->nodeValue;
+                               $data['name'] = $search->item(0)->nodeValue;
                        }
 
                        $search = $xpath->query("//*[contains(concat(' ', @class, ' '), ' searchable ')]", $vcard); // */
                        if ($search->length > 0) {
-                               $data["searchable"] = $search->item(0)->nodeValue;
+                               $data['searchable'] = $search->item(0)->nodeValue;
                        }
 
                        $search = $xpath->query("//*[contains(concat(' ', @class, ' '), ' key ')]", $vcard); // */
@@ -1323,7 +1322,7 @@ class Probe
                                }
                        }
 
-                       // Older Friendica versions had used the 'uid' field differently than newer versions
+                       // Older Friendica versions had used the "uid" field differently than newer versions
                        if (!empty($data['nick']) && !empty($data['guid']) && ($data['nick'] == $data['guid'])) {
                                unset($data['guid']);
                        }
@@ -1367,7 +1366,6 @@ class Probe
                        } elseif (($link['rel'] == 'diaspora-public-key') && !empty($link['href'])) {
                                $data['pubkey'] = base64_decode($link['href']);
 
-                               //if (strstr($data['pubkey'], 'RSA ') || ($link['type'] == 'RSA'))
                                if (strstr($data['pubkey'], 'RSA ')) {
                                        $data['pubkey'] = Crypto::rsaToPem($data['pubkey']);
                                }
@@ -1417,7 +1415,7 @@ class Probe
                                $data['addr'] = strtolower($data['addr']);
                        }
 
-                       // We have to overwrite the detected value for 'notify' since Hubzilla doesn't send it
+                       // We have to overwrite the detected value for "notify" since Hubzilla doesn't send it
                        $data['notify'] = $data['baseurl'] . '/receive/users/' . $data['guid'];
                        $data['batch']  = $data['baseurl'] . '/receive/public';
                } else {
@@ -1768,11 +1766,10 @@ class Probe
         *
         * @param string  $url   Profile link
         * @param boolean $probe Do a probe if the page contains a feed link
-        *
         * @return array feed data
         * @throws HTTPException\InternalServerErrorException
         */
-       private static function feed($url, $probe = true)
+       private static function feed(string $url, bool $probe = true): array
        {
                $curlResult = DI::httpClient()->get($url, HttpClientAccept::FEED_XML);
                if ($curlResult->isTimeout()) {
@@ -1977,9 +1974,9 @@ class Probe
         * Fetch the last activity date from the "noscrape" endpoint
         *
         * @param array $data Probing result
-        * @return string last activity or bool 'true' if update was successful or the server was unreachable
+        * @return string last activity or true if update was successful or the server was unreachable
         */
-       private static function updateFromNoScrape(array $data)
+       private static function updateFromNoScrape(array $data): string
        {
                if (empty($data['baseurl'])) {
                        return '';