Merge pull request #14584 from Art4/phpstan-level-2

PHPStan level 2
This commit is contained in:
Hypolite Petovan 2024-12-14 16:54:02 -05:00 committed by GitHub
commit 8210f5c7e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
118 changed files with 812 additions and 927 deletions

View file

@ -3,10 +3,10 @@
# SPDX-License-Identifier: CC0-1.0
parameters:
level: 1
level: 2
paths:
- addon/
# - addon/
- src/
excludePaths:
@ -23,3 +23,19 @@ parameters:
dynamicConstantNames:
- DB_UPDATE_VERSION
ignoreErrors:
-
# Ignore missing GdImage class in PHP <= 7.4
message: '(^Property .+ has unknown class GdImage as its type\.$)'
path: src
-
# Ignore missing IMAP\Connection class in PHP <= 8.0
message: '(^Method .+ has invalid return type IMAP\\Connection\.$)'
path: src
-
# Ignore missing IMAP\Connection class in PHP <= 8.0
message: '(^Parameter .+ has invalid type IMAP\\Connection\.$)'
path: src

View file

@ -7,7 +7,7 @@
namespace Friendica;
use Friendica\Network\HTTPException;
use Friendica\Network\HTTPException\InternalServerErrorException;
/**
* The Entity classes directly inheriting from this abstract class are meant to represent a single business entity.
@ -29,12 +29,12 @@ abstract class BaseEntity extends BaseDataTransferObject
/**
* @param string $name
* @return mixed
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
*/
public function __get(string $name)
{
if (!property_exists($this, $name)) {
throw new HTTPException\InternalServerErrorException('Unknown property ' . $name . ' in Entity ' . static::class);
throw new InternalServerErrorException('Unknown property ' . $name . ' in Entity ' . static::class);
}
return $this->$name;
@ -43,12 +43,12 @@ abstract class BaseEntity extends BaseDataTransferObject
/**
* @param mixed $name
* @return bool
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
*/
public function __isset($name): bool
{
if (!property_exists($this, $name)) {
throw new HTTPException\InternalServerErrorException('Unknown property ' . $name . ' of type ' . gettype($name) . ' in Entity ' . static::class);
throw new InternalServerErrorException('Unknown property ' . $name . ' of type ' . gettype($name) . ' in Entity ' . static::class);
}
return !empty($this->$name);

View file

@ -15,7 +15,7 @@ use Psr\Log\LoggerInterface;
* The Model classes inheriting from this abstract class are meant to represent a single database record.
* The associated table name has to be provided in the child class, and the table is expected to have a unique `id` field.
*
* @property int id
* @property int $id
*/
abstract class BaseModel extends BaseDataTransferObject
{
@ -41,8 +41,6 @@ abstract class BaseModel extends BaseDataTransferObject
private $originalData = [];
/**
* @param Database $dba
* @param LoggerInterface $logger
* @param array $data Table row attributes
*/
public function __construct(Database $dba, LoggerInterface $logger, array $data = [])

View file

@ -7,8 +7,8 @@
namespace Friendica\Collection\Api\Mastodon;
use Friendica\Api\Entity\Mastodon\Field;
use Friendica\BaseCollection;
use Friendica\Object\Api\Mastodon\Field;
class Fields extends BaseCollection
{

View file

@ -10,6 +10,7 @@ namespace Friendica\Console;
use Friendica\App\BaseURL;
use Friendica\Contact\Avatar;
use Friendica\Core\L10n;
use Friendica\Database\Database;
use Friendica\Model\Contact;
use Friendica\Core\Config\Capability\IManageConfigValues;
@ -21,12 +22,12 @@ class ClearAvatarCache extends \Asika\SimpleConsole\Console
protected $helpOptions = ['h', 'help', '?'];
/**
* @var $dba Friendica\Database\Database
* @var Database
*/
private $dba;
/**
* @var $baseurl Friendica\App\BaseURL
* @var BaseURL
*/
private $baseUrl;

View file

@ -9,6 +9,7 @@ namespace Friendica\Console;
use Console_Table;
use Friendica\App\Mode;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
use Friendica\DI;
use Friendica\Model\Contact as ContactModel;
use Friendica\Model\User as UserModel;
@ -29,7 +30,7 @@ class Contact extends \Asika\SimpleConsole\Console
*/
private $appMode;
/**
* @var IPConfig
* @var IManagePersonalConfigValues
*/
private $pConfig;

View file

@ -19,7 +19,7 @@ class MergeContacts extends \Asika\SimpleConsole\Console
protected $helpOptions = ['h', 'help', '?'];
/**
* @var $dba Database
* @var Database
*/
private $dba;

View file

@ -9,12 +9,13 @@ namespace Friendica\Console;
use Friendica\App\BaseURL;
use Friendica\Contact\Avatar;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\L10n;
use Friendica\Core\Protocol;
use Friendica\Database\Database;
use Friendica\Model\Contact;
use Friendica\Model\Photo;
use Friendica\Object\Image;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Protocol;
/**
* tool to move cached avatars to the avatar file cache.
@ -24,12 +25,12 @@ class MoveToAvatarCache extends \Asika\SimpleConsole\Console
protected $helpOptions = ['h', 'help', '?'];
/**
* @var $dba Friendica\Database\Database
* @var Database
*/
private $dba;
/**
* @var $baseurl Friendica\App\BaseURL
* @var BaseURL
*/
private $baseUrl;

View file

@ -8,6 +8,7 @@
namespace Friendica\Console;
use Asika\SimpleConsole\CommandArgsException;
use Friendica\Database\Database;
use Friendica\Model\APContact;
use Friendica\Protocol\ActivityPub\Transmitter;
use Friendica\Protocol\Relay as ProtocolRelay;
@ -23,7 +24,7 @@ class Relay extends \Asika\SimpleConsole\Console
protected $helpOptions = ['h', 'help', '?'];
/**
* @var $dba Friendica\Database\Database
* @var Database
*/
private $dba;

View file

@ -235,9 +235,6 @@ class Avatar
/**
* Delete locally cached avatar pictures of a contact
*
* @param string $avatar
* @return bool
*/
public static function deleteCache(array $contact): bool
{

View file

@ -19,7 +19,7 @@ use Friendica\BaseEntity;
* @property-read string $request
* @property-read string $photo
* @property-read string $note
* @property-read \DateTime created
* @property-read \DateTime $created
* @property-read int|null $id
*/
class FriendSuggest extends BaseEntity

View file

@ -9,7 +9,7 @@ namespace Friendica\Contact\FriendSuggest\Repository;
use Friendica\BaseRepository;
use Friendica\Contact\FriendSuggest\Collection;
use Friendica\Contact\FriendSuggest\Entity;
use Friendica\Contact\FriendSuggest\Entity\FriendSuggest as FriendSuggestEntity;
use Friendica\Contact\FriendSuggest\Exception\FriendSuggestNotFoundException;
use Friendica\Contact\FriendSuggest\Exception\FriendSuggestPersistenceException;
use Friendica\Contact\FriendSuggest\Factory;
@ -30,7 +30,7 @@ class FriendSuggest extends BaseRepository
parent::__construct($database, $logger, $factory);
}
private function convertToTableRow(Entity\FriendSuggest $fsuggest): array
private function convertToTableRow(FriendSuggestEntity $fsuggest): array
{
return [
'uid' => $fsuggest->uid,
@ -45,14 +45,9 @@ class FriendSuggest extends BaseRepository
}
/**
* @param array $condition
* @param array $params
*
* @return Entity\FriendSuggest
*
* @throws NotFoundException The underlying exception if there's no FriendSuggest with the given conditions
*/
private function selectOne(array $condition, array $params = []): Entity\FriendSuggest
private function selectOne(array $condition, array $params = []): FriendSuggestEntity
{
return parent::_selectOne($condition, $params);
}
@ -71,13 +66,9 @@ class FriendSuggest extends BaseRepository
}
/**
* @param int $id
*
* @return Entity\FriendSuggest
*
* @throws FriendSuggestNotFoundException in case there's no suggestion for this id
*/
public function selectOneById(int $id): Entity\FriendSuggest
public function selectOneById(int $id): FriendSuggestEntity
{
try {
return $this->selectOne(['id' => $id]);
@ -103,13 +94,9 @@ class FriendSuggest extends BaseRepository
}
/**
* @param Entity\FriendSuggest $fsuggest
*
* @return Entity\FriendSuggest
*
* @throws FriendSuggestNotFoundException in case the underlying storage cannot save the suggestion
*/
public function save(Entity\FriendSuggest $fsuggest): Entity\FriendSuggest
public function save(FriendSuggestEntity $fsuggest): FriendSuggestEntity
{
try {
$fields = $this->convertToTableRow($fsuggest);

View file

@ -106,10 +106,9 @@ class ContactSelector
* Determines network name
*
* @param string $network network of the contact
* @param string $profile optional, default empty
* @param string $protocol (Optional) Protocol that is used for the transmission
* @param int $gsid Server id
* @return string
*
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function networkToName(string $network, string $protocol = '', int $gsid = null): string

View file

@ -41,6 +41,7 @@ use Friendica\Util\DateTimeFormat;
use Friendica\Util\Profiler;
use Friendica\Util\Strings;
use Friendica\Util\Temporal;
use ImagickException;
use Psr\Log\LoggerInterface;
class Conversation
@ -112,7 +113,7 @@ class Conversation
* @param array &$conv_responses (already created with builtin activity structure)
* @return void
* @throws ImagickException
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
*/
public function builtinActivityPuller(array $activity, array &$conv_responses)
{
@ -598,7 +599,7 @@ class Conversation
* @param string $formSecurityToken A 'contact_action' form security token
* @return array
* @throws InternalServerErrorException
* @throws \ImagickException
* @throws ImagickException
*/
public function getThreadList(array $items, string $mode, bool $preview, bool $pagedrop, string $formSecurityToken): array
{

View file

@ -11,6 +11,7 @@ use Friendica\Content\Image\Collection\MasonryImageRow;
use Friendica\Content\Image\Entity\MasonryImage;
use Friendica\Content\Post\Collection\PostMedias;
use Friendica\Core\Renderer;
use Friendica\Network\HTTPException\ServiceUnavailableException;
class Image
{
@ -42,9 +43,7 @@ class Image
}
/**
* @param PostMedias $images
* @return string
* @throws \Friendica\Network\HTTPException\ServiceUnavailableException
* @throws ServiceUnavailableException
*/
private static function getImageGridHtml(PostMedias $images): string
{
@ -70,9 +69,7 @@ class Image
* For each row, we calculate how much of the total width each picture will take depending on their aspect ratio
* and how much relative height it needs to accomodate all pictures next to each other with their height normalized.
*
* @param array $images
* @return string
* @throws \Friendica\Network\HTTPException\ServiceUnavailableException
* @throws ServiceUnavailableException
*/
private static function getHorizontalMasonryHtml(PostMedias $images): string
{

View file

@ -32,6 +32,7 @@ use Friendica\Model\Post;
use Friendica\Model\Tag;
use Friendica\Model\User;
use Friendica\Network\HTTPException;
use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Object\EMail\ItemCCEMail;
use Friendica\Protocol\Activity;
use Friendica\Util\ACLFormatter;
@ -42,6 +43,7 @@ use Friendica\Util\Profiler;
use Friendica\Util\Proxy;
use Friendica\Util\XML;
use GuzzleHttp\Psr7\Uri;
use ImagickException;
/**
* A content helper class for displaying items
@ -174,8 +176,8 @@ class Item
* @param string $network The network of the post
*
* @return array|bool ['replaced' => $replaced, 'contact' => $contact] or "false" on if already replaced
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException
* @throws InternalServerErrorException
* @throws ImagickException
*/
public static function replaceTag(string &$body, int $profile_uid, string $tag, string $network = '')
{
@ -275,7 +277,7 @@ class Item
* @param array $item
* @return void
* @throws ImagickException
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
*/
public function localize(array &$item)
{
@ -645,11 +647,6 @@ class Item
/**
* Add a share block for the given guid
*
* @param string $guid
* @param integer $uid
* @param bool $add_media
* @return string
*/
private function createSharedPostByGuid(string $guid, bool $add_media): string
{

View file

@ -8,6 +8,7 @@
namespace Friendica\Content;
use DOMDocument;
use DOMElement;
use DOMXPath;
use Exception;
use Friendica\Content\Text\BBCode;
@ -83,6 +84,7 @@ class OEmbed
$xpath->query("//link[@type='application/json+oembed'] | //link[@type='text/json+oembed']")
as $link)
{
/** @var DOMElement $link */
$href = $link->getAttributeNode('href')->nodeValue;
// Both Youtube and Vimeo output OEmbed endpoint URL with HTTP
// but their OEmbed endpoint is only accessible by HTTPS ¯\_(ツ)_/¯

View file

@ -164,17 +164,17 @@ class PostMedia extends BaseEntity
/**
* Get preview path for given media id relative to the base URL
*
* @param string $size One of the Proxy::SIZE_* constants
* @param bool $vlurred If "true", the preview will be blurred
* @param string $size One of the Proxy::SIZE_* constants
* @param bool $blur If "true", the preview will be blurred
* @return string preview link
*/
public function getPreviewPath(string $size = '', bool $blurred = false): string
public function getPreviewPath(string $size = '', bool $blur = false): string
{
$path = '/photo/preview/' .
(Proxy::getPixelsFromSize($size) ? Proxy::getPixelsFromSize($size) . '/' : '') .
$this->id;
if ($blurred) {
if ($blur) {
$path .= '?' . http_build_query(['blur' => true]);
}
return $path;

View file

@ -824,11 +824,6 @@ class BBCode
/**
* Convert complex IMG and ZMG elements
*
* @param [type] $text
* @param integer $simplehtml
* @param integer $uriid
* @return string
*/
private static function convertImages(string $text, int $simplehtml, int $uriid = 0): string
{
@ -1113,7 +1108,7 @@ class BBCode
/**
* Removes links
*
* @param string $text HTML/BBCode string
* @param string $bbcode HTML/BBCode string
* @return string Cleaned HTML/BBCode
*/
public static function removeLinks(string $bbcode): string

View file

@ -966,7 +966,7 @@ class HTML
$text = $HTMLPurifier->purify($text);
/** @var \HTMLPurifier_ErrorCollector $errorCollector */
///** @var \HTMLPurifier_ErrorCollector $errorCollector */
// Uncomment to debug HTML Purifier behavior
//$errorCollector = $HTMLPurifier->context->get('ErrorCollector');
//var_dump($errorCollector->getRaw());

View file

@ -7,7 +7,10 @@
namespace Friendica\Content\Text;
use \HTMLPurifier_URIScheme;
use HTMLPurifier_Config;
use HTMLPurifier_Context;
use HTMLPurifier_URI;
use HTMLPurifier_URIScheme;
/**
* Validates content-id ("cid") as used in multi-part MIME messages, as defined by RFC 2392

View file

@ -7,6 +7,7 @@
namespace Friendica\Core;
use Exception;
use Friendica\App\Page;
use Friendica\Database\DBA;
use Friendica\DI;

View file

@ -18,7 +18,7 @@ interface ICanCache
/**
* Lists all cache keys
*
* @param string|null prefix optional a prefix to search
* @param string|null $prefix optional a prefix to search
*
* @return array Empty if it isn't supported by the cache driver
*/

View file

@ -7,7 +7,6 @@
namespace Friendica\Core\Config\Model;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Config\Capability\ISetConfigValuesTransactionally;
use Friendica\Core\Config\Exception\ConfigPersistenceException;
use Friendica\Core\Config\ValueObject\Cache;
@ -17,7 +16,7 @@ use Friendica\Core\Config\ValueObject\Cache;
*/
class ConfigTransaction implements ISetConfigValuesTransactionally
{
/** @var IManageConfigValues */
/** @var DatabaseConfig */
protected $config;
/** @var Cache */
protected $setCache;

View file

@ -345,10 +345,6 @@ class L10n
/**
* Provide a fallback which will not collide with a function defined in any language file
*
* @param int $n
*
* @return bool
*/
private function stringPluralSelectDefault(float $n): bool
{
@ -426,7 +422,7 @@ class L10n
$iso639 = new \Matriphe\ISO639\ISO639;
// In ISO 639-2 undetermined languages have got the code "und".
// There is no official code for ISO 639-1, but "un" is not assigned to any language.
// There is no official code for ISO 639-1, but "un" is not assigned to any language.
$languages = [self::UNDETERMINED_LANGUAGE => $this->t('Undetermined')];
foreach ($this->getDetectableLanguages() as $code) {

View file

@ -65,7 +65,7 @@ interface ICanLock
/**
* Lists all locks
*
* @param string prefix optional a prefix to search
* @param string $prefix optional a prefix to search
*
* @return string[] Empty if it isn't supported by the cache driver
*

View file

@ -16,12 +16,14 @@ use Friendica\Core\Lock\Exception\LockPersistenceException;
class CacheLock extends AbstractLock
{
/**
* @var string The static prefix of all locks inside the cache
* The static prefix of all locks inside the cache
*
* @var string
*/
const CACHE_PREFIX = 'lock:';
/**
* @var ICanCache;
* @var ICanCacheInMemory
*/
private $cache;

View file

@ -18,20 +18,24 @@ use Psr\Log\LogLevel;
class Logger
{
/**
* @var LoggerInterface The default Logger type
* LoggerInterface The default Logger type
*
* @var string
*/
const TYPE_LOGGER = LoggerInterface::class;
/**
* @var WorkerLogger A specific worker logger type, which can be enabled
* WorkerLogger A specific worker logger type, which can be enabled
*
* @var string
*/
const TYPE_WORKER = WorkerLogger::class;
/**
* @var LoggerInterface The current logger type
* @var string $type LoggerInterface The current logger type
*/
private static $type = self::TYPE_LOGGER;
/**
* @return LoggerInterface
* @return LoggerInterface|WorkerLogger
*/
private static function getInstance()
{
@ -52,7 +56,7 @@ class Logger
public static function enableWorker(string $functionName)
{
self::$type = self::TYPE_WORKER;
self::getInstance()->setFunctionName($functionName);
DI::workerLogger()->setFunctionName($functionName);
}
/**

View file

@ -55,7 +55,7 @@ class StreamLogger extends AbstractLogger
/**
* {@inheritdoc}
* @param string $level The minimum loglevel at which this logger will be triggered
* @param int $logLevel The minimum loglevel at which this logger will be triggered
*
* @throws LoggerException
*/

View file

@ -17,7 +17,7 @@ class LoggerSettingsCheck implements ICheckLoggerSettings
{
/** @var IManageConfigValues */
protected $config;
/** @var $fileSystem */
/** @var FileSystem */
protected $fileSystem;
/** @var L10n */
protected $l10n;
@ -38,10 +38,8 @@ class LoggerSettingsCheck implements ICheckLoggerSettings
try {
$stream = $this->fileSystem->createStream($file);
if (!isset($stream)) {
throw new LoggerUnusableException('Stream is null.');
}
} catch (LoggerUnusableException $exception) {
throw new LoggerUnusableException('Stream is null.', $exception);
} catch (\Throwable $exception) {
return $this->l10n->t('The logfile \'%s\' is not usable. No logging possible (error: \'%s\')', $file, $exception->getMessage());
}
@ -57,16 +55,14 @@ class LoggerSettingsCheck implements ICheckLoggerSettings
if ($this->config->get('system', 'debugging')) {
$file = $this->config->get('system', 'dlogfile');
if (empty($file)) {
if ($file === null || $file === '') {
return null;
}
try {
$stream = $this->fileSystem->createStream($file);
if (!isset($stream)) {
throw new LoggerUnusableException('Stream is null.');
}
} catch (LoggerUnusableException $exception) {
throw new LoggerUnusableException('Stream is null.', $exception);
} catch (\Throwable $exception) {
return $this->l10n->t('The debug logfile \'%s\' is not usable. No logging possible (error: \'%s\')', $file, $exception->getMessage());
}

View file

@ -274,24 +274,24 @@ class StorageManager
*/
public function register(string $class): bool
{
if (is_subclass_of($class, ICanReadFromStorage::class)) {
/** @var ICanReadFromStorage $class */
if ($this->isValidBackend($class::getName(), $this->validBackends)) {
return true;
}
$backends = $this->validBackends;
$backends[] = $class::getName();
if ($this->config->set('storage', 'backends', $backends)) {
$this->validBackends = $backends;
return true;
} else {
return false;
}
} else {
if (!is_subclass_of($class, ICanReadFromStorage::class)) {
return false;
}
/** @var class-string<ICanReadFromStorage> $class */
if ($this->isValidBackend($class::getName(), $this->validBackends)) {
return true;
}
$backends = $this->validBackends;
$backends[] = $class::getName();
if ($this->config->set('storage', 'backends', $backends)) {
$this->validBackends = $backends;
return true;
}
return false;
}
/**
@ -305,30 +305,31 @@ class StorageManager
*/
public function unregister(string $class): bool
{
if (is_subclass_of($class, ICanReadFromStorage::class)) {
/** @var ICanReadFromStorage $class */
if ($this->currentBackend::getName() == $class::getName()) {
throw new StorageException(sprintf('Cannot unregister %s, because it\'s currently active.', $class::getName()));
}
$key = array_search($class::getName(), $this->validBackends);
if ($key !== false) {
$backends = $this->validBackends;
unset($backends[$key]);
$backends = array_values($backends);
if ($this->config->set('storage', 'backends', $backends)) {
$this->validBackends = $backends;
return true;
} else {
return false;
}
} else {
return true;
}
} else {
if (!is_subclass_of($class, ICanReadFromStorage::class)) {
return false;
}
/** @var class-string<ICanReadFromStorage> $class */
if ($this->currentBackend::getName() == $class::getName()) {
throw new StorageException(sprintf('Cannot unregister %s, because it\'s currently active.', $class::getName()));
}
$key = array_search($class::getName(), $this->validBackends);
if ($key === false) {
return true;
}
$backends = $this->validBackends;
unset($backends[$key]);
$backends = array_values($backends);
if ($this->config->set('storage', 'backends', $backends)) {
$this->validBackends = $backends;
return true;
}
return false;
}
/**

View file

@ -8,10 +8,8 @@
namespace Friendica\Core;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\DI;
use Friendica\Model\User;
use Friendica\Module\Response;
use Friendica\Network\HTTPException\FoundException;
use Friendica\Network\HTTPException\InternalServerErrorException;
@ -325,9 +323,9 @@ class System
/**
* Send HTTP status header and exit.
*
* @param integer $val HTTP status result value
* @param string $message Error message. Optional.
* @param string $content Response body. Optional.
* @param integer $httpCode HTTP status result value
* @param string $message Error message. Optional.
* @param string $content Response body. Optional.
* @throws \Exception
* @deprecated since 2023.09 Use BaseModule->httpError instead
*/

View file

@ -824,7 +824,11 @@ class Worker
$max_idletime = DI::config()->get('system', 'worker_max_idletime');
$last_check = DI::cache()->get(self::LAST_CHECK);
$last_date = $last_check ? date('c', $last_check) : '';
if (($max_idletime > 0) && (time() > $last_check + $max_idletime) && !DBA::exists('workerqueue', ["`done` AND `executed` > ?", DateTimeFormat::utc('now - ' . $max_idletime . ' second')])) {
if (
($max_idletime > 0)
&& (time() > (int) $last_check + (int) $max_idletime)
&& !DBA::exists('workerqueue', ["`done` AND `executed` > ?", DateTimeFormat::utc('now - ' . $max_idletime . ' second')])
) {
DI::cache()->set(self::LAST_CHECK, time(), Duration::HOUR);
Logger::info('The last worker execution had been too long ago.', ['last' => $last_check, 'last-check' => $last_date, 'seconds' => $max_idletime, 'load' => $load, 'max_load' => $maxsysload, 'active_worker' => $active, 'max_worker' => $maxqueues]);
return false;
@ -1211,7 +1215,7 @@ class Worker
/**
* Adds tasks to the worker queue
*
* @param (integer|array) priority or parameter array, strings are deprecated and are ignored
* @param integer|array $args priority or parameter array, strings are deprecated and are ignored
*
* next args are passed as $cmd command line
* or: Worker::add(Worker::PRIORITY_HIGH, 'Notifier', Delivery::DELETION, $drop_id);

View file

@ -81,7 +81,7 @@ class Process extends BaseRepository
'pid' => $process->pid,
'hostname' => $this->currentHost,
])) {
throw new ProcessPersistenceException(sprintf('The process with PID %s doesn\'t exists.', $process->pi));
throw new ProcessPersistenceException(sprintf('The process with PID %d doesn\'t exists.', $process->pid));
}
} catch (\Exception $exception) {
throw new ProcessPersistenceException(sprintf('Cannot delete process with PID %s.', $process->pid), $exception);

View file

@ -164,7 +164,7 @@ abstract class DI
}
/**
* @return AtProtocol\Arguments
* @return ATProtocol\Actor
*/
public static function atpActor()
{
@ -341,7 +341,7 @@ abstract class DI
}
/**
* @return LoggerInterface
* @return \Friendica\Core\Logger\Type\WorkerLogger
*/
public static function workerLogger()
{
@ -554,7 +554,7 @@ abstract class DI
//
/**
* @return Contact\FriendSuggest\Repository\FriendSuggest;
* @return Contact\FriendSuggest\Repository\FriendSuggest
*/
public static function fsuggest()
{
@ -562,7 +562,7 @@ abstract class DI
}
/**
* @return Contact\FriendSuggest\Factory\FriendSuggest;
* @return Contact\FriendSuggest\Factory\FriendSuggest
*/
public static function fsuggestFactory()
{

View file

@ -233,7 +233,7 @@ class DBA
/**
* Returns the number of columns of a statement
*
* @param object Statement object
* @param object $stmt Statement object
* @return int Number of columns
*/
public static function columnCount($stmt): int
@ -243,7 +243,7 @@ class DBA
/**
* Returns the number of rows of a statement
*
* @param PDOStatement|mysqli_result|mysqli_stmt Statement object
* @param PDOStatement|mysqli_result|mysqli_stmt $stmt Statement object
* @return int Number of rows
*/
public static function numRows($stmt): int
@ -364,9 +364,9 @@ class DBA
* @return boolean was the delete successful?
* @throws \Exception
*/
public static function delete(string $table, array $conditions, array $options = []): bool
public static function delete(string $table, array $conditions): bool
{
return DI::dba()->delete($table, $conditions, $options);
return DI::dba()->delete($table, $conditions);
}
/**
@ -756,7 +756,7 @@ class DBA
/**
* Returns the error number of the last query
*
* @return string Error number (0 if no error)
* @return int Error number (0 if no error)
*/
public static function errorNo(): int
{
@ -813,8 +813,8 @@ class DBA
/**
* Acquire a lock to prevent a table optimization
*
* @return bool
* @throws LockPersistenceException
* @return bool
* @throws LockPersistenceException
*/
public static function acquireOptimizeLock(): bool
{
@ -823,8 +823,8 @@ class DBA
/**
* Release the table optimization lock
* @return bool
* @throws LockPersistenceException
* @return bool
* @throws LockPersistenceException
*/
public static function releaseOptimizeLock(): bool
{

View file

@ -552,8 +552,10 @@ class Database
break;
}
/** @var $stmt mysqli_stmt|PDOStatement */
if (!$stmt = $this->connection->prepare($sql)) {
/** @var mysqli_stmt|PDOStatement $stmt */
$stmt = $this->connection->prepare($sql);
if (!$stmt) {
$errorInfo = $this->connection->errorInfo();
$this->error = (string)$errorInfo[2];
$this->errorno = (int)$errorInfo[1];
@ -889,7 +891,7 @@ class Database
/**
* Returns the number of columns of a statement
*
* @param object Statement object
* @param object $stmt Statement object
*
* @return int Number of columns
*/
@ -910,7 +912,7 @@ class Database
/**
* Returns the number of rows of a statement
*
* @param PDOStatement|mysqli_result|mysqli_stmt Statement object
* @param PDOStatement|mysqli_result|mysqli_stmt $stmt Statement object
*
* @return int Number of rows
*/
@ -1652,7 +1654,7 @@ class Database
/**
* Returns the error number of the last query
*
* @return string Error number (0 if no error)
* @return int Error number (0 if no error)
*/
public function errorNo(): int
{

View file

@ -8,10 +8,8 @@
namespace Friendica\Factory\Api\Mastodon;
use Friendica\BaseFactory;
use Friendica\Content\Text\BBCode;
use Friendica\Model\Post;
use Friendica\Network\HTTPException;
use Friendica\Util\Strings;
class Card extends BaseFactory
{
@ -21,7 +19,8 @@ class Card extends BaseFactory
*
* @return \Friendica\Object\Api\Mastodon\Card
* @throws HTTPException\InternalServerErrorException
* @throws \ImagickException*@throws \Exception
* @throws \ImagickException
* @throws \Exception
*/
public function createFromUriId(int $uriId, array $history = []): \Friendica\Object\Api\Mastodon\Card
{

View file

@ -9,7 +9,7 @@ namespace Friendica\Factory\Api\Mastodon;
use Friendica\BaseFactory;
use Friendica\Model\Contact;
use Friendica\Navigation\Notifications;
use Friendica\Navigation\Notifications\Entity\Notification as NotificationEntity;
use Friendica\Navigation\Notifications\Exception\UnexpectedNotificationTypeException;
use Friendica\Object\Api\Mastodon\Notification as MstdnNotification;
use Friendica\Protocol\Activity;
@ -32,16 +32,17 @@ class Notification extends BaseFactory
}
/**
* @param Notifications\Entity\Notification $Notification
* @param bool $display_quote Display quoted posts
* @param NotificationEntity $Notification
* @param bool $display_quotes Display quoted posts
*
* @return MstdnNotification
* @throws UnexpectedNotificationTypeException
*/
public function createFromNotification(Notifications\Entity\Notification $Notification, bool $display_quotes): MstdnNotification
public function createFromNotification(NotificationEntity $Notification, bool $display_quotes): MstdnNotification
{
$type = self::getType($Notification);
if (empty($type)) {
if ($type === '') {
throw new UnexpectedNotificationTypeException();
}

View file

@ -20,7 +20,8 @@ use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Model\Verb;
use Friendica\Network\HTTPException;
use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Network\HTTPException\NotFoundException;
use Friendica\Object\Api\Mastodon\Status\FriendicaDeliveryData;
use Friendica\Object\Api\Mastodon\Status\FriendicaExtension;
use Friendica\Object\Api\Mastodon\Status\FriendicaVisibility;
@ -87,8 +88,8 @@ class Status extends BaseFactory
* @param bool $in_reply_status Add an "in_reply_status" element
*
* @return \Friendica\Object\Api\Mastodon\Status
* @throws HTTPException\InternalServerErrorException
* @throws ImagickException|HTTPException\NotFoundException
* @throws InternalServerErrorException
* @throws ImagickException|NotFoundException
*/
public function createFromUriId(int $uriId, int $uid = 0, bool $display_quote = false, bool $reblog = true, bool $in_reply_status = true): \Friendica\Object\Api\Mastodon\Status
{
@ -101,7 +102,7 @@ class Status extends BaseFactory
if ($mail) {
return $this->createFromMailId($mail['id']);
}
throw new HTTPException\NotFoundException('Item with URI ID ' . $uriId . ' not found' . ($uid ? ' for user ' . $uid : '.'));
throw new NotFoundException('Item with URI ID ' . $uriId . ' not found' . ($uid ? ' for user ' . $uid : '.'));
}
$activity_fields = ['uri-id', 'thr-parent-id', 'uri', 'author-id', 'author-uri-id', 'author-link', 'app', 'created', 'network', 'parent-author-id', 'private'];
@ -113,7 +114,7 @@ class Status extends BaseFactory
$activity = $item;
$item = Post::selectFirst($fields, ['uri-id' => $uriId, 'uid' => [0, $uid]], ['order' => ['uid' => true]]);
if (!$item) {
throw new HTTPException\NotFoundException('Item with URI ID ' . $uriId . ' not found' . ($uid ? ' for user ' . $uid : '.'));
throw new NotFoundException('Item with URI ID ' . $uriId . ' not found' . ($uid ? ' for user ' . $uid : '.'));
}
foreach ($activity_fields as $field) {
$item[$field] = $activity[$field];
@ -202,7 +203,7 @@ class Status extends BaseFactory
$sensitive = (bool)$item['sensitive'];
$network = ContactSelector::networkToName($item['network']);
$sitename = '';
$sitename = '';
$platform = '';
$version = '';
@ -211,7 +212,7 @@ class Status extends BaseFactory
if (!empty($gserver)) {
$platform = ucfirst($gserver['platform']);
$version = $gserver['version'];
$sitename = $gserver['site_name'];
$sitename = $gserver['site_name'];
}
}
@ -370,17 +371,17 @@ class Status extends BaseFactory
}
/**
* @param int $uriId id of the mail
* @param int $id id of the mail
*
* @return \Friendica\Object\Api\Mastodon\Status
* @throws HTTPException\InternalServerErrorException
* @throws ImagickException|HTTPException\NotFoundException
* @throws InternalServerErrorException
* @throws ImagickException|NotFoundException
*/
public function createFromMailId(int $id): \Friendica\Object\Api\Mastodon\Status
{
$item = ActivityPub\Transmitter::getItemArrayFromMail($id, true);
if (empty($item)) {
throw new HTTPException\NotFoundException('Mail record not found with id: ' . $id);
throw new NotFoundException('Mail record not found with id: ' . $id);
}
$account = $this->mstdnAccountFactory->createFromContactId($item['author-id']);

View file

@ -20,7 +20,8 @@ class StatusSource extends BaseFactory
*
* @return \Friendica\Object\Api\Mastodon\StatusSource
* @throws HTTPException\InternalServerErrorException
* @throws \ImagickException*@throws \Exception
* @throws \ImagickException
* @throws \Exception
*/
public function createFromUriId(int $uriId, int $uid): \Friendica\Object\Api\Mastodon\StatusSource
{

View file

@ -10,18 +10,17 @@ namespace Friendica\Factory\Api\Mastodon;
use Friendica\BaseFactory;
use Friendica\Database\DBA;
use Friendica\Model\Subscription as ModelSubscription;
use Friendica\Object\Api\Mastodon\Subscription as SubscriptionObject;
class Subscription extends BaseFactory
{
/**
* @param int $applicationid Application Id
* @param int $uid Item user
*
* @return \Friendica\Object\Api\Mastodon\Status
*/
public function createForApplicationIdAndUserId(int $applicationid, int $uid): \Friendica\Object\Api\Mastodon\Subscription
public function createForApplicationIdAndUserId(int $applicationid, int $uid): SubscriptionObject
{
$subscription = DBA::selectFirst('subscription', [], ['application-id' => $applicationid, 'uid' => $uid]);
return new \Friendica\Object\Api\Mastodon\Subscription($subscription, ModelSubscription::getPublicVapidKey());
return new SubscriptionObject($subscription, ModelSubscription::getPublicVapidKey());
}
}

View file

@ -17,7 +17,8 @@ use Friendica\Factory\Api\Twitter\User as TwitterUser;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Model\Verb;
use Friendica\Network\HTTPException;
use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Network\HTTPException\NotFoundException;
use Friendica\Protocol\Activity;
use ImagickException;
use Psr\Log\LoggerInterface;
@ -58,13 +59,13 @@ class Status extends BaseFactory
}
/**
* @param int $uriId Uri-ID of the item
* @param int $id Uri-ID of the item
* @param int $uid Item user
* @param bool $include_entities Whether to include entities
*
* @return \Friendica\Object\Api\Twitter\Status
* @throws HTTPException\InternalServerErrorException
* @throws ImagickException|HTTPException\NotFoundException
* @throws InternalServerErrorException
* @throws ImagickException|NotFoundException
*/
public function createFromItemId(int $id, int $uid, bool $include_entities = false): \Friendica\Object\Api\Twitter\Status
{
@ -73,7 +74,7 @@ class Status extends BaseFactory
'thr-parent-id', 'parent-author-id', 'parent-author-nick', 'uri', 'plink', 'private', 'vid', 'coord', 'quote-uri-id'];
$item = Post::selectFirst($fields, ['id' => $id], ['order' => ['uid' => true]]);
if (!$item) {
throw new HTTPException\NotFoundException('Item with ID ' . $id . ' not found.');
throw new NotFoundException('Item with ID ' . $id . ' not found.');
}
return $this->createFromArray($item, $uid, $include_entities);
}
@ -84,8 +85,8 @@ class Status extends BaseFactory
* @param bool $include_entities Whether to include entities
*
* @return \Friendica\Object\Api\Twitter\Status
* @throws HTTPException\InternalServerErrorException
* @throws ImagickException|HTTPException\NotFoundException
* @throws InternalServerErrorException
* @throws ImagickException|NotFoundException
*/
public function createFromUriId(int $uriId, int $uid = 0, bool $include_entities = false): \Friendica\Object\Api\Twitter\Status
{
@ -94,7 +95,7 @@ class Status extends BaseFactory
'thr-parent-id', 'parent-author-id', 'parent-author-nick', 'uri', 'plink', 'private', 'vid', 'coord'];
$item = Post::selectFirst($fields, ['uri-id' => $uriId, 'uid' => [0, $uid]], ['order' => ['uid' => true]]);
if (!$item) {
throw new HTTPException\NotFoundException('Item with URI ID ' . $uriId . ' not found' . ($uid ? ' for user ' . $uid : '.'));
throw new NotFoundException('Item with URI ID ' . $uriId . ' not found' . ($uid ? ' for user ' . $uid : '.'));
}
return $this->createFromArray($item, $uid, $include_entities);
}
@ -105,8 +106,8 @@ class Status extends BaseFactory
* @param bool $include_entities Whether to include entities
*
* @return \Friendica\Object\Api\Twitter\Status
* @throws HTTPException\InternalServerErrorException
* @throws ImagickException|HTTPException\NotFoundException
* @throws InternalServerErrorException
* @throws ImagickException|NotFoundException
*/
private function createFromArray(array $item, int $uid, bool $include_entities): \Friendica\Object\Api\Twitter\Status
{
@ -161,8 +162,8 @@ class Status extends BaseFactory
if ($include_entities) {
$hashtags = $this->hashtag->createFromUriId($item['uri-id'], $text);
$medias = $this->media->createFromUriId($item['uri-id'], $text);
$urls = $this->url->createFromUriId($item['uri-id'], $text);
$mentions = $this->mention->createFromUriId($item['uri-id'], $text);
$urls = $this->url->createFromUriId($item['uri-id']);
$mentions = $this->mention->createFromUriId($item['uri-id']);
} else {
$attachments = $this->attachment->createFromUriId($item['uri-id'], $text);
}
@ -176,8 +177,8 @@ class Status extends BaseFactory
if ($include_entities) {
$hashtags = array_merge($hashtags, $this->hashtag->createFromUriId($shared_uri_id, $text));
$medias = array_merge($medias, $this->media->createFromUriId($shared_uri_id, $text));
$urls = array_merge($urls, $this->url->createFromUriId($shared_uri_id, $text));
$mentions = array_merge($mentions, $this->mention->createFromUriId($shared_uri_id, $text));
$urls = array_merge($urls, $this->url->createFromUriId($shared_uri_id));
$mentions = array_merge($mentions, $this->mention->createFromUriId($shared_uri_id));
} else {
$attachments = array_merge($attachments, $this->attachment->createFromUriId($shared_uri_id, $text));
}

View file

@ -12,11 +12,11 @@ use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Core\Storage\Exception\InvalidClassStorageException;
use Friendica\Core\Storage\Exception\ReferenceStorageException;
use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Object\Image;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Mimetype;
use Friendica\Security\Security;
use Friendica\Util\Network;
/**
* Class to handle attach database table
@ -183,7 +183,7 @@ class Attach
* @param string $deny_gid Permissions, denied circle. optional, default = ''
*
* @return boolean|integer Row id on success, False on errors
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
*/
public static function store(string $data, int $uid, string $filename, string $filetype = '', int $filesize = null, string $allow_cid = '', string $allow_gid = '', string $deny_cid = '', string $deny_gid = '')
{
@ -237,7 +237,7 @@ class Attach
* @param string $deny_cid
* @param string $deny_gid
* @return boolean|int Insert id or false on failure
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
*/
public static function storeFile(string $src, int $uid, string $filename = '', string $filetype = '', string $allow_cid = '', string $allow_gid = '', string $deny_cid = '', string $deny_gid = '')
{
@ -257,11 +257,11 @@ class Attach
* @param array $fields Contains the fields that are updated
* @param array $conditions Condition array with the key values
* @param Image $img Image data to update. Optional, default null.
* @param array|boolean $old_fields Array with the old field values that are about to be replaced (true = update on duplicate)
* @param array $old_fields Array with the old field values that are about to be replaced (true = update on duplicate)
*
* @return boolean Was the update successful?
*
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @see \Friendica\Database\DBA::update
*/
public static function update(array $fields, array $conditions, Image $img = null, array $old_fields = []): bool
@ -287,19 +287,17 @@ class Attach
return DBA::update('attach', $fields, $conditions, $old_fields);
}
/**
* Delete info from table and data from storage
*
* @param array $conditions Field condition(s)
* @param array $options Options array, Optional
*
* @return boolean
*
* @throws \Exception
* @see \Friendica\Database\DBA::delete
*/
public static function delete(array $conditions, array $options = []): bool
public static function delete(array $conditions): bool
{
// get items to delete data info
$items = self::selectToArray(['backend-class', 'backend-ref'], $conditions);
@ -315,7 +313,7 @@ class Attach
}
}
return DBA::delete('attach', $conditions, $options);
return DBA::delete('attach', $conditions);
}
public static function setPermissionFromBody(array $post)

View file

@ -7,10 +7,10 @@
namespace Friendica\Model;
use Exception;
use Friendica\Contact\Avatar;
use Friendica\Contact\Header;
use Friendica\Contact\Introduction\Exception\IntroductionNotFoundException;
use Friendica\Contact\LocalRelationship\Entity\LocalRelationship;
use Friendica\Content\Conversation as ConversationContent;
use Friendica\Content\Pager;
use Friendica\Content\Text\HTML;
@ -25,7 +25,8 @@ use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
use Friendica\Network\HTTPClient\Client\HttpClientOptions;
use Friendica\Network\HTTPException;
use Friendica\Network\HTTPException\NotFoundException;
use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Network\Probe;
use Friendica\Object\Image;
use Friendica\Protocol\Activity;
@ -104,7 +105,7 @@ class Contact
* @param array $condition Array of fields for condition
* @param array $params Array of several parameters
* @return array
* @throws \Exception
* @throws Exception
*/
public static function selectToArray(array $fields = [], array $condition = [], array $params = []): array
{
@ -116,7 +117,7 @@ class Contact
* @param array $condition Array of fields for condition
* @param array $params Array of several parameters
* @return array|bool
* @throws \Exception
* @throws Exception
*/
public static function selectFirst(array $fields = [], array $condition = [], array $params = [])
{
@ -130,7 +131,7 @@ class Contact
* @param array $condition Array of fields for condition
* @param array $params Array of several parameters
* @return array
* @throws \Exception
* @throws Exception
*/
public static function selectAccountToArray(array $fields = [], array $condition = [], array $params = []): array
{
@ -142,7 +143,7 @@ class Contact
* @param array $condition Array of fields for condition
* @param array $params Array of several parameters
* @return array|bool
* @throws \Exception
* @throws Exception
*/
public static function selectFirstAccount(array $fields = [], array $condition = [], array $params = [])
{
@ -162,7 +163,7 @@ class Contact
* @param int $duplicate_mode Do an update on a duplicate entry
*
* @return int id of the created contact
* @throws \Exception
* @throws Exception
*/
public static function insert(array $fields, int $duplicate_mode = Database::INSERT_DEFAULT): int
{
@ -233,7 +234,7 @@ class Contact
* @param array|boolean $old_fields array with the old field values that are about to be replaced (true = update on duplicate, false = don't update identical fields)
*
* @return boolean was the update successful?
* @throws \Exception
* @throws Exception
* @todo Let's get rid of boolean type of $old_fields
*/
public static function update(array $fields, array $condition, $old_fields = []): bool
@ -249,7 +250,7 @@ class Contact
* @param integer $id Contact ID
* @param array $fields Array of selected fields, empty for all
* @return array|boolean Contact record if it exists, false otherwise
* @throws \Exception
* @throws Exception
*/
public static function getAccountById(int $id, array $fields = [])
{
@ -260,7 +261,7 @@ class Contact
* @param integer $id Contact ID
* @param array $fields Array of selected fields, empty for all
* @return array|boolean Contact record if it exists, false otherwise
* @throws \Exception
* @throws Exception
*/
public static function getById(int $id, array $fields = [])
{
@ -273,7 +274,7 @@ class Contact
* @param integer $uri_id uri-id of the contact
* @param array $fields Array of selected fields, empty for all
* @return array|boolean Contact record if it exists, false otherwise
* @throws \Exception
* @throws Exception
*/
public static function getByUriId(int $uri_id, array $fields = [])
{
@ -288,7 +289,7 @@ class Contact
*
* @return array all remote contacts
*
* @throws \Exception
* @throws Exception
*/
public static function getVisitorByUrl(string $url, array $fields = ['id', 'uid']): array
{
@ -432,7 +433,7 @@ class Contact
* @param bool $strict If "true" then contact mustn't be set to pending or readonly
*
* @return boolean is the contact id a follower?
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function isFollower(int $cid, int $uid, bool $strict = false): bool
@ -461,7 +462,7 @@ class Contact
* @param bool $strict If "true" then contact mustn't be set to pending or readonly
*
* @return boolean is the contact id a follower?
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function isFollowerByURL(string $url, int $uid, bool $strict = false): bool
@ -483,7 +484,7 @@ class Contact
* @param bool $strict If "true" then contact mustn't be set to pending or readonly
*
* @return boolean is the contact sharing with given user?
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function isSharing(int $cid, int $uid, bool $strict = false): bool
@ -512,7 +513,7 @@ class Contact
* @param bool $strict If "true" then contact mustn't be set to pending or readonly
*
* @return boolean is the contact url being followed?
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function isSharingByURL(string $url, int $uid, bool $strict = false): bool
@ -544,7 +545,7 @@ class Contact
* @param boolean $dont_update Don't update the contact
*
* @return string basepath
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function getBasepath(string $url, bool $dont_update = false): string
@ -594,7 +595,7 @@ class Contact
/**
* Check if the given contact ID is on the same server
*
* @param string $url The contact link
* @param int $cid The contact link
* @return boolean Is it the same server?
*/
public static function isLocalById(int $cid): bool
@ -619,7 +620,7 @@ class Contact
* @param integer $uid User ID
*
* @return integer|boolean Public contact id for given user id
* @throws \Exception
* @throws Exception
*/
public static function getPublicIdByUserId(int $uid)
{
@ -634,7 +635,7 @@ class Contact
* @param int $uid User ID
*
* @return array with public and user's contact id
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function getPublicAndUserContactID(int $cid, int $uid): array
@ -700,7 +701,7 @@ class Contact
* @param int $cid Either public contact id or user's contact id
* @param int $uid User ID
* @return array with public and user's contact id
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
private static function legacyGetPublicAndUserContactID(int $cid, int $uid): array
@ -741,7 +742,7 @@ class Contact
* @param array $fields The selected fields for the contact
* @return array The contact details
*
* @throws \Exception
* @throws Exception
*/
public static function getContactForUser(int $cid, int $uid, array $fields = []): array
{
@ -759,7 +760,7 @@ class Contact
*
* @param int $uid
* @return bool Operation success
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
*/
public static function createSelfFromUserId(int $uid): bool
{
@ -822,7 +823,7 @@ class Contact
* @param int $uid
* @param bool $update_avatar Force the avatar update
* @return bool "true" if updated
* @throws \Exception
* @throws Exception
*/
public static function updateSelfFromUserID(int $uid, bool $update_avatar = false): bool
{
@ -943,7 +944,7 @@ class Contact
*
* @param int $id contact id
* @return void
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
*/
public static function remove(int $id)
{
@ -973,7 +974,7 @@ class Contact
*
* @param array $contact Target user-specific contact (uid != 0) array
* @return void
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function unfollow(array $contact): void
@ -1003,7 +1004,7 @@ class Contact
*
* @param array $contact User-specific contact array (uid != 0) to revoke the follow from
* @return void
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function revokeFollow(array $contact): void
@ -1031,7 +1032,7 @@ class Contact
*
* @param array $contact User-specific contact (uid != 0) array
* @return void
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function terminateFriendship(array $contact)
@ -1078,7 +1079,7 @@ class Contact
*
* @param array $contact contact to mark for archival
* @return void
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
*/
public static function markForArchival(array $contact)
{
@ -1129,7 +1130,7 @@ class Contact
*
* @param array $contact contact to be unmarked for archival
* @return void
* @throws \Exception
* @throws Exception
*/
public static function unmarkForArchival(array $contact)
{
@ -1169,7 +1170,7 @@ class Contact
* @param array $contact contact
* @param int $uid Visitor user id
* @return array
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function photoMenu(array $contact, int $uid): array
@ -1301,7 +1302,7 @@ class Contact
* @param array $default Default value for creating the contact when everything else fails
*
* @return integer Contact ID
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function getIdForURL(string $url = null, int $uid = 0, $update = null, array $default = []): int
@ -1442,7 +1443,7 @@ class Contact
if ($data['network'] == Protocol::DIASPORA) {
try {
DI::dsprContact()->updateFromProbeArray($data);
} catch (HTTPException\NotFoundException $e) {
} catch (NotFoundException $e) {
Logger::notice($e->getMessage(), ['url' => $url, 'data' => $data]);
} catch (\InvalidArgumentException $e) {
Logger::notice($e->getMessage(), ['url' => $url, 'data' => $data]);
@ -1450,7 +1451,7 @@ class Contact
} elseif (!empty($data['networks'][Protocol::DIASPORA])) {
try {
DI::dsprContact()->updateFromProbeArray($data['networks'][Protocol::DIASPORA]);
} catch (HTTPException\NotFoundException $e) {
} catch (NotFoundException $e) {
Logger::notice($e->getMessage(), ['url' => $url, 'data' => $data['networks'][Protocol::DIASPORA]]);
} catch (\InvalidArgumentException $e) {
Logger::notice($e->getMessage(), ['url' => $url, 'data' => $data['networks'][Protocol::DIASPORA]]);
@ -1475,7 +1476,7 @@ class Contact
* @param int $cid contact id
*
* @return boolean Is the contact archived?
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
*/
public static function isArchived(int $cid): bool
{
@ -1518,7 +1519,7 @@ class Contact
*
* @param int $cid contact id
* @return boolean Is the contact blocked?
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
*/
public static function isBlocked(int $cid): bool
{
@ -1543,7 +1544,7 @@ class Contact
*
* @param int $cid contact id
* @return boolean Is the contact hidden?
* @throws \Exception
* @throws Exception
*/
public static function isHidden(int $cid): bool
{
@ -1566,7 +1567,7 @@ class Contact
* @param bool $only_media Only display media content
* @param string $last_created Newest creation date, used for paging
* @return string posts in HTML
* @throws \Exception
* @throws Exception
*/
public static function getPostsFromUrl(string $contact_url, int $uid, bool $only_media = false, string $last_created = null): string
{
@ -1581,7 +1582,7 @@ class Contact
* @param bool $only_media Only display media content
* @param string $last_created Newest creation date, used for paging
* @return string posts in HTML
* @throws \Exception
* @throws Exception
*/
public static function getPostsFromId(int $cid, int $uid, bool $only_media = false, string $last_created = null): string
{
@ -1653,7 +1654,7 @@ class Contact
* @param int $update Update mode
* @param int $parent Item parent ID for the update mode
* @return string posts in HTML
* @throws \Exception
* @throws Exception
*/
public static function getThreadsFromId(int $cid, int $uid, int $update = 0, int $parent = 0, string $last_created = ''): string
{
@ -2286,8 +2287,8 @@ class Contact
* @param bool $create_cache Enforces the creation of cached avatar fields
*
* @return void
* @throws HTTPException\InternalServerErrorException
* @throws HTTPException\NotFoundException
* @throws InternalServerErrorException
* @throws NotFoundException
* @throws \ImagickException
*/
public static function updateAvatar(int $cid, string $avatar, bool $force = false, bool $create_cache = false)
@ -2486,7 +2487,7 @@ class Contact
* @param integer $id contact id
* @param string $url The new URL to use for polling
*
* @throws \Exception
* @throws Exception
*/
public static function updatePollUrl(int $id, string $url)
{
@ -2502,7 +2503,7 @@ class Contact
* @param string $url The profile URL of the contact
* @param array $fields The fields that are updated
*
* @throws \Exception
* @throws Exception
*/
private static function updateContact(int $id, int $uid, int $uri_id, string $url, array $fields)
{
@ -2595,7 +2596,7 @@ class Contact
* @param string $nurl Normalised contact url
* @param integer $uid User id
* @return boolean
* @throws \Exception
* @throws Exception
*/
public static function removeDuplicates(string $nurl, int $uid)
{
@ -2673,7 +2674,7 @@ class Contact
* @param integer $id contact id
* @param string $network Optional network we are probing for
* @return boolean
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function updateFromProbe(int $id, string $network = ''): bool
@ -2696,7 +2697,7 @@ class Contact
if ($data['network'] == Protocol::DIASPORA) {
try {
DI::dsprContact()->updateFromProbeArray($data);
} catch (HTTPException\NotFoundException $e) {
} catch (NotFoundException $e) {
Logger::notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
} catch (\InvalidArgumentException $e) {
Logger::notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
@ -2704,7 +2705,7 @@ class Contact
} elseif (!empty($data['networks'][Protocol::DIASPORA])) {
try {
DI::dsprContact()->updateFromProbeArray($data['networks'][Protocol::DIASPORA]);
} catch (HTTPException\NotFoundException $e) {
} catch (NotFoundException $e) {
Logger::notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
} catch (\InvalidArgumentException $e) {
Logger::notice($e->getMessage(), ['id' => $id, 'network' => $network, 'contact' => $contact, 'data' => $data]);
@ -2760,7 +2761,7 @@ class Contact
* @param integer $id contact id
* @param array $ret Probed data
* @return boolean
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
private static function updateFromProbeArray(int $id, array $ret): bool
@ -3012,9 +3013,9 @@ class Contact
/**
* Updates contact record by provided URL
*
* @param integer $url contact url
* @return integer Contact id
* @throws HTTPException\InternalServerErrorException
* @param string $url contact url
* @return int Contact id
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function updateFromProbeByURL(string $url): int
@ -3069,8 +3070,8 @@ class Contact
* @param string $url The profile URL of the contact
* @param string $network
* @return array
* @throws HTTPException\InternalServerErrorException
* @throws HTTPException\NotFoundException
* @throws InternalServerErrorException
* @throws NotFoundException
* @throws \ImagickException
*/
public static function createFromProbeForUser(int $uid, string $url, string $network = ''): array
@ -3258,7 +3259,7 @@ class Contact
* @param bool $sharing True: Contact is now sharing with Owner; False: Contact is now following Owner (default)
* @param string $note Introduction additional message
* @return bool|null True: follow request is accepted; False: relationship is rejected; Null: relationship is pending
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function addRelationship(array $importer, array $contact, array $datarray, bool $sharing = false, string $note = '')
@ -3415,7 +3416,7 @@ class Contact
* @param array $contact User-specific contact (uid != 0) array
* @param bool $delete Delete if set, otherwise set relation to "nothing" when contact had been a follower
* @return void
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function removeFollower(array $contact, bool $delete = true)
@ -3449,7 +3450,7 @@ class Contact
*
* @param array $contact User-specific contact (uid != 0) array
* @param bool $delete Delete if set, otherwise set relation to "nothing" when contact had been a sharer
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
*/
public static function removeSharer(array $contact, bool $delete = true)
{
@ -3512,7 +3513,7 @@ class Contact
*
* @param array $contact_ids Contact id list
* @return array
* @throws \Exception
* @throws Exception
*/
public static function pruneUnavailable(array $contact_ids): array
{
@ -3554,7 +3555,7 @@ class Contact
* @param string $url An url that we will be redirected to after the authentication
*
* @return string with "redir" link
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function magicLink(string $contact_url, string $url = ''): string
@ -3581,7 +3582,7 @@ class Contact
* @param string $url An url that we will be redirected to after the authentication
*
* @return string with "redir" link
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function magicLinkById(int $cid, string $url = ''): string
@ -3605,7 +3606,7 @@ class Contact
* @param string $url An url that we will be redirected to after the authentication
*
* @return string with "redir" link
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function magicLinkByContact(array $contact, string $url = ''): string
@ -3810,7 +3811,7 @@ class Contact
* @param array $condition
*
* @return bool
* @throws \Exception
* @throws Exception
*/
public static function exists(array $condition): bool
{

View file

@ -15,6 +15,7 @@ use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\ItemURI;
use Friendica\Network\HTTPException\InternalServerErrorException;
use PDOException;
/**
@ -130,7 +131,7 @@ class User
* @param boolean $blocked Is the contact blocked or unblocked?
* @param boolean $only_set Only set the block flag, don't execute any block transmission
* @return void
* @throws \Exception
* @throws Exception
*/
public static function setBlocked(int $cid, int $uid, bool $blocked, bool $only_set = false)
{
@ -171,7 +172,7 @@ class User
* @param int $uid User ID
*
* @return boolean is the contact id blocked for the given user?
* @throws \Exception
* @throws Exception
*/
public static function isBlocked(int $cid, int $uid): bool
{
@ -212,7 +213,7 @@ class User
* @param int $uid User ID
* @param boolean $ignored Is the contact ignored or unignored?
* @return void
* @throws \Exception
* @throws Exception
*/
public static function setIgnored(int $cid, int $uid, bool $ignored)
{
@ -234,7 +235,7 @@ class User
* @param int $cid Either public contact id or user's contact id
* @param int $uid User ID
* @return boolean is the contact id ignored for the given user?
* @throws \Exception
* @throws Exception
*/
public static function isIgnored(int $cid, int $uid): bool
{
@ -275,7 +276,7 @@ class User
* @param int $uid User ID
* @param boolean $collapsed are the contact's posts collapsed or uncollapsed?
* @return void
* @throws \Exception
* @throws Exception
*/
public static function setCollapsed(int $cid, int $uid, bool $collapsed)
{
@ -293,7 +294,7 @@ class User
* @param int $cid Either public contact id or user's contact id
* @param int $uid User ID
* @return boolean is the contact id blocked for the given user?
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function isCollapsed(int $cid, int $uid): bool
@ -314,7 +315,7 @@ class User
* @param int $uid User ID
* @param int $frequency Type of post frequency in channels
* @return void
* @throws \Exception
* @throws Exception
*/
public static function setChannelFrequency(int $cid, int $uid, int $frequency)
{
@ -332,7 +333,7 @@ class User
* @param int $cid Either public contact id or user's contact id
* @param int $uid User ID
* @return int Type of post frequency in channels
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function getChannelFrequency(int $cid, int $uid): int
@ -349,11 +350,11 @@ class User
/**
* Set the channel only value for contact id and user id
*
* @param int $cid Either public contact id or user's contact id
* @param int $uid User ID
* @param int $isChannelOnly Is channel only
* @param int $cid Either public contact id or user's contact id
* @param int $uid User ID
* @param bool $isChannelOnly Is channel only
* @return void
* @throws \Exception
* @throws Exception
*/
public static function setChannelOnly(int $cid, int $uid, bool $isChannelOnly)
{
@ -371,7 +372,7 @@ class User
* @param int $cid Either public contact id or user's contact id
* @param int $uid User ID
* @return bool Contact is channel only
* @throws HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function getChannelOnly(int $cid, int $uid): bool
@ -392,7 +393,7 @@ class User
* @param int $uid User ID
* @param boolean $blocked Is the user blocked or unblocked by the contact?
* @return void
* @throws \Exception
* @throws Exception
*/
public static function setIsBlocked(int $cid, int $uid, bool $blocked)
{
@ -410,7 +411,7 @@ class User
* @param int $cid Either public contact id or user's contact id
* @param int $uid User ID
* @return boolean Is the user blocked or unblocked by the contact?
* @throws \Exception
* @throws Exception
*/
public static function isIsBlocked(int $cid, int $uid): bool
{

View file

@ -15,7 +15,9 @@ use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Network\HTTPException;
use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Network\HTTPException\NotFoundException;
use Friendica\Network\HTTPException\UnauthorizedException;
use Friendica\Protocol\Activity;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Map;
@ -487,23 +489,23 @@ class Event
* @param string $nickname
*
* @return array the owner array
* @throws HTTPException\InternalServerErrorException
* @throws HTTPException\NotFoundException The given nickname does not exist
* @throws HTTPException\UnauthorizedException The access for the given nickname is restricted
* @throws InternalServerErrorException
* @throws NotFoundException The given nickname does not exist
* @throws UnauthorizedException The access for the given nickname is restricted
*/
public static function getOwnerForNickname(string $nickname): array
{
$owner = User::getOwnerDataByNick($nickname);
if (empty($owner) || $owner['account_removed'] || $owner['account_expired']) {
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
throw new NotFoundException(DI::l10n()->t('User not found.'));
}
if (!DI::userSession()->isAuthenticated() && $owner['hidewall']) {
throw new HTTPException\UnauthorizedException(DI::l10n()->t('Access to this profile has been restricted.'));
throw new UnauthorizedException(DI::l10n()->t('Access to this profile has been restricted.'));
}
if (!DI::userSession()->isAuthenticated() && !Feature::isEnabled($owner['uid'], Feature::PUBLIC_CALENDAR)) {
throw new HTTPException\UnauthorizedException(DI::l10n()->t('Permission denied.'));
throw new UnauthorizedException(DI::l10n()->t('Permission denied.'));
}
return $owner;
@ -514,7 +516,6 @@ class Event
*
* @param int $owner_uid The User ID of the owner of the event
* @param int $event_id The ID of the event in the event table
* @param string|null $nickname a possible nickname to search for instead of the owner uid
* @return array Query result
* @throws \Exception
*/
@ -541,7 +542,7 @@ class Event
$owner_uid
));
if (empty($events)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('Event not found.'));
throw new NotFoundException(DI::l10n()->t('Event not found.'));
}
return $events[0];
@ -556,8 +557,8 @@ class Event
* @param bool|null $ignore Filters ignored events (false: unignored events, true: ignored events, null: all events)
*
* @return array Query results.
* @throws HTTPException\NotFoundException
* @throws HTTPException\UnauthorizedException
* @throws NotFoundException
* @throws UnauthorizedException
*/
public static function getListByDate(int $owner_uid, string $start = null, string $finish = null, ?bool $ignore = false): array
{

View file

@ -163,9 +163,6 @@ class GServer
/**
* Checks if the given server array is unreachable for a long time now
*
* @param integer $gsid
* @return boolean
*/
private static function isDefunct(array $gserver): bool
{
@ -509,7 +506,7 @@ class GServer
* @return UriInterface cleaned URI
* @throws Exception
*/
public static function cleanUri(UriInterface $dirtyUri): string
public static function cleanUri(UriInterface $dirtyUri): UriInterface
{
return $dirtyUri
->withUserInfo('')
@ -1349,8 +1346,6 @@ class GServer
*
* @see https://github.com/jaywink/nodeinfo2
*
* @param string $nodeinfo_url address of the nodeinfo path
*
* @return array Server data
*
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
@ -1539,7 +1534,6 @@ class GServer
/**
* Fetches server data via an ActivityPub account with url of that server
*
* @param string $url URL of the given server
* @param array $serverdata array with server data
*
* @return array server data

View file

@ -445,7 +445,7 @@ class Item
* Get guid from given item record
*
* @param array $item Item record
* @param bool Whether to notify (?)
* @param bool $notify Whether to notify (?)
* @return string Guid
*/
public static function guid(array $item, bool $notify): string
@ -2123,7 +2123,6 @@ class Item
*
* @param array $item
* @return string detected language
* @throws \Text_LanguageDetect_Exception
*/
private static function getLanguage(array $item): ?string
{
@ -3571,7 +3570,7 @@ class Item
}
$xpath = new \DOMXPath($dom);
/** @var DOMElement $element */
/** @var \DOMElement $element */
foreach ($xpath->query("//img[@class='network-svg']") as $element) {
$src = $element->getAttributeNode('src')->nodeValue;
if ($src == $svg) {

View file

@ -18,7 +18,7 @@ use Friendica\Object\Log\ParsedLogLine;
*/
class ParsedLogIterator implements \Iterator
{
/** @var \Iterator */
/** @var ReversedFileReader */
private $reader;
/** @var ParsedLogLine current iterator value*/
@ -33,10 +33,6 @@ class ParsedLogIterator implements \Iterator
/** @var string search term */
private $search = '';
/**
* @param ReversedFileReader $reader
*/
public function __construct(ReversedFileReader $reader)
{
$this->reader = $reader;

View file

@ -489,14 +489,11 @@ class Photo
* Delete info from table and data from storage
*
* @param array $conditions Field condition(s)
* @param array $options Options array, Optional
*
* @return boolean
*
* @throws \Exception
* @see \Friendica\Database\DBA::delete
*/
public static function delete(array $conditions, array $options = []): bool
public static function delete(array $conditions): bool
{
// get photo to delete data info
$photos = DBA::select('photo', ['id', 'backend-class', 'backend-ref'], $conditions);
@ -516,7 +513,7 @@ class Photo
DBA::close($photos);
return DBA::delete('photo', $conditions, $options);
return DBA::delete('photo', $conditions);
}
/**

View file

@ -19,8 +19,6 @@ class Post
/**
* Insert a new post entry
*
* @param integer $uri_id
* @param array $fields
* @return bool Success of the insert process
* @throws \Exception
*/
@ -184,10 +182,6 @@ class Post
/**
* Retrieve a single record from the post-user-view view and returns it in an associative array
*
* @param array $fields
* @param array $condition
* @param array $params
* @param bool $user_mode true = post-user-view, false = post-view
* @return bool|array
* @throws \Exception
* @see DBA::select
@ -212,10 +206,6 @@ class Post
* When the requested record is a reshare activity, the system fetches the reshared original post.
* Otherwise the function reacts similar to selectFirst
*
* @param array $fields
* @param array $condition
* @param array $params
* @param bool $user_mode true = post-user-view, false = post-view
* @return bool|array
* @throws \Exception
* @see DBA::select
@ -300,7 +290,7 @@ class Post
/**
* Select rows from the post-user-view view and returns them as an array
*
* @param array $selected Array of selected fields, empty for all
* @param array $fields Array of selected fields, empty for all
* @param array $condition Array of fields for condition
* @param array $params Array of several parameters
*
@ -767,15 +757,12 @@ class Post
* Delete a row from the post table
*
* @param array $conditions Field condition(s)
* @param array $options
* - cascade: If true we delete records in other tables that depend on the one we're deleting through
* relations (default: true)
*
* @return boolean was the delete successful?
* @throws \Exception
*/
public static function delete(array $conditions, array $options = []): bool
public static function delete(array $conditions): bool
{
return DBA::delete('post', $conditions, $options);
return DBA::delete('post', $conditions);
}
}

View file

@ -16,9 +16,6 @@ class Activity
/**
* Insert a new post-activity entry
*
* @param integer $uri_id
* @param array $fields
*
* @return bool success
*/
public static function insert(int $uri_id, string $source): bool

View file

@ -140,8 +140,6 @@ class Category
* Inserts new terms for the provided item ID based on the legacy item.file field BBCode content.
* Deletes all previous file terms for the same item ID.
*
* @param integer $item_id item id
* @param $files
* @return void
* @throws \Exception
*/

View file

@ -62,9 +62,6 @@ class Collection
/**
* Fetch collections for a given contact
*
* @param integer $cid
* @param [type] $type
* @param array $fields
* @return array
*/
public static function selectToArrayForContact(int $cid, int $type = self::FEATURED, array $fields = [])

View file

@ -11,7 +11,6 @@ use \BadMethodCallException;
use Friendica\Database\Database;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Post;
class Content
@ -19,8 +18,6 @@ class Content
/**
* Insert a new post-content entry
*
* @param integer $uri_id
* @param array $fields
* @return bool success
* @throws \Exception
*/
@ -69,16 +66,13 @@ class Content
* Delete a row from the post-content table
*
* @param array $conditions Field condition(s)
* @param array $options
* - cascade: If true we delete records in other tables that depend on the one we're deleting through
* relations (default: true)
*
* @return boolean was the delete successful?
* @throws \Exception
*/
public static function delete(array $conditions, array $options = [])
public static function delete(array $conditions)
{
return DBA::delete('post-content', $conditions, $options);
return DBA::delete('post-content', $conditions);
}

View file

@ -17,11 +17,6 @@ class Delivery
{
/**
* Add a post to an inbox
*
* @param integer $uri_id
* @param string $inbox
* @param string $created
* @param array %receivers
*/
public static function add(int $uri_id, int $uid, string $inbox, string $created, string $command, array $receivers)
{

View file

@ -17,7 +17,6 @@ class Origin
/**
* Insert a new post origin entry
*
* @param array $fields
* @return boolean was the insert successful?
* @throws \Exception
*/
@ -65,15 +64,12 @@ class Origin
* Delete a row from the post-origin table
*
* @param array $conditions Field condition(s)
* @param array $options
* - cascade: If true we delete records in other tables that depend on the one we're deleting through
* relations (default: true)
*
* @return boolean was the delete successful?
* @throws \Exception
*/
public static function delete(array $conditions, array $options = [])
public static function delete(array $conditions)
{
return DBA::delete('post-origin', $conditions, $options);
return DBA::delete('post-origin', $conditions);
}
}

View file

@ -10,7 +10,6 @@ namespace Friendica\Model\Post;
use \BadMethodCallException;
use Friendica\Database\Database;
use Friendica\Database\DBA;
use Friendica\Database\DBStructure;
use Friendica\DI;
class Thread
@ -18,8 +17,6 @@ class Thread
/**
* Insert a new post-thread entry
*
* @param integer $uri_id
* @param array $fields
* @return bool success
* @throws \Exception
*/
@ -68,15 +65,12 @@ class Thread
* Delete a row from the post-thread table
*
* @param array $conditions Field condition(s)
* @param array $options
* - cascade: If true we delete records in other tables that depend on the one we're deleting through
* relations (default: true)
*
* @return boolean was the delete successful?
* @throws \Exception
*/
public static function delete(array $conditions, array $options = [])
public static function delete(array $conditions)
{
return DBA::delete('post-thread', $conditions, $options);
return DBA::delete('post-thread', $conditions);
}
}

View file

@ -7,10 +7,10 @@
namespace Friendica\Model\Post;
use \BadMethodCallException;
use BadMethodCallException;
use Exception;
use Friendica\Database\Database;
use Friendica\Database\DBA;
use Friendica\Database\DBStructure;
use Friendica\DI;
class ThreadUser
@ -18,9 +18,6 @@ class ThreadUser
/**
* Insert a new URI user entry
*
* @param integer $uri_id
* @param integer $uid
* @param array $fields
* @return bool success
* @throws \Exception
*/
@ -72,16 +69,13 @@ class ThreadUser
* Delete a row from the post-thread-user table
*
* @param array $conditions Field condition(s)
* @param array $options
* - cascade: If true we delete records in other tables that depend on the one we're deleting through
* relations (default: true)
*
* @return boolean was the delete successful?
* @throws \Exception
*/
public static function delete(array $conditions, array $options = [])
public static function delete(array $conditions)
{
return DBA::delete('post-thread-user', $conditions, $options);
return DBA::delete('post-thread-user', $conditions);
}
/**

View file

@ -7,9 +7,9 @@
namespace Friendica\Model\Post;
use Friendica\Database\DBA;
use \BadMethodCallException;
use BadMethodCallException;
use Friendica\Database\Database;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Protocol\Activity;
@ -19,9 +19,6 @@ class User
/**
* Insert a new post user entry
*
* @param integer $uri_id
* @param integer $uid
* @param array $fields
* @return int ID of inserted post-user
* @throws \Exception
*/
@ -109,15 +106,12 @@ class User
* Delete a row from the post-user table
*
* @param array $conditions Field condition(s)
* @param array $options
* - cascade: If true we delete records in other tables that depend on the one we're deleting through
* relations (default: true)
*
* @return boolean was the delete successful?
* @throws \Exception
*/
public static function delete(array $conditions, array $options = [])
public static function delete(array $conditions)
{
return DBA::delete('post-user', $conditions, $options);
return DBA::delete('post-user', $conditions);
}
}

View file

@ -95,15 +95,13 @@ class UserNotification
* Delete a row from the post-user-notification table
*
* @param array $conditions Field condition(s)
* @param array $options - cascade: If true we delete records in other tables that depend on the one we're deleting through
* relations (default: true)
*
* @return boolean was the deletion successful?
* @throws Exception
*/
public static function delete(array $conditions, array $options = []): bool
public static function delete(array $conditions): bool
{
return DBA::delete('post-user-notification', $conditions, $options);
return DBA::delete('post-user-notification', $conditions);
}
/**

View file

@ -33,7 +33,7 @@ class Profile
/**
* Returns default profile for a given user id
*
* @param integer User ID
* @param int $uid User ID
*
* @return array|bool Profile data or false on error
* @throws \Exception
@ -61,8 +61,8 @@ class Profile
/**
* Returns profile data for the contact owner
*
* @param int $uid The User ID
* @param array|bool $fields The fields to retrieve or false on error
* @param int $uid The User ID
* @param array $fields The fields to retrieve or false on error
*
* @return array Array of profile data
* @throws \Exception

View file

@ -12,7 +12,7 @@ use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Factory\Api\Mastodon\Notification as NotificationFactory;
use Friendica\Navigation\Notifications\Entity;
use Friendica\Navigation\Notifications\Entity\Notification as NotificationEntity;
use Friendica\Object\Api\Mastodon\Notification;
use Minishlink\WebPush\VAPID;
@ -21,9 +21,6 @@ class Subscription
/**
* Select a subscription record exists
*
* @param int $applicationid
* @param int $uid
* @param array $fields
* @return array|bool Array on success, false on failure
*/
public static function select(int $applicationid, int $uid, array $fields = [])
@ -120,10 +117,9 @@ class Subscription
/**
* Prepare push notification
*
* @param Notification $Notification
* @return void
*/
public static function pushByNotification(Entity\Notification $notification)
public static function pushByNotification(NotificationEntity $notification)
{
$type = NotificationFactory::getType($notification);

View file

@ -521,7 +521,6 @@ class User
/**
* Get owner data by nick name
*
* @param int $nick
* @return boolean|array
* @throws Exception
*/
@ -1215,6 +1214,7 @@ class User
$_SESSION['openid'] = $openid_url;
$openid = new LightOpenID(DI::baseUrl()->getHost());
/** @phpstan-ignore-next-line $openid->identity is private, but will be set via magic setter */
$openid->identity = $openid_url;
$openid->returnUrl = DI::baseUrl() . '/openid';
$openid->required = ['namePerson/friendly', 'contact/email', 'namePerson'];

View file

@ -9,7 +9,6 @@ namespace Friendica\Module\Admin;
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\Config\Util\ConfigFileManager;
use Friendica\Core\Config\ValueObject\Cache;
use Friendica\Core\Renderer;
use Friendica\Core\Update;
@ -19,7 +18,6 @@ use Friendica\DI;
use Friendica\Core\Config\Factory\Config;
use Friendica\Module\BaseAdmin;
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
use Friendica\Network\HTTPException\ServiceUnavailableException;
use Friendica\Network\Probe;
use Friendica\Util\DateTimeFormat;
@ -55,7 +53,7 @@ class Summary extends BaseAdmin
$table_definition_cache = DBA::getVariable('table_definition_cache');
$table_open_cache = DBA::getVariable('table_open_cache');
if (!empty($table_definition_cache) && !empty($table_open_cache)) {
$suggested_definition_cache = min(400 + round($table_open_cache / 2, 1), 2000);
$suggested_definition_cache = min(400 + round((int) $table_open_cache / 2, 1), 2000);
if ($suggested_definition_cache > $table_definition_cache) {
$warningtext[] = DI::l10n()->t('Your table_definition_cache is too low (%d). This can lead to the database error "Prepared statement needs to be re-prepared". Please set it at least to %d. See <a href="%s">here</a> for more information.<br />', $table_definition_cache, $suggested_definition_cache, 'https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_table_definition_cache');
}

View file

@ -252,7 +252,7 @@ class BaseApi extends BaseModule
/**
* Set boundaries for the "link" header
* @param array $boundaries
*
* @param int|\DateTime $id
*/
protected static function setBoundaries($id)

View file

@ -9,7 +9,8 @@ namespace Friendica\Module;
use DOMDocument;
use DOMElement;
use Friendica\App;
use Friendica\App\Arguments;
use Friendica\App\BaseURL;
use Friendica\BaseModule;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\L10n;
@ -31,7 +32,7 @@ class OpenSearch extends BaseModule
/** @var string */
private $basePath;
public function __construct(BasePath $basePath, IManageConfigValues $config, L10n $l10n, App\baseUrl $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
public function __construct(BasePath $basePath, IManageConfigValues $config, L10n $l10n, BaseURL $baseUrl, Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
@ -44,20 +45,23 @@ class OpenSearch extends BaseModule
*/
protected function rawContent(array $request = [])
{
/** @var DOMDocument $xml */
XML::fromArray([
'OpenSearchDescription' => [
'@attributes' => [
'xmlns' => 'http://a9.com/-/spec/opensearch/1.1/',
XML::fromArray(
[
'OpenSearchDescription' => [
'@attributes' => [
'xmlns' => 'http://a9.com/-/spec/opensearch/1.1/',
],
'ShortName' => $this->baseUrl->getHost(),
'Description' => $this->l10n->t('Search in Friendica %s', $this->baseUrl->getHost()),
'Contact' => 'https://github.com/friendica/friendica/issues',
'InputEncoding' => 'UTF-8',
'OutputEncoding' => 'UTF-8',
'Developer' => 'Friendica Developer Team',
],
'ShortName' => $this->baseUrl->getHost(),
'Description' => $this->l10n->t('Search in Friendica %s', $this->baseUrl->getHost()),
'Contact' => 'https://github.com/friendica/friendica/issues',
'InputEncoding' => 'UTF-8',
'OutputEncoding' => 'UTF-8',
'Developer' => 'Friendica Developer Team',
],
], $xml);
/** @var DOMDocument $xml */
$xml
);
/** @var DOMElement $parent */
$parent = $xml->getElementsByTagName('OpenSearchDescription')[0];

View file

@ -69,7 +69,9 @@ class OpenID extends BaseModule
// Detect the server URL
$open_id_obj = new LightOpenID(DI::baseUrl()->getHost());
/** @phpstan-ignore-next-line $openid->identity is private, but will be set via magic setter */
$open_id_obj->identity = $authId;
/** @phpstan-ignore-next-line $openid->identity is private, but will be retrieved via magic getter */
$session->set('openid_server', $open_id_obj->discover($open_id_obj->identity));
if (\Friendica\Module\Register::getPolicy() === \Friendica\Module\Register::CLOSED) {

View file

@ -7,13 +7,16 @@
namespace Friendica\Module\Special;
use Friendica\App;
use Friendica\App\Arguments;
use Friendica\App\Request;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Core\Session\Model\UserSession;
use Friendica\Core\System;
use Friendica\Module\Response;
use Friendica\Network\HTTPException as NetworkHTTPException;
use Psr\Log\LoggerInterface;
use Throwable;
/**
* This special module displays HTTPException when they are thrown in modules.
@ -26,7 +29,7 @@ class HTTPException
protected $l10n;
/** @var LoggerInterface */
protected $logger;
/** @var App\Arguments */
/** @var Arguments */
protected $args;
/** @var bool */
protected $isSiteAdmin;
@ -35,7 +38,7 @@ class HTTPException
/** @var string */
protected $requestId;
public function __construct(L10n $l10n, LoggerInterface $logger, App\Arguments $args, UserSession $session, App\Request $request, array $server = [])
public function __construct(L10n $l10n, LoggerInterface $logger, Arguments $args, UserSession $session, Request $request, array $server = [])
{
$this->logger = $logger;
$this->l10n = $l10n;
@ -50,11 +53,9 @@ class HTTPException
*
* Fills in the blanks if title or descriptions aren't provided by the exception.
*
* @param \Friendica\Network\HTTPException $e
*
* @return array ['$title' => ..., '$description' => ...]
*/
private function getVars(\Friendica\Network\HTTPException $e)
private function getVars(NetworkHTTPException $e)
{
// Explanations are mostly taken from https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
$vars = [
@ -76,11 +77,9 @@ class HTTPException
/**
* Displays a bare message page with no theming at all.
*
* @param \Friendica\Network\HTTPException $e
*
* @throws \Exception
*/
public function rawContent(\Friendica\Network\HTTPException $e)
public function rawContent(NetworkHTTPException $e)
{
$content = '';
@ -89,7 +88,7 @@ class HTTPException
try {
$tpl = Renderer::getMarkupTemplate('http_status.tpl');
$content = Renderer::replaceMacros($tpl, $vars);
} catch (\Exception $e) {
} catch (Throwable $th) {
$vars = array_map('htmlentities', $vars);
$content = "<h1>{$vars['$title']}</h1><p>{$vars['$message']}</p>";
if ($this->isSiteAdmin) {
@ -111,12 +110,10 @@ class HTTPException
/**
* Returns a content string that can be integrated in the current theme.
*
* @param \Friendica\Network\HTTPException $e
*
* @return string
* @throws \Exception
*/
public function content(\Friendica\Network\HTTPException $e): string
public function content(NetworkHTTPException $e): string
{
if ($e->getCode() >= 400) {
$this->logger->debug('Exit with error',

View file

@ -11,16 +11,16 @@ use DateTime;
use Friendica\BaseEntity;
/**
* @property-read $id
* @property-read $uid
* @property-read $verb
* @property-read $type
* @property-read $actorId
* @property-read $targetUriId
* @property-read $parentUriId
* @property-read $created
* @property-read $seen
* @property-read $dismissed
* @property-read int $id
* @property-read int $uid
* @property-read string $verb
* @property-read int $type
* @property-read int $actorId
* @property-read int $targetUriId
* @property-read int $parentUriId
* @property-read DateTime $created
* @property-read bool $seen
* @property-read bool $dismissed
*/
class Notification extends BaseEntity
{
@ -31,7 +31,7 @@ class Notification extends BaseEntity
/** @var string */
protected $verb;
/**
* @var int One of the \Friendica\Model\Post\UserNotification::TYPE_* constant values
* @var int $type One of the \Friendica\Model\Post\UserNotification::TYPE_* constant values
* @see \Friendica\Model\Post\UserNotification
*/
protected $type;

View file

@ -14,24 +14,24 @@ use Friendica\Core\Renderer;
use Psr\Http\Message\UriInterface;
/**
* @property-read $type
* @property-read $name
* @property-read $url
* @property-read $photo
* @property-read $date
* @property-read $msg
* @property-read $uid
* @property-read $link
* @property-read $itemId
* @property-read $parent
* @property-read $seen
* @property-read $verb
* @property-read $otype
* @property-read $name_cache
* @property-read $msg_cache
* @property-read $uriId
* @property-read $parentUriId
* @property-read $id
* @property-read string $type
* @property-read string $name
* @property-read UriInterface $url
* @property-read UriInterface $photo
* @property-read DateTime $date
* @property-read string|null $msg
* @property-read int $uid
* @property-read UriInterface $link
* @property-read int|null $itemId
* @property-read int|null $parent
* @property-read bool $seen
* @property-read string $verb
* @property-read string|null $otype
* @property-read string|null $name_cache
* @property-read string|null $msg_cache
* @property-read int|null $uriId
* @property-read int|null $parentUriId
* @property-read int|null $id
*
* @deprecated since 2022.05 Use \Friendica\Navigation\Notifications\Entity\Notification instead
*/

View file

@ -11,6 +11,8 @@ use Friendica\BaseEntity;
/**
* A view-only object for printing item notifications to the frontend
*
* @property-read bool $seen
*/
class FormattedNavNotification extends BaseEntity
{

View file

@ -28,7 +28,6 @@ class Activity extends BaseDataTransferObject
/**
* Creates an activity
*
* @param array $item
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function __construct(int $week, int $statuses, int $logins, int $registrations)

View file

@ -34,7 +34,6 @@ class Application extends BaseDataTransferObject
/**
* Creates an application entry
*
* @param array $item
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function __construct(string $name, string $client_id = null, string $client_secret = null, int $id = null, string $redirect_uri = null, string $website = null, string $vapid_key = null)

View file

@ -32,7 +32,6 @@ class Emoji extends BaseDataTransferObject
// Optional attributes
/**
* Unsupported
* @var string
*/
//protected $category;

View file

@ -23,9 +23,6 @@ class Error extends BaseDataTransferObject
/**
* Creates an error record
*
* @param string $error
* @param string error_description
*/
public function __construct(string $error, string $error_description)
{

View file

@ -26,8 +26,6 @@ class ListEntity extends BaseDataTransferObject
/**
* Creates an list record
*
* @param int $id
* @param string $title
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function __construct(string $id, string $title, string $policy)

View file

@ -45,10 +45,6 @@ class Preferences extends BaseDataTransferObject
/**
* Creates a preferences record.
*
* @param BaseURL $baseUrl
* @param array $publicContact Full contact table record with uid = 0
* @param array $apcontact Optional full apcontact table record
* @param array $userContact Optional full contact table record with uid != 0
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function __construct(string $visibility, bool $sensitive, string $language, string $media, bool $spoilers)

View file

@ -11,6 +11,11 @@ namespace Friendica\Object\Api\Mastodon\Status;
* Class Counts
*
* @see https://docs.joinmastodon.org/entities/status
*
* @property-read int $replies
* @property-read int $reblogs
* @property-read int $favourites
* @property-read int $dislikes
*/
class Counts
{

View file

@ -10,6 +10,12 @@ namespace Friendica\Object\Api\Mastodon\Status;
/**
* Class UserAttributes
*
* @property-read bool $favourited
* @property-read bool $reblogged
* @property-read bool $muted
* @property-read bool $bookmarked
* @property-read bool $pinned
*
* @see https://docs.joinmastodon.org/entities/status
*/
class UserAttributes

View file

@ -32,7 +32,7 @@ class Tag extends BaseDataTransferObject
* @param BaseURL $baseUrl
* @param array $tag tag-view record
* @param array $history
* @param array $following "true" if the user is following this tag
* @param bool $following "true" if the user is following this tag
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function __construct(BaseURL $baseUrl, array $tag, array $history = [], bool $following = false)

View file

@ -26,7 +26,6 @@ class Attachment extends BaseDataTransferObject
/**
* Creates an Attachment entity array
*
* @param array $attachment
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function __construct(array $media)

View file

@ -24,7 +24,6 @@ class Hashtag extends BaseDataTransferObject
/**
* Creates a hashtag
*
* @param array $attachment
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function __construct(string $name, array $indices)

View file

@ -41,7 +41,6 @@ class Media extends BaseDataTransferObject
/**
* Creates a media entity array
*
* @param array $attachment
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function __construct(array $media, string $url, array $indices)

View file

@ -31,7 +31,6 @@ class Mention extends BaseDataTransferObject
/**
* Creates a mention record from an tag-view record.
*
* @param BaseURL $baseUrl
* @param array $tag tag-view record
* @param array $contact contact table record
* @throws \Friendica\Network\HTTPException\InternalServerErrorException

View file

@ -34,7 +34,6 @@ class SavedSearch extends BaseDataTransferObject
/**
* Creates a saved search record from a search record.
*
* @param BaseURL $baseUrl
* @param array $search Full search table record
*/
public function __construct(array $search)

View file

@ -28,7 +28,6 @@ class Url extends BaseDataTransferObject
/**
* Creates an URL entity array
*
* @param array $attachment
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public function __construct(array $media, array $indices)

View file

@ -7,7 +7,6 @@
namespace Friendica\Object\EMail;
use Friendica\Util\Emailer;
use JsonSerializable;
/**

View file

@ -13,7 +13,7 @@ use Friendica\Util\Images;
use Imagick;
use ImagickDraw;
use ImagickPixel;
use GDImage;
use GdImage;
use kornrunner\Blurhash\Blurhash;
/**
@ -21,7 +21,7 @@ use kornrunner\Blurhash\Blurhash;
*/
class Image
{
/** @var GDImage|Imagick|resource */
/** @var GdImage|Imagick|resource */
private $image;
/*
@ -41,7 +41,7 @@ class Image
* @param string $data Image data
* @param string $type optional, default ''
* @param string $filename optional, default ''
* @param string $imagick optional, default 'true'
* @param bool $imagick optional, default 'true'
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException
*/
@ -765,7 +765,6 @@ class Image
/**
* Create a blurhash out of a given image string
*
* @param string $img_str
* @return string
*/
public function getBlurHash(): string

View file

@ -39,7 +39,7 @@ class ParsedLogLine
public $logline;
/**
* @param int line id
* @param int $id line id
* @param string $logline Source log line to parse
*/
public function __construct(int $id, string $logline)

View file

@ -51,7 +51,7 @@ final class ATProtocol
/** @var \Friendica\Core\Config\Capability\IManageConfigValues */
private $config;
/** @var IManagePersonalConfigValue */
/** @var IManagePersonalConfigValues */
private $pConfig;
/** @var ICanSendHttpRequests */

View file

@ -307,7 +307,6 @@ class ClientToServer
* @param integer $page Page number
* @param integer $max_id Maximum ID
* @param string $requester URL of requesting account
* @param boolean $nocache Wether to bypass caching
* @return array of posts
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException

View file

@ -29,8 +29,6 @@ class Fetch
/**
* Set the worker id for the queue entry
*
* @param array $activity
* @param int $wid
* @return void
*/
public static function setWorkerId(string $url, int $wid)
@ -45,9 +43,6 @@ class Fetch
/**
* Check if there is an assigned worker task
*
* @param array $activity
* @return bool
*/
public static function hasWorker(string $url): bool
{

View file

@ -1449,7 +1449,7 @@ class Processor
* @return int|bool New mail table row id or false on error
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
private static function postMail(array $item): bool
private static function postMail(array $item)
{
if (($item['gravity'] != Item::GRAVITY_PARENT) && !DBA::exists('mail', ['uri' => $item['thr-parent'], 'uid' => $item['uid']])) {
Logger::info('Parent not found, mail will be discarded.', ['uid' => $item['uid'], 'uri' => $item['thr-parent']]);

View file

@ -19,7 +19,6 @@ use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\APContact;
use Friendica\Model\Contact;
use Friendica\Model\GServer;
use Friendica\Model\Item;
use Friendica\Model\Photo;
use Friendica\Model\Post;
@ -904,10 +903,6 @@ class Transmitter
/**
* Get a list of receivers for the provided uri-id
*
* @param array $item
* @param boolean $blindcopy
* @return array
*/
public static function getReceiversForUriId(int $uri_id, bool $blindcopy): array
{
@ -1344,8 +1339,6 @@ class Transmitter
/**
* Creates an activity array for a given URI-Id and uid
*
* @param integer $uri_id
* @param integer $uid
* @param boolean $object_mode true = Create the object, false = create the activity with the object
* @param boolean $api_mode true = used for the API
* @param boolean $announce_activity true = the announced object is the activity, false = we announce the object link
@ -1370,7 +1363,6 @@ class Transmitter
/**
* Creates an activity array for a given item id
*
* @param integer $item_id
* @param boolean $object_mode true = Create the object, false = create the activity with the object
* @param boolean $api_mode true = used for the API
* @param boolean $announce_activity true = the announced object is the activity, false = we announce the object link
@ -2509,15 +2501,14 @@ class Transmitter
* Prepends mentions (@) to $body variable
*
* @param string $body HTML code
* @param int $uriId
* @param string $authorLink Author link
* @return string HTML code with prepended mentions
*/
private static function prependMentions(string $body, int $uriid, string $authorLink): string
private static function prependMentions(string $body, int $uriId, string $authorLink): string
{
$mentions = [];
foreach (Tag::getByURIId($uriid, [Tag::IMPLICIT_MENTION]) as $tag) {
foreach (Tag::getByURIId($uriId, [Tag::IMPLICIT_MENTION]) as $tag) {
$profile = Contact::getByURL($tag['url'], false, ['addr', 'contact-type', 'nick']);
if (
!empty($profile['addr'])

View file

@ -417,7 +417,7 @@ class DFRN
$t_dob = strtotime($bd);
$now = strtotime(DateTimeFormat::timezoneNow($tz));
if ($t_dob < $now) {
$bd = $y + 1 . '-' . $tmp_dob . ' 00:00';
$bd = (int) $y + 1 . '-' . $tmp_dob . ' 00:00';
}
$birthday = DateTimeFormat::convert($bd, 'UTC', $tz, DateTimeFormat::ATOM);
}

View file

@ -29,6 +29,8 @@ use Friendica\Model\User;
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
use Friendica\Network\HTTPClient\Client\HttpClientRequest;
use Friendica\Network\HTTPException;
use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Network\HTTPException\NotFoundException;
use Friendica\Network\Probe;
use Friendica\Protocol\Delivery;
use Friendica\Util\Crypto;
@ -778,7 +780,7 @@ class Diaspora
* @param WebFingerUri $uri The handle
*
* @return string The public key
* @throws InternalServerErrorException
* @throws NotFoundException
* @throws \ImagickException
*/
private static function key(WebFingerUri $uri): string
@ -786,7 +788,7 @@ class Diaspora
Logger::info('Fetching diaspora key', ['handle' => $uri->getAddr()]);
try {
return DI::dsprContact()->getByAddr($uri)->pubKey;
} catch (HTTPException\NotFoundException | \InvalidArgumentException $e) {
} catch (NotFoundException | \InvalidArgumentException $e) {
return '';
}
}
@ -813,7 +815,7 @@ class Diaspora
* @param string $url profile url or WebFinger address
* @param boolean|null $update true = always update, false = never update, null = update when not found or outdated
* @return boolean
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
public static function isSupportedByContactUrl(string $url, ?bool $update = null): bool
@ -2913,14 +2915,13 @@ class Diaspora
/**
* Transmit a message to a target server
*
* @param array $owner the array of the item owner
* @param array $contact Target of the communication
* @param string $envelope The message that is to be transmitted
* @param bool $public_batch Is it a public post?
* @param string $guid message guid
*
* @return int Result of the transmission
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws InternalServerErrorException
* @throws \ImagickException
*/
private static function transmit(array $contact, string $envelope, bool $public_batch, string $guid = ''): int
@ -3222,7 +3223,7 @@ class Diaspora
/**
* Create an event array
*
* @param integer $event_id The id of the event
* @param string $event_id The id of the event
*
* @return array with event data
* @throws \Friendica\Network\HTTPException\InternalServerErrorException

View file

@ -10,31 +10,31 @@ namespace Friendica\Protocol\Diaspora\Entity;
use Psr\Http\Message\UriInterface;
/**
* @property-read $uriId
* @property-read $url
* @property-read $guid
* @property-read $addr
* @property-read $alias
* @property-read $nick
* @property-read $name
* @property-read $givenName
* @property-read $familyName
* @property-read $photo
* @property-read $photoMedium
* @property-read $photoSmall
* @property-read $batch
* @property-read $notify
* @property-read $poll
* @property-read $subscribe
* @property-read $searchable
* @property-read $pubKey
* @property-read $baseurl
* @property-read $gsid
* @property-read $created
* @property-read $updated
* @property-read $interacting_count
* @property-read $interacted_count
* @property-read $post_count
* @property-read int $uriId
* @property-read UriInterface $url
* @property-read string $guid
* @property-read string $addr
* @property-read UriInterface $alias
* @property-read string $nick
* @property-read string $name
* @property-read string $givenName
* @property-read string $familyName
* @property-read UriInterface $photo
* @property-read UriInterface $photoMedium
* @property-read UriInterface $photoSmall
* @property-read UriInterface $batch
* @property-read UriInterface $notify
* @property-read UriInterface $poll
* @property-read string $subscribe
* @property-read bool $searchable
* @property-read string $pubKey
* @property-read UriInterface $baseurl
* @property-read int $gsid
* @property-read \DateTime $created
* @property-read \DateTime $updated
* @property-read int $interacting_count
* @property-read int $interacted_count
* @property-read int $post_count
*/
class DiasporaContact extends \Friendica\BaseEntity
{

View file

@ -266,7 +266,7 @@ class DiasporaContact extends BaseRepository
/**
* get a url (scheme://domain.tld/u/user) from a given contact guid
*
* @param mixed $guid Hexadecimal string guid
* @param string $guid Hexadecimal string guid
*
* @return string the contact url or null
* @throws \Exception

Some files were not shown because too many files have changed in this diff Show more