$parsed = parse_url($uri);
// Remove the scheme to make sure that "https" and "http" doesn't make a difference
- unset($parsed["scheme"]);
+ unset($parsed['scheme']);
// Glue it together to be able to make a hash from it
- $host_id = implode("/", $parsed);
+ $host_id = implode('/', $parsed);
// Use a mixture of several hashes to provide some GUID like experience
- return hash("crc32", $host) . '-'. hash('joaat', $host_id) . '-'. hash('fnv164', $host_id);
+ return hash('crc32', $host) . '-'. hash('joaat', $host_id) . '-'. hash('fnv164', $host_id);
}
/**
* @return string
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- public static function newURI($uid, $guid = "")
+ public static function newURI(int $uid, string $guid = ''): string
{
- if ($guid == "") {
+ if ($guid == '') {
$guid = System::createUUID();
}
/**
* Checks incoming message from the inbox
*
- * @param $body
- * @param $header
+ * @param string $body Body string
+ * @param array $header Header lines
* @param integer $uid User ID
* @throws \Exception
- * @todo Find type for $body/$header
*/
- public static function processInbox($body, $header, int $uid)
+ public static function processInbox(string $body, array $header, int $uid)
{
$activity = json_decode($body, true);
if (empty($activity)) {
$actor = JsonLD::fetchElement($ldactivity, 'as:actor', '@id');
- $apcontact = APContact::getByURL($actor);
+ $apcontact = APContact::getByURL($actor ?? '');
if (empty($apcontact)) {
Logger::notice('Unable to retrieve AP contact for actor - message is discarded', ['actor' => $actor]);
return;