From: Roland Häder Date: Mon, 20 Jun 2022 00:30:09 +0000 (+0200) Subject: Changes: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f1867463a054b5a8bed33d5835afc099f60761a9;p=friendica.git Changes: - added more type-hints --- diff --git a/src/Util/ParseUrl.php b/src/Util/ParseUrl.php index f4c78df8a5..9f0fd8a9bc 100644 --- a/src/Util/ParseUrl.php +++ b/src/Util/ParseUrl.php @@ -101,7 +101,7 @@ class ParseUrl * @see ParseUrl::getSiteinfo() for more information about scraping * embeddable content */ - public static function getSiteinfoCached($url, $do_oembed = true): array + public static function getSiteinfoCached(string $url, bool $do_oembed = true): array { if (empty($url)) { return [ @@ -180,7 +180,7 @@ class ParseUrl * * @endverbatim */ - public static function getSiteinfo($url, $do_oembed = true, $count = 1) + public static function getSiteinfo(string $url, bool $do_oembed = true, int $count = 1) { if (empty($url)) { return [ @@ -633,15 +633,16 @@ class ParseUrl * @param string $string Tags * @return array with formatted Hashtags */ - public static function convertTagsToArray($string) + public static function convertTagsToArray(string $string): array { $arr_tags = str_getcsv($string); if (count($arr_tags)) { // add the # sign to every tag - array_walk($arr_tags, ["self", "arrAddHashes"]); + array_walk($arr_tags, ['self', 'arrAddHashes']); return $arr_tags; } + return []; } /** @@ -653,9 +654,9 @@ class ParseUrl * @param int $k Counter for internal use * @return void */ - private static function arrAddHashes(&$tag, $k) + private static function arrAddHashes(string &$tag, int $k) { - $tag = "#" . $tag; + $tag = '#' . $tag; } /** @@ -672,41 +673,41 @@ class ParseUrl * * @return string The url with a scheme */ - private static function completeUrl($url, $scheme) + private static function completeUrl(string $url, string $scheme): string { $urlarr = parse_url($url); // If the url does allready have an scheme // we can stop the process here - if (isset($urlarr["scheme"])) { - return($url); + if (isset($urlarr['scheme'])) { + return $url; } $schemearr = parse_url($scheme); - $complete = $schemearr["scheme"]."://".$schemearr["host"]; + $complete = $schemearr['scheme'] . '://' . $schemearr['host']; - if (!empty($schemearr["port"])) { - $complete .= ":".$schemearr["port"]; + if (!empty($schemearr['port'])) { + $complete .= ':' . $schemearr['port']; } - if (!empty($urlarr["path"])) { - if (strpos($urlarr["path"], "/") !== 0) { - $complete .= "/"; + if (!empty($urlarr['path'])) { + if (strpos($urlarr['path'], '/') !== 0) { + $complete .= '/'; } - $complete .= $urlarr["path"]; + $complete .= $urlarr['path']; } - if (!empty($urlarr["query"])) { - $complete .= "?".$urlarr["query"]; + if (!empty($urlarr['query'])) { + $complete .= '?' . $urlarr['query']; } - if (!empty($urlarr["fragment"])) { - $complete .= "#".$urlarr["fragment"]; + if (!empty($urlarr['fragment'])) { + $complete .= '#' . $urlarr['fragment']; } - return($complete); + return $complete; } /** @@ -716,7 +717,7 @@ class ParseUrl * @param array $jsonld * @return array siteinfo */ - private static function parseParts(array $siteinfo, array $jsonld) + private static function parseParts(array $siteinfo, array $jsonld): array { if (!empty($jsonld['@graph']) && is_array($jsonld['@graph'])) { foreach ($jsonld['@graph'] as $part) { @@ -761,7 +762,7 @@ class ParseUrl * @param array $jsonld * @return array siteinfo */ - private static function parseJsonLd(array $siteinfo, array $jsonld) + private static function parseJsonLd(array $siteinfo, array $jsonld): array { $type = JsonLD::fetchElement($jsonld, '@type'); if (empty($type)) { @@ -854,7 +855,7 @@ class ParseUrl * @param array $jsonld * @return array siteinfo */ - private static function parseJsonLdAuthor(array $siteinfo, array $jsonld) + private static function parseJsonLdAuthor(array $siteinfo, array $jsonld): array { $jsonldinfo = []; @@ -938,7 +939,7 @@ class ParseUrl * @param array $jsonld * @return array siteinfo */ - private static function parseJsonLdArticle(array $siteinfo, array $jsonld) + private static function parseJsonLdArticle(array $siteinfo, array $jsonld): array { $jsonldinfo = []; @@ -1008,7 +1009,7 @@ class ParseUrl * @param array $jsonld * @return array siteinfo */ - private static function parseJsonLdWebPage(array $siteinfo, array $jsonld) + private static function parseJsonLdWebPage(array $siteinfo, array $jsonld): array { $jsonldinfo = []; @@ -1047,7 +1048,7 @@ class ParseUrl * @param array $jsonld * @return array siteinfo */ - private static function parseJsonLdWebSite(array $siteinfo, array $jsonld) + private static function parseJsonLdWebSite(array $siteinfo, array $jsonld): array { $jsonldinfo = []; @@ -1085,7 +1086,7 @@ class ParseUrl * @param array $jsonld * @return array siteinfo */ - private static function parseJsonLdWebOrganization(array $siteinfo, array $jsonld) + private static function parseJsonLdWebOrganization(array $siteinfo, array $jsonld): array { $jsonldinfo = []; @@ -1131,7 +1132,7 @@ class ParseUrl * @param array $jsonld * @return array siteinfo */ - private static function parseJsonLdWebPerson(array $siteinfo, array $jsonld) + private static function parseJsonLdWebPerson(array $siteinfo, array $jsonld): array { $jsonldinfo = []; @@ -1176,7 +1177,7 @@ class ParseUrl * @param array $jsonld * @return array siteinfo */ - private static function parseJsonLdMediaObject(array $siteinfo, array $jsonld, string $name) + private static function parseJsonLdMediaObject(array $siteinfo, array $jsonld, string $name): array { $media = [];