fix 17 PHPStan errors

This commit is contained in:
Art4 2025-02-25 11:36:32 +00:00
parent 459ad05137
commit c1653877fb
4 changed files with 62 additions and 62 deletions

View file

@ -279,7 +279,7 @@ class Processor
$uri = $this->getUri($post); $uri = $this->getUri($post);
if ($uri_id = $this->fetchUriId($uri, $uid)) { if ($uri_id = $this->fetchUriId($uri, $uid)) {
return $uri_id; return (int) $uri_id;
} }
if (empty($post->record)) { if (empty($post->record)) {
@ -322,7 +322,7 @@ class Processor
$this->logger->warning('Fetched post was not inserted', ['guid' => $item['guid'], 'uri' => $item['uri']]); $this->logger->warning('Fetched post was not inserted', ['guid' => $item['guid'], 'uri' => $item['uri']]);
} }
return $this->fetchUriId($uri, $uid); return (int) $this->fetchUriId($uri, $uid);
} }
private function getHeaderFromJetstream(stdClass $data, int $uid, int $protocol = Conversation::PARCEL_JETSTREAM): array private function getHeaderFromJetstream(stdClass $data, int $uid, int $protocol = Conversation::PARCEL_JETSTREAM): array
@ -860,7 +860,7 @@ class Processor
$this->logger->debug('Post with extid exists', ['uri' => $uri]); $this->logger->debug('Post with extid exists', ['uri' => $uri]);
return $reply['uri-id']; return $reply['uri-id'];
} }
return 0; return '0';
} }
private function getPostUids(string $uri, bool $with_public_user): array private function getPostUids(string $uri, bool $with_public_user): array

View file

@ -250,7 +250,7 @@ class Receiver
* @param string $object_id Object ID of the provided object * @param string $object_id Object ID of the provided object
* @param integer $uid User ID * @param integer $uid User ID
* *
* @return string with object type or NULL * @return string|null string with object type or NULL
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */

View file

@ -607,13 +607,16 @@ class DFRN
* @param string $element Element name for the activity * @param string $element Element name for the activity
* @param string $activity activity value * @param string $activity activity value
* @param int $uriid Uri-Id of the post * @param int $uriid Uri-Id of the post
* @return DOMElement XML activity object * @return DOMElement|false XML activity object or false on error
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @todo Find proper type-hints * @todo Find proper type-hints
*/ */
private static function createActivity(DOMDocument $doc, string $element, string $activity, int $uriid) private static function createActivity(DOMDocument $doc, string $element, string $activity, int $uriid)
{ {
if ($activity) { if (!$activity) {
return false;
}
$entry = $doc->createElement($element); $entry = $doc->createElement($element);
$r = XML::parseString($activity); $r = XML::parseString($activity);
@ -664,9 +667,6 @@ class DFRN
return $entry; return $entry;
} }
return false;
}
/** /**
* Adds the elements for attachments * Adds the elements for attachments
* *
@ -1925,7 +1925,7 @@ class DFRN
// Check if the message is wanted // Check if the message is wanted
if (!self::isSolicitedMessage($item, $importer)) { if (!self::isSolicitedMessage($item, $importer)) {
DBA::delete('item-uri', ['uri' => $item['uri']]); DBA::delete('item-uri', ['uri' => $item['uri']]);
return 403; return;
} }
// Get the type of the item (Top level post, reply or remote reply) // Get the type of the item (Top level post, reply or remote reply)
@ -2051,7 +2051,7 @@ class DFRN
Item::distribute($posted_id); Item::distribute($posted_id);
} }
return true; return;
} }
} else { // $entrytype == self::TOP_LEVEL } else { // $entrytype == self::TOP_LEVEL
if (($item['uid'] != 0) && !Contact::isSharing($item['owner-id'], $item['uid']) && !Contact::isSharing($item['author-id'], $item['uid'])) { if (($item['uid'] != 0) && !Contact::isSharing($item['owner-id'], $item['uid']) && !Contact::isSharing($item['author-id'], $item['uid'])) {
@ -2099,7 +2099,7 @@ class DFRN
} }
if (!$uri || !$importer['id']) { if (!$uri || !$importer['id']) {
return false; return;
} }
$condition = ['uri' => $uri, 'uid' => $importer['importer_uid']]; $condition = ['uri' => $uri, 'uid' => $importer['importer_uid']];

View file

@ -337,7 +337,7 @@ class Diaspora
* @param string $xml urldecoded Diaspora salmon * @param string $xml urldecoded Diaspora salmon
* @param string $privKey The private key of the importer * @param string $privKey The private key of the importer
* *
* @return array * @return array|false array with decoded data or false on error
* 'message' -> decoded Diaspora XML message * 'message' -> decoded Diaspora XML message
* 'author' -> author diaspora handle * 'author' -> author diaspora handle
* 'key' -> author public key (converted to pkcs#8) * 'key' -> author public key (converted to pkcs#8)
@ -1051,7 +1051,7 @@ class Diaspora
* @param string $server The url of the server * @param string $server The url of the server
* @param int $level Endless loop prevention * @param int $level Endless loop prevention
* *
* @return array * @return array|false The message as array or false on error
* 'message' => The message XML * 'message' => The message XML
* 'author' => The author handle * 'author' => The author handle
* 'key' => The public key of the author * 'key' => The public key of the author
@ -2795,7 +2795,7 @@ class Diaspora
// without a public key nothing will work // without a public key nothing will work
if (!$pubkey) { if (!$pubkey) {
DI::logger()->notice('pubkey missing: contact id: ' . $contact['id']); DI::logger()->notice('pubkey missing: contact id: ' . $contact['id']);
return false; return '';
} }
$aes_key = random_bytes(32); $aes_key = random_bytes(32);
@ -2809,7 +2809,7 @@ class Diaspora
$encrypted_key_bundle = ''; $encrypted_key_bundle = '';
if (!@openssl_public_encrypt($json, $encrypted_key_bundle, $pubkey)) { if (!@openssl_public_encrypt($json, $encrypted_key_bundle, $pubkey)) {
return false; return '';
} }
$json_object = json_encode( $json_object = json_encode(