mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-07 15:54:26 +02:00
fix 17 PHPStan errors
This commit is contained in:
parent
459ad05137
commit
c1653877fb
4 changed files with 62 additions and 62 deletions
|
@ -279,7 +279,7 @@ class Processor
|
|||
$uri = $this->getUri($post);
|
||||
|
||||
if ($uri_id = $this->fetchUriId($uri, $uid)) {
|
||||
return $uri_id;
|
||||
return (int) $uri_id;
|
||||
}
|
||||
|
||||
if (empty($post->record)) {
|
||||
|
@ -322,7 +322,7 @@ class Processor
|
|||
$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
|
||||
|
@ -860,7 +860,7 @@ class Processor
|
|||
$this->logger->debug('Post with extid exists', ['uri' => $uri]);
|
||||
return $reply['uri-id'];
|
||||
}
|
||||
return 0;
|
||||
return '0';
|
||||
}
|
||||
|
||||
private function getPostUids(string $uri, bool $with_public_user): array
|
||||
|
|
|
@ -250,7 +250,7 @@ class Receiver
|
|||
* @param string $object_id Object ID of the provided object
|
||||
* @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 \ImagickException
|
||||
*/
|
||||
|
|
|
@ -607,64 +607,64 @@ class DFRN
|
|||
* @param string $element Element name for the activity
|
||||
* @param string $activity activity value
|
||||
* @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
|
||||
* @todo Find proper type-hints
|
||||
*/
|
||||
private static function createActivity(DOMDocument $doc, string $element, string $activity, int $uriid)
|
||||
{
|
||||
if ($activity) {
|
||||
$entry = $doc->createElement($element);
|
||||
|
||||
$r = XML::parseString($activity);
|
||||
if (!$r) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($r->type) {
|
||||
XML::addElement($doc, $entry, "activity:object-type", $r->type);
|
||||
}
|
||||
|
||||
if ($r->id) {
|
||||
XML::addElement($doc, $entry, "id", $r->id);
|
||||
}
|
||||
|
||||
if ($r->title) {
|
||||
XML::addElement($doc, $entry, "title", $r->title);
|
||||
}
|
||||
|
||||
if ($r->link) {
|
||||
if (substr($r->link, 0, 1) == '<') {
|
||||
if (strstr($r->link, '&') && (! strstr($r->link, '&'))) {
|
||||
$r->link = str_replace('&', '&', $r->link);
|
||||
}
|
||||
|
||||
$r->link = preg_replace('/\<link(.*?)\"\>/', '<link$1"/>', $r->link);
|
||||
|
||||
// XML does need a single element as root element so we add a dummy element here
|
||||
$data = XML::parseString("<dummy>" . $r->link . "</dummy>");
|
||||
if (is_object($data)) {
|
||||
foreach ($data->link as $link) {
|
||||
$attributes = [];
|
||||
foreach ($link->attributes() as $parameter => $value) {
|
||||
$attributes[$parameter] = $value;
|
||||
}
|
||||
XML::addElement($doc, $entry, "link", "", $attributes);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$attributes = ["rel" => "alternate", "type" => "text/html", "href" => $r->link];
|
||||
XML::addElement($doc, $entry, "link", "", $attributes);
|
||||
}
|
||||
}
|
||||
if ($r->content) {
|
||||
XML::addElement($doc, $entry, "content", BBCode::convertForUriId($uriid, $r->content, BBCode::EXTERNAL), ["type" => "html"]);
|
||||
}
|
||||
|
||||
return $entry;
|
||||
if (!$activity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
$entry = $doc->createElement($element);
|
||||
|
||||
$r = XML::parseString($activity);
|
||||
if (!$r) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($r->type) {
|
||||
XML::addElement($doc, $entry, "activity:object-type", $r->type);
|
||||
}
|
||||
|
||||
if ($r->id) {
|
||||
XML::addElement($doc, $entry, "id", $r->id);
|
||||
}
|
||||
|
||||
if ($r->title) {
|
||||
XML::addElement($doc, $entry, "title", $r->title);
|
||||
}
|
||||
|
||||
if ($r->link) {
|
||||
if (substr($r->link, 0, 1) == '<') {
|
||||
if (strstr($r->link, '&') && (! strstr($r->link, '&'))) {
|
||||
$r->link = str_replace('&', '&', $r->link);
|
||||
}
|
||||
|
||||
$r->link = preg_replace('/\<link(.*?)\"\>/', '<link$1"/>', $r->link);
|
||||
|
||||
// XML does need a single element as root element so we add a dummy element here
|
||||
$data = XML::parseString("<dummy>" . $r->link . "</dummy>");
|
||||
if (is_object($data)) {
|
||||
foreach ($data->link as $link) {
|
||||
$attributes = [];
|
||||
foreach ($link->attributes() as $parameter => $value) {
|
||||
$attributes[$parameter] = $value;
|
||||
}
|
||||
XML::addElement($doc, $entry, "link", "", $attributes);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$attributes = ["rel" => "alternate", "type" => "text/html", "href" => $r->link];
|
||||
XML::addElement($doc, $entry, "link", "", $attributes);
|
||||
}
|
||||
}
|
||||
if ($r->content) {
|
||||
XML::addElement($doc, $entry, "content", BBCode::convertForUriId($uriid, $r->content, BBCode::EXTERNAL), ["type" => "html"]);
|
||||
}
|
||||
|
||||
return $entry;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1925,7 +1925,7 @@ class DFRN
|
|||
// Check if the message is wanted
|
||||
if (!self::isSolicitedMessage($item, $importer)) {
|
||||
DBA::delete('item-uri', ['uri' => $item['uri']]);
|
||||
return 403;
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the type of the item (Top level post, reply or remote reply)
|
||||
|
@ -2051,7 +2051,7 @@ class DFRN
|
|||
Item::distribute($posted_id);
|
||||
}
|
||||
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
} else { // $entrytype == self::TOP_LEVEL
|
||||
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']) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
$condition = ['uri' => $uri, 'uid' => $importer['importer_uid']];
|
||||
|
|
|
@ -337,7 +337,7 @@ class Diaspora
|
|||
* @param string $xml urldecoded Diaspora salmon
|
||||
* @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
|
||||
* 'author' -> author diaspora handle
|
||||
* 'key' -> author public key (converted to pkcs#8)
|
||||
|
@ -1051,7 +1051,7 @@ class Diaspora
|
|||
* @param string $server The url of the server
|
||||
* @param int $level Endless loop prevention
|
||||
*
|
||||
* @return array
|
||||
* @return array|false The message as array or false on error
|
||||
* 'message' => The message XML
|
||||
* 'author' => The author handle
|
||||
* 'key' => The public key of the author
|
||||
|
@ -2795,7 +2795,7 @@ class Diaspora
|
|||
// without a public key nothing will work
|
||||
if (!$pubkey) {
|
||||
DI::logger()->notice('pubkey missing: contact id: ' . $contact['id']);
|
||||
return false;
|
||||
return '';
|
||||
}
|
||||
|
||||
$aes_key = random_bytes(32);
|
||||
|
@ -2809,7 +2809,7 @@ class Diaspora
|
|||
|
||||
$encrypted_key_bundle = '';
|
||||
if (!@openssl_public_encrypt($json, $encrypted_key_bundle, $pubkey)) {
|
||||
return false;
|
||||
return '';
|
||||
}
|
||||
|
||||
$json_object = json_encode(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue