diff --git a/src/Core/Hook.php b/src/Core/Hook.php index 44dfad70bc..8c9f3ba910 100644 --- a/src/Core/Hook.php +++ b/src/Core/Hook.php @@ -172,7 +172,7 @@ class Hook * the provided data. * * @param string $name of the hook to call - * @param string|array &$data to transmit to the callback handler + * @param string|array|null $data to transmit to the callback handler * @return void * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ diff --git a/src/Factory/Api/Friendica/Photo.php b/src/Factory/Api/Friendica/Photo.php index 82c80ac7f3..051ae66a5d 100644 --- a/src/Factory/Api/Friendica/Photo.php +++ b/src/Factory/Api/Friendica/Photo.php @@ -41,7 +41,6 @@ class Photo extends BaseFactory * @param int $scale * @param int $uid * @param string $type - * @return Array */ public function createFromId(string $photo_id, int $scale = null, int $uid, string $type = 'json', bool $with_posts = true): array { @@ -66,7 +65,7 @@ class Photo extends BaseFactory $data['id'] = $data['resource-id']; if (is_int($scale)) { - $data['data'] = base64_encode(ModelPhoto::getImageDataForPhoto($data)); + $data['data'] = base64_encode(ModelPhoto::getImageDataForPhoto($data) ?? ''); } if ($type == 'xml') { diff --git a/src/Model/Item.php b/src/Model/Item.php index 31f8a8e22e..6500c8005c 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -672,7 +672,7 @@ class Item /** * Inserts item record * - * @param array $item Item array to be inserted + * @param array $item Item array to be inserted * @param int $notify Notification (type?) * @param bool $post_local (???) * @return int Zero means error, otherwise primary key (id) is being returned @@ -695,6 +695,7 @@ class Item // If it is a posting where users should get notifications, then define it as wall posting if ($notify) { + /** @var array */ $item = $itemHelper->prepareOriginPost($item); if (is_int($notify) && in_array($notify, Worker::PRIORITIES)) { @@ -708,6 +709,7 @@ class Item $item['network'] = trim(($item['network'] ?? '') ?: Protocol::PHANTOM); } + /** @var array */ $item = $itemHelper->prepareItemData($item, (bool) $notify); // Store conversation data @@ -749,6 +751,7 @@ class Item } } + /** @var array */ $item = $itemHelper->validateItemData($item); // Ensure that there is an avatar cache @@ -846,6 +849,7 @@ class Item $dummy_session = false; } + /** @var array */ $item = $eventDispatcher->dispatch( new ArrayFilterEvent(ArrayFilterEvent::POST_LOCAL, $item) )->getArray(); @@ -3061,7 +3065,14 @@ class Item { $appHelper = DI::appHelper(); $uid = DI::userSession()->getLocalUserId(); - Hook::callAll('prepare_body_init', $item); + + $item_copy = $item; + + Hook::callAll('prepare_body_init', $item_copy); + + if (is_array($item_copy)) { + $item = $item_copy; + } // In order to provide theme developers more possibilities, event items // are treated differently. diff --git a/src/Model/Log/ParsedLogIterator.php b/src/Model/Log/ParsedLogIterator.php index 44c98462c1..58c8bddb77 100644 --- a/src/Model/Log/ParsedLogIterator.php +++ b/src/Model/Log/ParsedLogIterator.php @@ -21,7 +21,7 @@ class ParsedLogIterator implements \Iterator /** @var ReversedFileReader */ private $reader; - /** @var ParsedLogLine current iterator value*/ + /** @var ParsedLogLine|null current iterator value*/ private $value = null; /** @var int max number of lines to read */ diff --git a/src/Model/Photo.php b/src/Model/Photo.php index c275753960..74edaf360d 100644 --- a/src/Model/Photo.php +++ b/src/Model/Photo.php @@ -244,7 +244,7 @@ class Photo * * @param array $photo Photo data. Needs at least 'id', 'type', 'backend-class', 'backend-ref' * - * @return \Friendica\Object\Image|null Image object or null on error + * @return string|null Image data as string or null on error */ public static function getImageDataForPhoto(array $photo) { @@ -254,7 +254,7 @@ class Photo try { $backendClass = DI::storageManager()->getByName($photo['backend-class'] ?? ''); - /// @todo refactoring this returning, because the storage returns a "string" which is casted in different ways - a check "instanceof Image" will fail! + return $backendClass->get($photo['backend-ref'] ?? ''); } catch (InvalidClassStorageException $storageException) { try { @@ -834,10 +834,9 @@ class Photo * - Sharing a post with a group will create a photo that only the group can see. * - Sharing a photo again that been shared non public before doesn't alter the permissions. * - * @return string * @throws \Exception */ - public static function setPermissionFromBody($body, $uid, $original_contact_id, $str_contact_allow, $str_circle_allow, $str_contact_deny, $str_circle_deny) + public static function setPermissionFromBody($body, $uid, $original_contact_id, $str_contact_allow, $str_circle_allow, $str_contact_deny, $str_circle_deny): bool { // Simplify image codes $img_body = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $body); diff --git a/src/Model/Post/Delayed.php b/src/Model/Post/Delayed.php index e4862c27c2..b0c5d09dcd 100644 --- a/src/Model/Post/Delayed.php +++ b/src/Model/Post/Delayed.php @@ -170,9 +170,8 @@ class Delayed * @param array $attachments * @param int $preparation_mode * @param string $uri - * @return bool */ - public static function publish(array $item, int $notify = 0, array $taglist = [], array $attachments = [], int $preparation_mode = self::PREPARED, string $uri = '') + public static function publish(array $item, int $notify = 0, array $taglist = [], array $attachments = [], int $preparation_mode = self::PREPARED, string $uri = ''): int { if (!empty($attachments)) { $item['attachments'] = $attachments;