* 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
*/
* @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
{
$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') {
/**
* Inserts item record
*
- * @param array $item Item array to be inserted
+ * @param array<string,mixed> $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
// If it is a posting where users should get notifications, then define it as wall posting
if ($notify) {
+ /** @var array<string,mixed> */
$item = $itemHelper->prepareOriginPost($item);
if (is_int($notify) && in_array($notify, Worker::PRIORITIES)) {
$item['network'] = trim(($item['network'] ?? '') ?: Protocol::PHANTOM);
}
+ /** @var array<string,mixed> */
$item = $itemHelper->prepareItemData($item, (bool) $notify);
// Store conversation data
}
}
+ /** @var array<string,mixed> */
$item = $itemHelper->validateItemData($item);
// Ensure that there is an avatar cache
$dummy_session = false;
}
+ /** @var array<string,mixed> */
$item = $eventDispatcher->dispatch(
new ArrayFilterEvent(ArrayFilterEvent::POST_LOCAL, $item)
)->getArray();
{
$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.
/** @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 */
*
* @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)
{
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 {
* - 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);
* @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;