Merge pull request #11653 from Quix0r/fixes/more-type-hints
More type-hints added
This commit is contained in:
commit
e90ad0c1cd
50 changed files with 1167 additions and 1067 deletions
58
src/App.php
58
src/App.php
|
@ -145,7 +145,7 @@ class App
|
|||
$this->nickname = $nickname;
|
||||
}
|
||||
|
||||
public function isLoggedIn()
|
||||
public function isLoggedIn(): bool
|
||||
{
|
||||
return local_user() && $this->user_id && ($this->user_id == local_user());
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ class App
|
|||
*
|
||||
* @return bool true if user is an admin
|
||||
*/
|
||||
public function isSiteAdmin()
|
||||
public function isSiteAdmin(): bool
|
||||
{
|
||||
$admin_email = $this->config->get('config', 'admin_email');
|
||||
|
||||
|
@ -166,18 +166,18 @@ class App
|
|||
|
||||
/**
|
||||
* Fetch the user id
|
||||
* @return int
|
||||
* @return int User id
|
||||
*/
|
||||
public function getLoggedInUserId()
|
||||
public function getLoggedInUserId(): int
|
||||
{
|
||||
return $this->user_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the user nick name
|
||||
* @return string
|
||||
* @return string User's nickname
|
||||
*/
|
||||
public function getLoggedInUserNickname()
|
||||
public function getLoggedInUserNickname(): string
|
||||
{
|
||||
return $this->nickname;
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ class App
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getProfileOwner():int
|
||||
public function getProfileOwner(): int
|
||||
{
|
||||
return $this->profile_owner;
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ class App
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getContactId():int
|
||||
public function getContactId(): int
|
||||
{
|
||||
return $this->contact_id;
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ class App
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTimeZone():string
|
||||
public function getTimeZone(): string
|
||||
{
|
||||
return $this->timezone;
|
||||
}
|
||||
|
@ -260,9 +260,9 @@ class App
|
|||
/**
|
||||
* Fetch workerqueue information
|
||||
*
|
||||
* @return array
|
||||
* @return array Worker queue
|
||||
*/
|
||||
public function getQueue()
|
||||
public function getQueue(): array
|
||||
{
|
||||
return $this->queue ?? [];
|
||||
}
|
||||
|
@ -270,8 +270,8 @@ class App
|
|||
/**
|
||||
* Fetch a specific workerqueue field
|
||||
*
|
||||
* @param string $index
|
||||
* @return mixed
|
||||
* @param string $index Work queue record to fetch
|
||||
* @return mixed Work queue item or NULL if not found
|
||||
*/
|
||||
public function getQueueValue(string $index)
|
||||
{
|
||||
|
@ -306,9 +306,9 @@ class App
|
|||
/**
|
||||
* The basepath of this app
|
||||
*
|
||||
* @return string
|
||||
* @return string Base path from configuration
|
||||
*/
|
||||
public function getBasePath()
|
||||
public function getBasePath(): string
|
||||
{
|
||||
// Don't use the basepath of the config table for basepath (it should always be the config-file one)
|
||||
return $this->config->getCache()->get('system', 'basepath');
|
||||
|
@ -396,10 +396,10 @@ class App
|
|||
/**
|
||||
* Returns the current theme name. May be overriden by the mobile theme name.
|
||||
*
|
||||
* @return string
|
||||
* @return string Current theme name or empty string in installation phase
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getCurrentTheme()
|
||||
public function getCurrentTheme(): string
|
||||
{
|
||||
if ($this->mode->isInstall()) {
|
||||
return '';
|
||||
|
@ -425,10 +425,10 @@ class App
|
|||
/**
|
||||
* Returns the current mobile theme name.
|
||||
*
|
||||
* @return string
|
||||
* @return string Mobile theme name or empty string if installer
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getCurrentMobileTheme()
|
||||
public function getCurrentMobileTheme(): string
|
||||
{
|
||||
if ($this->mode->isInstall()) {
|
||||
return '';
|
||||
|
@ -441,12 +441,22 @@ class App
|
|||
return $this->currentMobileTheme;
|
||||
}
|
||||
|
||||
public function setCurrentTheme($theme)
|
||||
/**
|
||||
* Setter for current theme name
|
||||
*
|
||||
* @param string $theme Name of current theme
|
||||
*/
|
||||
public function setCurrentTheme(string $theme)
|
||||
{
|
||||
$this->currentTheme = $theme;
|
||||
}
|
||||
|
||||
public function setCurrentMobileTheme($theme)
|
||||
/**
|
||||
* Setter for current mobile theme name
|
||||
*
|
||||
* @param string $theme Name of current mobile theme
|
||||
*/
|
||||
public function setCurrentMobileTheme(string $theme)
|
||||
{
|
||||
$this->currentMobileTheme = $theme;
|
||||
}
|
||||
|
@ -525,10 +535,10 @@ class App
|
|||
/**
|
||||
* Provide a sane default if nothing is chosen or the specified theme does not exist.
|
||||
*
|
||||
* @return string
|
||||
* @return string Current theme's stylsheet path
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getCurrentThemeStylesheetPath()
|
||||
public function getCurrentThemeStylesheetPath(): string
|
||||
{
|
||||
return Core\Theme::getStylesheetPath($this->getCurrentTheme());
|
||||
}
|
||||
|
@ -730,7 +740,7 @@ class App
|
|||
*
|
||||
* @throws HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public function redirect($toUrl)
|
||||
public function redirect(string $toUrl)
|
||||
{
|
||||
if (!empty(parse_url($toUrl, PHP_URL_SCHEME))) {
|
||||
Core\System::externalRedirect($toUrl);
|
||||
|
|
|
@ -78,7 +78,7 @@ class Arguments
|
|||
/**
|
||||
* @return string The whole command of this call
|
||||
*/
|
||||
public function getCommand()
|
||||
public function getCommand(): string
|
||||
{
|
||||
return $this->command;
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ class Arguments
|
|||
/**
|
||||
* @return array All arguments of this call
|
||||
*/
|
||||
public function getArgv()
|
||||
public function getArgv(): array
|
||||
{
|
||||
return $this->argv;
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ class Arguments
|
|||
/**
|
||||
* @return string The used HTTP method
|
||||
*/
|
||||
public function getMethod()
|
||||
public function getMethod(): string
|
||||
{
|
||||
return $this->method;
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ class Arguments
|
|||
/**
|
||||
* @return int The count of arguments of this call
|
||||
*/
|
||||
public function getArgc()
|
||||
public function getArgc(): int
|
||||
{
|
||||
return $this->argc;
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ class Arguments
|
|||
*
|
||||
* @return bool if the argument position exists
|
||||
*/
|
||||
public function has(int $position)
|
||||
public function has(int $position): bool
|
||||
{
|
||||
return array_key_exists($position, $this->argv);
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ class Arguments
|
|||
*
|
||||
* @return Arguments The determined arguments
|
||||
*/
|
||||
public function determine(array $server, array $get)
|
||||
public function determine(array $server, array $get): Arguments
|
||||
{
|
||||
// removing leading / - maybe a nginx problem
|
||||
$server['QUERY_STRING'] = ltrim($server['QUERY_STRING'] ?? '', '/');
|
||||
|
|
|
@ -107,7 +107,7 @@ class BaseURL
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHostname()
|
||||
public function getHostname(): string
|
||||
{
|
||||
return $this->hostname;
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ class BaseURL
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getScheme()
|
||||
public function getScheme(): string
|
||||
{
|
||||
return $this->scheme;
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ class BaseURL
|
|||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSSLPolicy()
|
||||
public function getSSLPolicy(): int
|
||||
{
|
||||
return $this->sslPolicy;
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ class BaseURL
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUrlPath()
|
||||
public function getUrlPath(): string
|
||||
{
|
||||
return $this->urlPath;
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ class BaseURL
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get($ssl = false)
|
||||
public function get(bool $ssl = false): string
|
||||
{
|
||||
if ($this->sslPolicy === self::SSL_POLICY_SELFSIGN && $ssl) {
|
||||
return Network::switchScheme($this->url);
|
||||
|
@ -168,8 +168,9 @@ class BaseURL
|
|||
* @param string? $urlPath
|
||||
*
|
||||
* @return bool true, if successful
|
||||
* @TODO Find proper types
|
||||
*/
|
||||
public function save($hostname = null, $sslPolicy = null, $urlPath = null)
|
||||
public function save($hostname = null, $sslPolicy = null, $urlPath = null): bool
|
||||
{
|
||||
$currHostname = $this->hostname;
|
||||
$currSSLPolicy = $this->sslPolicy;
|
||||
|
@ -224,11 +225,11 @@ class BaseURL
|
|||
/**
|
||||
* Save the current url as base URL
|
||||
*
|
||||
* @param $url
|
||||
* @param string $url
|
||||
*
|
||||
* @return bool true, if the save was successful
|
||||
*/
|
||||
public function saveByURL($url)
|
||||
public function saveByURL(string $url): bool
|
||||
{
|
||||
$parsed = @parse_url($url);
|
||||
|
||||
|
@ -421,7 +422,7 @@ class BaseURL
|
|||
*
|
||||
* @return string The cleaned url
|
||||
*/
|
||||
public function remove(string $origURL)
|
||||
public function remove(string $origURL): string
|
||||
{
|
||||
// Remove the hostname from the url if it is an internal link
|
||||
$nurl = Strings::normaliseLink($origURL);
|
||||
|
@ -445,7 +446,7 @@ class BaseURL
|
|||
*
|
||||
* @throws HTTPException\InternalServerErrorException In Case the given URL is not relative to the Friendica node
|
||||
*/
|
||||
public function redirect($toUrl = '', $ssl = false)
|
||||
public function redirect(string $toUrl = '', bool $ssl = false)
|
||||
{
|
||||
if (!empty(parse_url($toUrl, PHP_URL_SCHEME))) {
|
||||
throw new HTTPException\InternalServerErrorException("'$toUrl is not a relative path, please use System::externalRedirectTo");
|
||||
|
@ -458,8 +459,8 @@ class BaseURL
|
|||
/**
|
||||
* Returns the base url as string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->get();
|
||||
return (string) $this->get();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ class Mode
|
|||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function determine(BasePath $basepath, Database $database, Cache $configCache)
|
||||
public function determine(BasePath $basepath, Database $database, Cache $configCache): Mode
|
||||
{
|
||||
$mode = 0;
|
||||
|
||||
|
@ -178,7 +178,7 @@ class Mode
|
|||
*
|
||||
* @return Mode returns the determined mode
|
||||
*/
|
||||
public function determineRunMode(bool $isBackend, array $server, Arguments $args, MobileDetect $mobileDetect)
|
||||
public function determineRunMode(bool $isBackend, array $server, Arguments $args, MobileDetect $mobileDetect): Mode
|
||||
{
|
||||
foreach (self::BACKEND_CONTENT_TYPES as $type) {
|
||||
if (strpos(strtolower($server['HTTP_ACCEPT'] ?? ''), $type) !== false) {
|
||||
|
@ -201,7 +201,7 @@ class Mode
|
|||
*
|
||||
* @return bool returns true, if the mode is set
|
||||
*/
|
||||
public function has($mode)
|
||||
public function has(int $mode): bool
|
||||
{
|
||||
return ($this->mode & $mode) > 0;
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ class Mode
|
|||
*
|
||||
* @return int Execution Mode
|
||||
*/
|
||||
public function getExecutor()
|
||||
public function getExecutor(): int
|
||||
{
|
||||
return $this->executor;
|
||||
}
|
||||
|
@ -235,9 +235,9 @@ class Mode
|
|||
/**
|
||||
* Install mode is when the local config file is missing or the DB schema hasn't been installed yet.
|
||||
*
|
||||
* @return bool
|
||||
* @return bool Whether installation mode is active (local/database configuration files present or not)
|
||||
*/
|
||||
public function isInstall()
|
||||
public function isInstall(): bool
|
||||
{
|
||||
return !$this->has(Mode::LOCALCONFIGPRESENT) ||
|
||||
!$this->has(MODE::DBCONFIGAVAILABLE);
|
||||
|
@ -248,7 +248,7 @@ class Mode
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isNormal()
|
||||
public function isNormal(): bool
|
||||
{
|
||||
return $this->has(Mode::LOCALCONFIGPRESENT) &&
|
||||
$this->has(Mode::DBAVAILABLE) &&
|
||||
|
@ -261,7 +261,7 @@ class Mode
|
|||
*
|
||||
* @return bool Is it a backend call
|
||||
*/
|
||||
public function isBackend()
|
||||
public function isBackend(): bool
|
||||
{
|
||||
return $this->isBackend;
|
||||
}
|
||||
|
@ -271,7 +271,7 @@ class Mode
|
|||
*
|
||||
* @return bool true if it was an AJAX request
|
||||
*/
|
||||
public function isAjax()
|
||||
public function isAjax(): bool
|
||||
{
|
||||
return $this->isAjax;
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ class Mode
|
|||
*
|
||||
* @return bool true if it was an mobile request
|
||||
*/
|
||||
public function isMobile()
|
||||
public function isMobile(): bool
|
||||
{
|
||||
return $this->isMobile;
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ class Mode
|
|||
*
|
||||
* @return bool true if it was an tablet request
|
||||
*/
|
||||
public function isTablet()
|
||||
public function isTablet(): bool
|
||||
{
|
||||
return $this->isTablet;
|
||||
}
|
||||
|
|
|
@ -195,7 +195,7 @@ class Page implements ArrayAccess
|
|||
* @param string $media
|
||||
* @see Page::initHead()
|
||||
*/
|
||||
public function registerStylesheet($path, string $media = 'screen')
|
||||
public function registerStylesheet(string $path, string $media = 'screen')
|
||||
{
|
||||
$path = Network::appendQueryParam($path, ['v' => FRIENDICA_VERSION]);
|
||||
|
||||
|
@ -288,7 +288,7 @@ class Page implements ArrayAccess
|
|||
*
|
||||
* Taken from http://webcheatsheet.com/php/get_current_page_url.php
|
||||
*/
|
||||
private function curPageURL()
|
||||
private function curPageURL(): string
|
||||
{
|
||||
$pageURL = 'http';
|
||||
if (!empty($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] == "on")) {
|
||||
|
|
|
@ -152,7 +152,7 @@ class Router
|
|||
*
|
||||
* @throws HTTPException\InternalServerErrorException In case of invalid configs
|
||||
*/
|
||||
public function loadRoutes(array $routes)
|
||||
public function loadRoutes(array $routes): Router
|
||||
{
|
||||
$routeCollector = ($this->routeCollector ?? new RouteCollector(new Std(), new GroupCountBased()));
|
||||
|
||||
|
@ -166,6 +166,13 @@ class Router
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds multiple routes to a route collector
|
||||
*
|
||||
* @param RouteCollector $routeCollector Route collector instance
|
||||
* @param array $routes Multiple routes to be added
|
||||
* @throws HTTPException\InternalServerErrorException If route was wrong (somehow)
|
||||
*/
|
||||
private function addRoutes(RouteCollector $routeCollector, array $routes)
|
||||
{
|
||||
foreach ($routes as $route => $config) {
|
||||
|
@ -221,7 +228,7 @@ class Router
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isRoute(array $config)
|
||||
private function isRoute(array $config): bool
|
||||
{
|
||||
return
|
||||
// The config array should at least have one entry
|
||||
|
@ -253,7 +260,7 @@ class Router
|
|||
* @throws HTTPException\MethodNotAllowedException If a rule matched but the method didn't
|
||||
* @throws HTTPException\NotFoundException If no rule matched
|
||||
*/
|
||||
private function getModuleClass()
|
||||
private function getModuleClass(): string
|
||||
{
|
||||
$cmd = $this->args->getCommand();
|
||||
$cmd = '/' . ltrim($cmd, '/');
|
||||
|
|
|
@ -70,9 +70,11 @@ class BaseCollection extends \ArrayIterator
|
|||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
* Getter for total count
|
||||
*
|
||||
* @return int Total count
|
||||
*/
|
||||
public function getTotalCount()
|
||||
public function getTotalCount(): int
|
||||
{
|
||||
return $this->totalCount;
|
||||
}
|
||||
|
@ -85,7 +87,7 @@ class BaseCollection extends \ArrayIterator
|
|||
* @return array
|
||||
* @see array_column()
|
||||
*/
|
||||
public function column($column, $index_key = null)
|
||||
public function column(string $column, $index_key = null): array
|
||||
{
|
||||
return array_column($this->getArrayCopy(true), $column, $index_key);
|
||||
}
|
||||
|
@ -97,7 +99,7 @@ class BaseCollection extends \ArrayIterator
|
|||
* @return BaseCollection
|
||||
* @see array_map()
|
||||
*/
|
||||
public function map(callable $callback)
|
||||
public function map(callable $callback): BaseCollection
|
||||
{
|
||||
return new static(array_map($callback, $this->getArrayCopy()), $this->getTotalCount());
|
||||
}
|
||||
|
@ -110,7 +112,7 @@ class BaseCollection extends \ArrayIterator
|
|||
* @return BaseCollection
|
||||
* @see array_filter()
|
||||
*/
|
||||
public function filter(callable $callback = null, int $flag = 0)
|
||||
public function filter(callable $callback = null, int $flag = 0): BaseCollection
|
||||
{
|
||||
return new static(array_filter($this->getArrayCopy(), $callback, $flag));
|
||||
}
|
||||
|
|
|
@ -55,14 +55,14 @@ abstract class BaseEntity extends BaseDataTransferObject
|
|||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param mixed $name
|
||||
* @return bool
|
||||
* @throws HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public function __isset($name)
|
||||
public function __isset($name): bool
|
||||
{
|
||||
if (!property_exists($this, $name)) {
|
||||
throw new HTTPException\InternalServerErrorException('Unknown property ' . $name . ' in Entity ' . static::class);
|
||||
throw new HTTPException\InternalServerErrorException('Unknown property ' . $name . ' of type ' . gettype($name) . ' in Entity ' . static::class);
|
||||
}
|
||||
|
||||
return !empty($this->$name);
|
||||
|
|
|
@ -110,11 +110,11 @@ abstract class BaseModel extends BaseDataTransferObject
|
|||
* - $model->field (outside of class)
|
||||
* - $this->field (inside of class)
|
||||
*
|
||||
* @param $name
|
||||
* @param string $name Name of data to fetch
|
||||
* @return mixed
|
||||
* @throws HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public function __get($name)
|
||||
public function __get(string $name)
|
||||
{
|
||||
$this->checkValid();
|
||||
|
||||
|
|
|
@ -331,7 +331,7 @@ abstract class BaseModule implements ICanHandleRequests
|
|||
* Actually, important actions should not be triggered by Links / GET-Requests at all, but sometimes they still are,
|
||||
* so this mechanism brings in some damage control (the attacker would be able to forge a request to a form of this type, but not to forms of other types).
|
||||
*/
|
||||
public static function getFormSecurityToken($typename = '')
|
||||
public static function getFormSecurityToken(string $typename = '')
|
||||
{
|
||||
$user = User::getById(DI::app()->getLoggedInUserId(), ['guid', 'prvkey']);
|
||||
$timestamp = time();
|
||||
|
@ -340,7 +340,14 @@ abstract class BaseModule implements ICanHandleRequests
|
|||
return $timestamp . '.' . $sec_hash;
|
||||
}
|
||||
|
||||
public static function checkFormSecurityToken($typename = '', $formname = 'form_security_token')
|
||||
/**
|
||||
* Checks if form's security (CSRF) token is valid.
|
||||
*
|
||||
* @param string $typename ???
|
||||
* @param string $formname Name of form/field (???)
|
||||
* @return bool Whether it is valid
|
||||
*/
|
||||
public static function checkFormSecurityToken(string $typename = '', string $formname = 'form_security_token'): bool
|
||||
{
|
||||
$hash = null;
|
||||
|
||||
|
@ -372,12 +379,12 @@ abstract class BaseModule implements ICanHandleRequests
|
|||
return ($sec_hash == $x[1]);
|
||||
}
|
||||
|
||||
public static function getFormSecurityStandardErrorMessage()
|
||||
public static function getFormSecurityStandardErrorMessage(): string
|
||||
{
|
||||
return DI::l10n()->t("The form security token was not correct. This probably happened because the form has been opened for too long \x28>3 hours\x29 before submitting it.") . EOL;
|
||||
}
|
||||
|
||||
public static function checkFormSecurityTokenRedirectOnError($err_redirect, $typename = '', $formname = 'form_security_token')
|
||||
public static function checkFormSecurityTokenRedirectOnError(string $err_redirect, string $typename = '', string $formname = 'form_security_token')
|
||||
{
|
||||
if (!self::checkFormSecurityToken($typename, $formname)) {
|
||||
Logger::notice('checkFormSecurityToken failed: user ' . DI::app()->getLoggedInUserNickname() . ' - form element ' . $typename);
|
||||
|
@ -387,7 +394,7 @@ abstract class BaseModule implements ICanHandleRequests
|
|||
}
|
||||
}
|
||||
|
||||
public static function checkFormSecurityTokenForbiddenOnError($typename = '', $formname = 'form_security_token')
|
||||
public static function checkFormSecurityTokenForbiddenOnError(string $typename = '', string $formname = 'form_security_token')
|
||||
{
|
||||
if (!self::checkFormSecurityToken($typename, $formname)) {
|
||||
Logger::notice('checkFormSecurityToken failed: user ' . DI::app()->getLoggedInUserNickname() . ' - form element ' . $typename);
|
||||
|
|
|
@ -123,7 +123,7 @@ class Avatar
|
|||
return $fields;
|
||||
}
|
||||
|
||||
private static function getFilename(string $url)
|
||||
private static function getFilename(string $url): string
|
||||
{
|
||||
$guid = Item::guidFromUri($url, parse_url($url, PHP_URL_HOST));
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ class BoundariesPager extends Pager
|
|||
* @param string $last_item_id The id† of the last item in the displayed item list
|
||||
* @param integer $itemsPerPage An optional number of items per page to override the default value
|
||||
*/
|
||||
public function __construct(L10n $l10n, $queryString, $first_item_id = null, $last_item_id = null, $itemsPerPage = 50)
|
||||
public function __construct(L10n $l10n, string $queryString, string $first_item_id = null, string $last_item_id = null, int $itemsPerPage = 50)
|
||||
{
|
||||
parent::__construct($l10n, $queryString, $itemsPerPage);
|
||||
|
||||
|
@ -102,7 +102,7 @@ class BoundariesPager extends Pager
|
|||
* @return string HTML string of the pager
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function renderMinimal(int $itemCount)
|
||||
public function renderMinimal(int $itemCount): string
|
||||
{
|
||||
$displayedItemCount = max(0, intval($itemCount));
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ class ContactSelector
|
|||
* @param boolean $disabled optional, default false
|
||||
* @return string
|
||||
*/
|
||||
public static function pollInterval($current, $disabled = false)
|
||||
public static function pollInterval(string $current, bool $disabled = false): string
|
||||
{
|
||||
$dis = (($disabled) ? ' disabled="disabled" ' : '');
|
||||
$o = '';
|
||||
|
@ -84,7 +84,7 @@ class ContactSelector
|
|||
* @return string Server URL
|
||||
* @throws \Exception
|
||||
*/
|
||||
private static function getServerURLForProfile($profile)
|
||||
private static function getServerURLForProfile(string $profile): string
|
||||
{
|
||||
if (!empty(self::$server_url[$profile])) {
|
||||
return self::$server_url[$profile];
|
||||
|
@ -111,13 +111,16 @@ 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($network, $profile = '', $protocol = '', $gsid = 0)
|
||||
public static function networkToName(string $network, string $profile = '', string $protocol = '', int $gsid = null): string
|
||||
{
|
||||
$nets = [
|
||||
Protocol::DFRN => DI::l10n()->t('DFRN'),
|
||||
|
@ -179,12 +182,15 @@ class ContactSelector
|
|||
}
|
||||
|
||||
/**
|
||||
* Determines network's icon name
|
||||
*
|
||||
* @param string $network network
|
||||
* @param string $profile optional, default empty
|
||||
* @return string
|
||||
* @param int $gsid Server id
|
||||
* @return string Name for network icon
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function networkToIcon($network, $profile = "", $gsid = 0)
|
||||
public static function networkToIcon(string $network, string $profile = "", int $gsid = null): string
|
||||
{
|
||||
$nets = [
|
||||
Protocol::DFRN => 'friendica',
|
||||
|
|
|
@ -189,7 +189,7 @@ class Conversation
|
|||
* @return string formatted text
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public function formatActivity(array $links, $verb, $id)
|
||||
public function formatActivity(array $links, string $verb, int $id): string
|
||||
{
|
||||
$this->profiler->startRecording('rendering');
|
||||
$o = '';
|
||||
|
@ -275,7 +275,7 @@ class Conversation
|
|||
return $o;
|
||||
}
|
||||
|
||||
public function statusEditor(array $x = [], $notes_cid = 0, $popup = false)
|
||||
public function statusEditor(array $x = [], int $notes_cid = 0, bool $popup = false): string
|
||||
{
|
||||
$user = User::getById($this->app->getLoggedInUserId(), ['uid', 'nickname', 'allow_location', 'default-location']);
|
||||
if (empty($user['uid'])) {
|
||||
|
@ -414,8 +414,8 @@ class Conversation
|
|||
* figures out how to determine page owner and other contextual items
|
||||
* that are based on unique features of the calling module.
|
||||
* @param array $items
|
||||
* @param $mode
|
||||
* @param $update
|
||||
* @param string $mode
|
||||
* @param $update @TODO Which type?
|
||||
* @param bool $preview
|
||||
* @param string $order
|
||||
* @param int $uid
|
||||
|
@ -423,7 +423,7 @@ class Conversation
|
|||
* @throws ImagickException
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public function create(array $items, $mode, $update, $preview = false, $order = 'commented', $uid = 0)
|
||||
public function create(array $items, string $mode, $update, bool $preview = false, string $order = 'commented', int $uid = 0): string
|
||||
{
|
||||
$this->profiler->startRecording('rendering');
|
||||
|
||||
|
@ -784,7 +784,7 @@ class Conversation
|
|||
return $o;
|
||||
}
|
||||
|
||||
private function getBlocklist()
|
||||
private function getBlocklist(): array
|
||||
{
|
||||
if (!local_user()) {
|
||||
return [];
|
||||
|
@ -816,7 +816,7 @@ class Conversation
|
|||
*
|
||||
* @return array items with parents and comments
|
||||
*/
|
||||
private function addRowInformation(array $row, array $activity, array $thr_parent)
|
||||
private function addRowInformation(array $row, array $activity, array $thr_parent): array
|
||||
{
|
||||
$this->profiler->startRecording('rendering');
|
||||
|
||||
|
@ -911,7 +911,7 @@ class Conversation
|
|||
* @return array items with parents and comments
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
private function addChildren(array $parents, bool $block_authors, string $order, int $uid, string $mode)
|
||||
private function addChildren(array $parents, bool $block_authors, string $order, int $uid, string $mode): array
|
||||
{
|
||||
$this->profiler->startRecording('rendering');
|
||||
if (count($parents) > 1) {
|
||||
|
@ -1005,7 +1005,7 @@ class Conversation
|
|||
* @param bool $recursive
|
||||
* @return array
|
||||
*/
|
||||
private function getItemChildren(array &$item_list, array $parent, $recursive = true)
|
||||
private function getItemChildren(array &$item_list, array $parent, bool $recursive = true): array
|
||||
{
|
||||
$this->profiler->startRecording('rendering');
|
||||
$children = [];
|
||||
|
@ -1040,7 +1040,7 @@ class Conversation
|
|||
* @param array $items
|
||||
* @return array
|
||||
*/
|
||||
private function sortItemChildren(array $items)
|
||||
private function sortItemChildren(array $items): array
|
||||
{
|
||||
$this->profiler->startRecording('rendering');
|
||||
$result = $items;
|
||||
|
@ -1086,7 +1086,7 @@ class Conversation
|
|||
* @param array $parent A tree-like array of items
|
||||
* @return array
|
||||
*/
|
||||
private function smartFlattenConversation(array $parent)
|
||||
private function smartFlattenConversation(array $parent): array
|
||||
{
|
||||
$this->profiler->startRecording('rendering');
|
||||
if (!isset($parent['children']) || count($parent['children']) == 0) {
|
||||
|
@ -1142,7 +1142,7 @@ class Conversation
|
|||
* @return array
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
private function convSort(array $item_list, $order)
|
||||
private function convSort(array $item_list, string $order): array
|
||||
{
|
||||
$this->profiler->startRecording('rendering');
|
||||
$parents = [];
|
||||
|
@ -1222,7 +1222,7 @@ class Conversation
|
|||
* @param array $b
|
||||
* @return int
|
||||
*/
|
||||
private function sortThrFeaturedReceived(array $a, array $b)
|
||||
private function sortThrFeaturedReceived(array $a, array $b): int
|
||||
{
|
||||
if ($b['featured'] && !$a['featured']) {
|
||||
return 1;
|
||||
|
@ -1240,7 +1240,7 @@ class Conversation
|
|||
* @param array $b
|
||||
* @return int
|
||||
*/
|
||||
private function sortThrFeaturedCommented(array $a, array $b)
|
||||
private function sortThrFeaturedCommented(array $a, array $b): int
|
||||
{
|
||||
if ($b['featured'] && !$a['featured']) {
|
||||
return 1;
|
||||
|
@ -1258,7 +1258,7 @@ class Conversation
|
|||
* @param array $b
|
||||
* @return int
|
||||
*/
|
||||
private function sortThrReceived(array $a, array $b)
|
||||
private function sortThrReceived(array $a, array $b): int
|
||||
{
|
||||
return strcmp($b['received'], $a['received']);
|
||||
}
|
||||
|
@ -1270,7 +1270,7 @@ class Conversation
|
|||
* @param array $b
|
||||
* @return int
|
||||
*/
|
||||
private function sortThrReceivedRev(array $a, array $b)
|
||||
private function sortThrReceivedRev(array $a, array $b): int
|
||||
{
|
||||
return strcmp($a['received'], $b['received']);
|
||||
}
|
||||
|
@ -1282,7 +1282,7 @@ class Conversation
|
|||
* @param array $b
|
||||
* @return int
|
||||
*/
|
||||
private function sortThrCommented(array $a, array $b)
|
||||
private function sortThrCommented(array $a, array $b): int
|
||||
{
|
||||
return strcmp($b['commented'], $a['commented']);
|
||||
}
|
||||
|
@ -1294,7 +1294,7 @@ class Conversation
|
|||
* @param array $b
|
||||
* @return int
|
||||
*/
|
||||
private function sortThrCreated(array $a, array $b)
|
||||
private function sortThrCreated(array $a, array $b): int
|
||||
{
|
||||
return strcmp($b['created'], $a['created']);
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ class Widget
|
|||
* @return string
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function follow($value = "")
|
||||
public static function follow(string $value = ''): string
|
||||
{
|
||||
return Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/follow.tpl'), array(
|
||||
'$connect' => DI::l10n()->t('Add New Contact'),
|
||||
|
@ -58,8 +58,10 @@ class Widget
|
|||
|
||||
/**
|
||||
* Return Find People widget
|
||||
*
|
||||
* @return string HTML code respresenting "People Widget"
|
||||
*/
|
||||
public static function findPeople()
|
||||
public static function findPeople(): string
|
||||
{
|
||||
$global_dir = Search::getGlobalDirectory();
|
||||
|
||||
|
@ -97,7 +99,7 @@ class Widget
|
|||
*
|
||||
* @return array Unsupported networks
|
||||
*/
|
||||
public static function unavailableNetworks()
|
||||
public static function unavailableNetworks(): array
|
||||
{
|
||||
// Always hide content from these networks
|
||||
$networks = [Protocol::PHANTOM, Protocol::FACEBOOK, Protocol::APPNET, Protocol::ZOT];
|
||||
|
@ -154,7 +156,7 @@ class Widget
|
|||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
private static function filter($type, $title, $desc, $all, $baseUrl, array $options, $selected = null)
|
||||
private static function filter(string $type, string $title, string $desc, string $all, string $baseUrl, array $options, string $selected = null): string
|
||||
{
|
||||
$queryString = parse_url($baseUrl, PHP_URL_QUERY);
|
||||
$queryArray = [];
|
||||
|
@ -191,7 +193,7 @@ class Widget
|
|||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function groups($baseurl, $selected = '')
|
||||
public static function groups(string $baseurl, string $selected = ''): string
|
||||
{
|
||||
if (!local_user()) {
|
||||
return '';
|
||||
|
|
|
@ -60,7 +60,7 @@ class Worker
|
|||
* @return void
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function processQueue($run_cron, Process $process)
|
||||
public static function processQueue(bool $run_cron, Process $process)
|
||||
{
|
||||
self::$up_start = microtime(true);
|
||||
|
||||
|
@ -169,7 +169,7 @@ class Worker
|
|||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isReady()
|
||||
public static function isReady(): bool
|
||||
{
|
||||
// Count active workers and compare them with a maximum value that depends on the load
|
||||
if (self::tooMuchWorkers()) {
|
||||
|
@ -204,7 +204,7 @@ class Worker
|
|||
* @return boolean Returns "true" if tasks are existing
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function entriesExists()
|
||||
public static function entriesExists(): bool
|
||||
{
|
||||
$stamp = (float)microtime(true);
|
||||
$exists = DBA::exists('workerqueue', ["NOT `done` AND `pid` = 0 AND `next_try` < ?", DateTimeFormat::utcNow()]);
|
||||
|
@ -218,7 +218,7 @@ class Worker
|
|||
* @return integer Number of deferred entries in the worker queue
|
||||
* @throws \Exception
|
||||
*/
|
||||
private static function deferredEntries()
|
||||
private static function deferredEntries(): int
|
||||
{
|
||||
$stamp = (float)microtime(true);
|
||||
$count = DBA::count('workerqueue', ["NOT `done` AND `pid` = 0 AND `retrial` > ?", 0]);
|
||||
|
@ -233,7 +233,7 @@ class Worker
|
|||
* @return integer Number of non executed entries in the worker queue
|
||||
* @throws \Exception
|
||||
*/
|
||||
private static function totalEntries()
|
||||
private static function totalEntries(): int
|
||||
{
|
||||
$stamp = (float)microtime(true);
|
||||
$count = DBA::count('workerqueue', ['done' => false, 'pid' => 0]);
|
||||
|
@ -248,7 +248,7 @@ class Worker
|
|||
* @return integer Number of active worker processes
|
||||
* @throws \Exception
|
||||
*/
|
||||
private static function highestPriority()
|
||||
private static function highestPriority(): int
|
||||
{
|
||||
$stamp = (float)microtime(true);
|
||||
$condition = ["`pid` = 0 AND NOT `done` AND `next_try` < ?", DateTimeFormat::utcNow()];
|
||||
|
@ -269,7 +269,7 @@ class Worker
|
|||
* @return integer Is there a process running with that priority?
|
||||
* @throws \Exception
|
||||
*/
|
||||
private static function processWithPriorityActive($priority)
|
||||
private static function processWithPriorityActive(int $priority): int
|
||||
{
|
||||
$condition = ["`priority` <= ? AND `pid` != 0 AND NOT `done`", $priority];
|
||||
return DBA::exists('workerqueue', $condition);
|
||||
|
@ -281,7 +281,7 @@ class Worker
|
|||
* @param mixed $file
|
||||
* @return bool
|
||||
*/
|
||||
private static function validateInclude(&$file)
|
||||
private static function validateInclude(&$file): bool
|
||||
{
|
||||
$orig_file = $file;
|
||||
|
||||
|
@ -321,7 +321,7 @@ class Worker
|
|||
* @return boolean "true" if further processing should be stopped
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function execute($queue)
|
||||
public static function execute(array $queue): bool
|
||||
{
|
||||
$mypid = getmypid();
|
||||
|
||||
|
@ -454,7 +454,7 @@ class Worker
|
|||
* @return void
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
private static function execFunction($queue, $funcname, $argv, $method_call)
|
||||
private static function execFunction(array $queue, string $funcname, array $argv, bool $method_call)
|
||||
{
|
||||
$a = DI::app();
|
||||
|
||||
|
@ -543,7 +543,7 @@ class Worker
|
|||
* @return bool Are more than 3/4 of the maximum connections used?
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
private static function maxConnectionsReached()
|
||||
private static function maxConnectionsReached(): bool
|
||||
{
|
||||
// Fetch the max value from the config. This is needed when the system cannot detect the correct value by itself.
|
||||
$max = DI::config()->get("system", "max_connections");
|
||||
|
@ -627,7 +627,7 @@ class Worker
|
|||
* @return bool Are there too much workers running?
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
private static function tooMuchWorkers()
|
||||
private static function tooMuchWorkers(): bool
|
||||
{
|
||||
$queues = DI::config()->get("system", "worker_queues", 10);
|
||||
|
||||
|
@ -751,7 +751,7 @@ class Worker
|
|||
* @return integer Number of active worker processes
|
||||
* @throws \Exception
|
||||
*/
|
||||
private static function activeWorkers()
|
||||
private static function activeWorkers(): int
|
||||
{
|
||||
$stamp = (float)microtime(true);
|
||||
$count = DI::process()->countCommand('Worker.php');
|
||||
|
@ -766,7 +766,7 @@ class Worker
|
|||
* @return array List of worker process ids
|
||||
* @throws \Exception
|
||||
*/
|
||||
private static function getWorkerPIDList()
|
||||
private static function getWorkerPIDList(): array
|
||||
{
|
||||
$ids = [];
|
||||
$stamp = (float)microtime(true);
|
||||
|
@ -787,7 +787,7 @@ class Worker
|
|||
/**
|
||||
* Returns waiting jobs for the current process id
|
||||
*
|
||||
* @return array waiting workerqueue jobs
|
||||
* @return array|bool waiting workerqueue jobs or FALSE on failture
|
||||
* @throws \Exception
|
||||
*/
|
||||
private static function getWaitingJobForPID()
|
||||
|
@ -809,7 +809,7 @@ class Worker
|
|||
* @return array array with next jobs
|
||||
* @throws \Exception
|
||||
*/
|
||||
private static function nextProcess(int $limit)
|
||||
private static function nextProcess(int $limit): array
|
||||
{
|
||||
$priority = self::nextPriority();
|
||||
if (empty($priority)) {
|
||||
|
@ -844,7 +844,7 @@ class Worker
|
|||
/**
|
||||
* Returns the priority of the next workerqueue job
|
||||
*
|
||||
* @return string priority
|
||||
* @return string|bool priority or FALSE on failure
|
||||
* @throws \Exception
|
||||
*/
|
||||
private static function nextPriority()
|
||||
|
@ -915,7 +915,7 @@ class Worker
|
|||
/**
|
||||
* Find and claim the next worker process for us
|
||||
*
|
||||
* @return boolean Have we found something?
|
||||
* @return void
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
private static function findWorkerProcesses()
|
||||
|
@ -993,7 +993,7 @@ class Worker
|
|||
* @return array worker processes
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function workerProcess()
|
||||
public static function workerProcess(): array
|
||||
{
|
||||
// There can already be jobs for us in the queue.
|
||||
$waiting = self::getWaitingJobForPID();
|
||||
|
@ -1003,7 +1003,7 @@ class Worker
|
|||
|
||||
$stamp = (float)microtime(true);
|
||||
if (!DI::lock()->acquire(self::LOCK_PROCESS)) {
|
||||
return false;
|
||||
return [];
|
||||
}
|
||||
self::$lock_duration += (microtime(true) - $stamp);
|
||||
|
||||
|
@ -1011,7 +1011,9 @@ class Worker
|
|||
|
||||
DI::lock()->release(self::LOCK_PROCESS);
|
||||
|
||||
return self::getWaitingJobForPID();
|
||||
// Prevents "Return value of Friendica\Core\Worker::workerProcess() must be of the type array, bool returned"
|
||||
$process = self::getWaitingJobForPID();
|
||||
return (is_array($process) ? $process : []);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1097,7 +1099,7 @@ class Worker
|
|||
* @return void
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function spawnWorker($do_cron = false)
|
||||
public static function spawnWorker(bool $do_cron = false)
|
||||
{
|
||||
if (Worker\Daemon::isMode() && DI::config()->get('system', 'worker_fork')) {
|
||||
self::forkProcess($do_cron);
|
||||
|
@ -1231,7 +1233,7 @@ class Worker
|
|||
return $added;
|
||||
}
|
||||
|
||||
public static function countWorkersByCommand(string $command)
|
||||
public static function countWorkersByCommand(string $command): int
|
||||
{
|
||||
return DBA::count('workerqueue', ['done' => false, 'pid' => 0, 'command' => $command]);
|
||||
}
|
||||
|
@ -1244,7 +1246,7 @@ class Worker
|
|||
* @param integer $max_level maximum retrial level
|
||||
* @return integer the next retrial level value
|
||||
*/
|
||||
private static function getNextRetrial($queue, $max_level)
|
||||
private static function getNextRetrial(array $queue, int $max_level): int
|
||||
{
|
||||
$created = strtotime($queue['created']);
|
||||
$retrial_time = time() - $created;
|
||||
|
@ -1314,9 +1316,10 @@ class Worker
|
|||
/**
|
||||
* Check if the system is inside the defined maintenance window
|
||||
*
|
||||
* @param bool $check_last_execution Whether check last execution
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isInMaintenanceWindow(bool $check_last_execution = false)
|
||||
public static function isInMaintenanceWindow(bool $check_last_execution = false): bool
|
||||
{
|
||||
// Calculate the seconds of the start end end of the maintenance window
|
||||
$start = strtotime(DI::config()->get('system', 'maintenance_start')) % 86400;
|
||||
|
|
|
@ -427,7 +427,7 @@ class DBA
|
|||
* @return boolean was the update successfull?
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function update($table, $fields, $condition, $old_fields = [], $params = [])
|
||||
public static function update($table, array $fields, array $condition, $old_fields = [], array $params = [])
|
||||
{
|
||||
return DI::dba()->update($table, $fields, $condition, $old_fields, $params);
|
||||
}
|
||||
|
@ -443,7 +443,7 @@ class DBA
|
|||
* @throws \Exception
|
||||
* @see self::select
|
||||
*/
|
||||
public static function selectFirst($table, array $fields = [], array $condition = [], $params = [])
|
||||
public static function selectFirst($table, array $fields = [], array $condition = [], array $params = [])
|
||||
{
|
||||
return DI::dba()->selectFirst($table, $fields, $condition, $params);
|
||||
}
|
||||
|
@ -512,7 +512,7 @@ class DBA
|
|||
* $count = DBA::count($table, $condition);
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function count($table, array $condition = [], array $params = [])
|
||||
public static function count($table, array $condition = [], array $params = []): int
|
||||
{
|
||||
return DI::dba()->count($table, $condition, $params);
|
||||
}
|
||||
|
@ -771,7 +771,7 @@ class DBA
|
|||
*
|
||||
* @return array Data array
|
||||
*/
|
||||
public static function toArray($stmt, $do_close = true, int $count = 0)
|
||||
public static function toArray($stmt, $do_close = true, int $count = 0): array
|
||||
{
|
||||
return DI::dba()->toArray($stmt, $do_close, $count);
|
||||
}
|
||||
|
@ -783,7 +783,7 @@ class DBA
|
|||
* @param array $fields
|
||||
* @return array casted fields
|
||||
*/
|
||||
public static function castFields(string $table, array $fields)
|
||||
public static function castFields(string $table, array $fields): array
|
||||
{
|
||||
return DI::dba()->castFields($table, $fields);
|
||||
}
|
||||
|
@ -793,7 +793,7 @@ class DBA
|
|||
*
|
||||
* @return string Error number (0 if no error)
|
||||
*/
|
||||
public static function errorNo()
|
||||
public static function errorNo(): int
|
||||
{
|
||||
return DI::dba()->errorNo();
|
||||
}
|
||||
|
@ -803,7 +803,7 @@ class DBA
|
|||
*
|
||||
* @return string Error message ('' if no error)
|
||||
*/
|
||||
public static function errorMessage()
|
||||
public static function errorMessage(): string
|
||||
{
|
||||
return DI::dba()->errorMessage();
|
||||
}
|
||||
|
@ -814,7 +814,7 @@ class DBA
|
|||
* @param object $stmt statement object
|
||||
* @return boolean was the close successful?
|
||||
*/
|
||||
public static function close($stmt)
|
||||
public static function close($stmt): bool
|
||||
{
|
||||
return DI::dba()->close($stmt);
|
||||
}
|
||||
|
@ -827,7 +827,7 @@ class DBA
|
|||
* 'amount' => Number of concurrent database processes
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function processlist()
|
||||
public static function processlist(): array
|
||||
{
|
||||
return DI::dba()->processlist();
|
||||
}
|
||||
|
|
|
@ -541,7 +541,7 @@ class Database
|
|||
if (!$retval = $this->connection->query($this->replaceParameters($sql, $args))) {
|
||||
$errorInfo = $this->connection->errorInfo();
|
||||
$this->error = $errorInfo[2];
|
||||
$this->errorno = $errorInfo[1];
|
||||
$this->errorno = (int) $errorInfo[1];
|
||||
$retval = false;
|
||||
$is_error = true;
|
||||
break;
|
||||
|
@ -554,7 +554,7 @@ class Database
|
|||
if (!$stmt = $this->connection->prepare($sql)) {
|
||||
$errorInfo = $this->connection->errorInfo();
|
||||
$this->error = $errorInfo[2];
|
||||
$this->errorno = $errorInfo[1];
|
||||
$this->errorno = (int) $errorInfo[1];
|
||||
$retval = false;
|
||||
$is_error = true;
|
||||
break;
|
||||
|
@ -574,7 +574,7 @@ class Database
|
|||
if (!$stmt->execute()) {
|
||||
$errorInfo = $stmt->errorInfo();
|
||||
$this->error = $errorInfo[2];
|
||||
$this->errorno = $errorInfo[1];
|
||||
$this->errorno = (int) $errorInfo[1];
|
||||
$retval = false;
|
||||
$is_error = true;
|
||||
} else {
|
||||
|
@ -709,7 +709,7 @@ class Database
|
|||
}
|
||||
|
||||
$this->error = $error;
|
||||
$this->errorno = $errorno;
|
||||
$this->errorno = (int) $errorno;
|
||||
}
|
||||
|
||||
$this->profiler->stopRecording();
|
||||
|
@ -1541,7 +1541,7 @@ class Database
|
|||
*
|
||||
* @return array Data array
|
||||
*/
|
||||
public function toArray($stmt, $do_close = true, int $count = 0)
|
||||
public function toArray($stmt, bool $do_close = true, int $count = 0): array
|
||||
{
|
||||
if (is_bool($stmt)) {
|
||||
return [];
|
||||
|
@ -1632,7 +1632,7 @@ class Database
|
|||
*
|
||||
* @return string Error number (0 if no error)
|
||||
*/
|
||||
public function errorNo()
|
||||
public function errorNo(): int
|
||||
{
|
||||
return $this->errorno;
|
||||
}
|
||||
|
@ -1654,7 +1654,7 @@ class Database
|
|||
*
|
||||
* @return boolean was the close successful?
|
||||
*/
|
||||
public function close($stmt)
|
||||
public function close($stmt): bool
|
||||
{
|
||||
|
||||
$this->profiler->startRecording('database');
|
||||
|
@ -1696,7 +1696,7 @@ class Database
|
|||
* 'amount' => Number of concurrent database processes
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function processlist()
|
||||
public function processlist(): array
|
||||
{
|
||||
$ret = $this->p("SHOW PROCESSLIST");
|
||||
$data = $this->toArray($ret);
|
||||
|
|
|
@ -57,7 +57,7 @@ class Account extends BaseFactory
|
|||
* @throws HTTPException\InternalServerErrorException
|
||||
* @throws ImagickException|HTTPException\NotFoundException
|
||||
*/
|
||||
public function createFromContactId(int $contactId, $uid = 0): \Friendica\Object\Api\Mastodon\Account
|
||||
public function createFromContactId(int $contactId, int $uid = 0): \Friendica\Object\Api\Mastodon\Account
|
||||
{
|
||||
$contact = Contact::getById($contactId, ['uri-id']);
|
||||
if (empty($contact)) {
|
||||
|
@ -74,7 +74,7 @@ class Account extends BaseFactory
|
|||
* @throws HTTPException\InternalServerErrorException
|
||||
* @throws ImagickException|HTTPException\NotFoundException
|
||||
*/
|
||||
public function createFromUriId(int $contactUriId, $uid = 0): \Friendica\Object\Api\Mastodon\Account
|
||||
public function createFromUriId(int $contactUriId, int $uid = 0): \Friendica\Object\Api\Mastodon\Account
|
||||
{
|
||||
$account = DBA::selectFirst('account-user-view', [], ['uri-id' => $contactUriId, 'uid' => [0, $uid]], ['order' => ['id' => true]]);
|
||||
if (empty($account)) {
|
||||
|
|
|
@ -70,6 +70,7 @@ class Status extends BaseFactory
|
|||
/**
|
||||
* @param int $uriId 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
|
||||
|
@ -90,12 +91,13 @@ class Status extends BaseFactory
|
|||
/**
|
||||
* @param int $uriId 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
|
||||
*/
|
||||
public function createFromUriId(int $uriId, $uid = 0, $include_entities = false): \Friendica\Object\Api\Twitter\Status
|
||||
public function createFromUriId(int $uriId, int $uid = 0, bool $include_entities = false): \Friendica\Object\Api\Twitter\Status
|
||||
{
|
||||
$fields = ['parent-uri-id', 'uri-id', 'uid', 'author-id', 'author-link', 'author-network', 'owner-id', 'causer-id',
|
||||
'starred', 'app', 'title', 'body', 'raw-body', 'created', 'network','post-reason', 'language', 'gravity',
|
||||
|
@ -110,6 +112,7 @@ class Status extends BaseFactory
|
|||
/**
|
||||
* @param array $item item array
|
||||
* @param int $uid Item user
|
||||
* @param bool $include_entities Whether to include entities
|
||||
*
|
||||
* @return \Friendica\Object\Api\Twitter\Status
|
||||
* @throws HTTPException\InternalServerErrorException
|
||||
|
|
|
@ -51,7 +51,7 @@ class User extends BaseFactory
|
|||
* @throws HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public function createFromContactId(int $contactId, $uid = 0, $skip_status = true, $include_user_entities = true)
|
||||
public function createFromContactId(int $contactId, int $uid = 0, bool $skip_status = true, bool $include_user_entities = true)
|
||||
{
|
||||
$cdata = Contact::getPublicAndUserContactID($contactId, $uid);
|
||||
if (!empty($cdata)) {
|
||||
|
@ -78,7 +78,7 @@ class User extends BaseFactory
|
|||
return new \Friendica\Object\Api\Twitter\User($publicContact, $apcontact, $userContact, $status, $include_user_entities);
|
||||
}
|
||||
|
||||
public function createFromUserId(int $uid, $skip_status = true, $include_user_entities = true)
|
||||
public function createFromUserId(int $uid, bool $skip_status = true, bool $include_user_entities = true)
|
||||
{
|
||||
return $this->createFromContactId(Contact::getPublicIdByUserId($uid), $uid, $skip_status, $include_user_entities);
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ class LegacyModule extends BaseModule
|
|||
* @param string $file_path
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function setModuleFile($file_path)
|
||||
private function setModuleFile(string $file_path)
|
||||
{
|
||||
if (!is_readable($file_path)) {
|
||||
throw new \Exception(DI::l10n()->t('Legacy module file not found: %s', $file_path));
|
||||
|
@ -87,7 +87,7 @@ class LegacyModule extends BaseModule
|
|||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function runModuleFunction(string $function_suffix)
|
||||
private function runModuleFunction(string $function_suffix): string
|
||||
{
|
||||
$function_name = $this->moduleName . '_' . $function_suffix;
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ class APContact
|
|||
* @param string $addr Address
|
||||
* @return array webfinger data
|
||||
*/
|
||||
private static function fetchWebfingerData(string $addr)
|
||||
private static function fetchWebfingerData(string $addr): array
|
||||
{
|
||||
$addr_parts = explode('@', $addr);
|
||||
if (count($addr_parts) != 2) {
|
||||
|
@ -117,14 +117,14 @@ class APContact
|
|||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function getByURL($url, $update = null)
|
||||
public static function getByURL(string $url, $update = null): array
|
||||
{
|
||||
if (empty($url) || Network::isUrlBlocked($url)) {
|
||||
Logger::info('Domain is blocked', ['url' => $url]);
|
||||
return [];
|
||||
}
|
||||
|
||||
$fetched_contact = false;
|
||||
$fetched_contact = [];
|
||||
|
||||
if (empty($update)) {
|
||||
if (is_null($update)) {
|
||||
|
@ -220,14 +220,14 @@ class APContact
|
|||
$apcontact['type'] = str_replace('as:', '', JsonLD::fetchElement($compacted, '@type'));
|
||||
$apcontact['following'] = JsonLD::fetchElement($compacted, 'as:following', '@id');
|
||||
$apcontact['followers'] = JsonLD::fetchElement($compacted, 'as:followers', '@id');
|
||||
$apcontact['inbox'] = JsonLD::fetchElement($compacted, 'ldp:inbox', '@id');
|
||||
$apcontact['inbox'] = (JsonLD::fetchElement($compacted, 'ldp:inbox', '@id') ?? '');
|
||||
self::unarchiveInbox($apcontact['inbox'], false);
|
||||
|
||||
$apcontact['outbox'] = JsonLD::fetchElement($compacted, 'as:outbox', '@id');
|
||||
|
||||
$apcontact['sharedinbox'] = '';
|
||||
if (!empty($compacted['as:endpoints'])) {
|
||||
$apcontact['sharedinbox'] = JsonLD::fetchElement($compacted['as:endpoints'], 'as:sharedInbox', '@id');
|
||||
$apcontact['sharedinbox'] = (JsonLD::fetchElement($compacted['as:endpoints'], 'as:sharedInbox', '@id') ?? '');
|
||||
self::unarchiveInbox($apcontact['sharedinbox'], true);
|
||||
}
|
||||
|
||||
|
@ -527,7 +527,7 @@ class APContact
|
|||
* @param string $url inbox url
|
||||
* @param boolean $shared Shared Inbox
|
||||
*/
|
||||
private static function unarchiveInbox($url, $shared)
|
||||
private static function unarchiveInbox(string $url, bool $shared)
|
||||
{
|
||||
if (empty($url)) {
|
||||
return;
|
||||
|
|
|
@ -59,7 +59,7 @@ class Attach
|
|||
* @param array $conditions Array of fields for conditions
|
||||
* @param array $params Array of several parameters
|
||||
*
|
||||
* @return array
|
||||
* @return array|bool
|
||||
*
|
||||
* @throws \Exception
|
||||
* @see \Friendica\Database\DBA::selectToArray
|
||||
|
@ -102,7 +102,7 @@ class Attach
|
|||
* @return boolean
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function exists(array $conditions)
|
||||
public static function exists(array $conditions): bool
|
||||
{
|
||||
return DBA::exists('attach', $conditions);
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ class Attach
|
|||
* @throws \Exception
|
||||
* @see \Friendica\Database\DBA::select
|
||||
*/
|
||||
public static function getById($id)
|
||||
public static function getById(int $id)
|
||||
{
|
||||
return self::selectFirst([], ['id' => $id]);
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ class Attach
|
|||
* @throws \Exception
|
||||
* @see \Friendica\Database\DBA::select
|
||||
*/
|
||||
public static function getByIdWithPermission($id)
|
||||
public static function getByIdWithPermission(int $id)
|
||||
{
|
||||
$r = self::selectFirst(['uid'], ['id' => $id]);
|
||||
if ($r === false) {
|
||||
|
@ -156,10 +156,10 @@ class Attach
|
|||
*
|
||||
* @param array $item Attachment data. Needs at least 'id', 'backend-class', 'backend-ref'
|
||||
*
|
||||
* @return string file data
|
||||
* @return string|null file data or null on failure
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function getData($item)
|
||||
public static function getData(array $item)
|
||||
{
|
||||
if (!empty($item['data'])) {
|
||||
return $item['data'];
|
||||
|
@ -195,10 +195,10 @@ class Attach
|
|||
* @param string $deny_cid Permissions, denied contacts.optional, default = ''
|
||||
* @param string $deny_gid Permissions, denied greoup.optional, default = ''
|
||||
*
|
||||
* @return boolean/integer Row id on success, False on errors
|
||||
* @return boolean|integer Row id on success, False on errors
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function store($data, $uid, $filename, $filetype = '' , $filesize = null, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '')
|
||||
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 = '')
|
||||
{
|
||||
if ($filetype === '') {
|
||||
$filetype = Mimetype::getContentType($filename);
|
||||
|
@ -241,17 +241,17 @@ class Attach
|
|||
/**
|
||||
* Store new file metadata in db and binary in default backend from existing file
|
||||
*
|
||||
* @param $src
|
||||
* @param $uid
|
||||
* @param string $filename
|
||||
* @param string $src Source file name
|
||||
* @param int $uid User id
|
||||
* @param string $filename Optional file name
|
||||
* @param string $allow_cid
|
||||
* @param string $allow_gid
|
||||
* @param string $deny_cid
|
||||
* @param string $deny_gid
|
||||
* @return boolean True on success
|
||||
* @return boolean|int Insert id or false on failure
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function storeFile($src, $uid, $filename = '', $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '')
|
||||
public static function storeFile(string $src, int $uid, string $filename = '', string $allow_cid = '', string $allow_gid = '', string $deny_cid = '', string $deny_gid = '')
|
||||
{
|
||||
if ($filename === '') {
|
||||
$filename = basename($src);
|
||||
|
@ -276,7 +276,7 @@ class Attach
|
|||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @see \Friendica\Database\DBA::update
|
||||
*/
|
||||
public static function update($fields, $conditions, Image $img = null, array $old_fields = [])
|
||||
public static function update(array $fields, array $conditions, Image $img = null, array $old_fields = []): bool
|
||||
{
|
||||
if (!is_null($img)) {
|
||||
// get items to update
|
||||
|
@ -311,7 +311,7 @@ class Attach
|
|||
* @throws \Exception
|
||||
* @see \Friendica\Database\DBA::delete
|
||||
*/
|
||||
public static function delete(array $conditions, array $options = [])
|
||||
public static function delete(array $conditions, array $options = []): bool
|
||||
{
|
||||
// get items to delete data info
|
||||
$items = self::selectToArray(['backend-class','backend-ref'], $conditions);
|
||||
|
|
|
@ -119,7 +119,7 @@ class Contact
|
|||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function selectToArray(array $fields = [], array $condition = [], array $params = [])
|
||||
public static function selectToArray(array $fields = [], array $condition = [], array $params = []): array
|
||||
{
|
||||
return DBA::selectToArray('contact', $fields, $condition, $params);
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ class Contact
|
|||
* @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
|
||||
* @return array
|
||||
* @return array|bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function selectFirst(array $fields = [], array $condition = [], array $params = [])
|
||||
|
@ -148,7 +148,7 @@ class Contact
|
|||
* @return int id of the created contact
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function insert(array $fields, int $duplicate_mode = Database::INSERT_DEFAULT)
|
||||
public static function insert(array $fields, int $duplicate_mode = Database::INSERT_DEFAULT): int
|
||||
{
|
||||
if (!empty($fields['baseurl']) && empty($fields['gsid'])) {
|
||||
$fields['gsid'] = GServer::getID($fields['baseurl'], true);
|
||||
|
@ -187,6 +187,7 @@ class Contact
|
|||
*
|
||||
* @return boolean was the update successfull?
|
||||
* @throws \Exception
|
||||
* @todo Let's get rid of boolean type of $old_fields
|
||||
*/
|
||||
public static function update(array $fields, array $condition, $old_fields = [])
|
||||
{
|
||||
|
@ -204,7 +205,7 @@ class Contact
|
|||
* @return array|boolean Contact record if it exists, false otherwise
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function getById($id, $fields = [])
|
||||
public static function getById(int $id, array $fields = [])
|
||||
{
|
||||
return DBA::selectFirst('contact', $fields, ['id' => $id]);
|
||||
}
|
||||
|
@ -217,7 +218,7 @@ class Contact
|
|||
* @return array|boolean Contact record if it exists, false otherwise
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function getByUriId($uri_id, $fields = [])
|
||||
public static function getByUriId(int $uri_id, array $fields = [])
|
||||
{
|
||||
return DBA::selectFirst('contact', $fields, ['uri-id' => $uri_id], ['order' => ['uid']]);
|
||||
}
|
||||
|
@ -231,7 +232,7 @@ class Contact
|
|||
* @param integer $uid User ID of the contact
|
||||
* @return array contact array
|
||||
*/
|
||||
public static function getByURL(string $url, $update = null, array $fields = [], int $uid = 0)
|
||||
public static function getByURL(string $url, $update = null, array $fields = [], int $uid = 0): array
|
||||
{
|
||||
if ($update || is_null($update)) {
|
||||
$cid = self::getIdForURL($url, $uid, $update);
|
||||
|
@ -302,7 +303,7 @@ class Contact
|
|||
* @param array $fields Field list
|
||||
* @return array contact array
|
||||
*/
|
||||
public static function getByURLForUser(string $url, int $uid = 0, $update = false, array $fields = [])
|
||||
public static function getByURLForUser(string $url, int $uid = 0, $update = false, array $fields = []): array
|
||||
{
|
||||
if ($uid != 0) {
|
||||
$contact = self::getByURL($url, $update, $fields, $uid);
|
||||
|
@ -333,7 +334,7 @@ class Contact
|
|||
* @throws HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function isFollower($cid, $uid)
|
||||
public static function isFollower(int $cid, int $uid): bool
|
||||
{
|
||||
if (Contact\User::isBlocked($cid, $uid)) {
|
||||
return false;
|
||||
|
@ -358,7 +359,7 @@ class Contact
|
|||
* @throws HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function isFollowerByURL($url, $uid)
|
||||
public static function isFollowerByURL(string $url, uid $uid): bool
|
||||
{
|
||||
$cid = self::getIdForURL($url, $uid);
|
||||
|
||||
|
@ -370,16 +371,16 @@ class Contact
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests if the given user follow the given contact
|
||||
* Tests if the given user shares with the given contact
|
||||
*
|
||||
* @param int $cid Either public contact id or user's contact id
|
||||
* @param int $uid User ID
|
||||
*
|
||||
* @return boolean is the contact url being followed?
|
||||
* @return boolean is the contact sharing with given user?
|
||||
* @throws HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function isSharing($cid, $uid)
|
||||
public static function isSharing(int $cid, int $uid): bool
|
||||
{
|
||||
if (Contact\User::isBlocked($cid, $uid)) {
|
||||
return false;
|
||||
|
@ -404,7 +405,7 @@ class Contact
|
|||
* @throws HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function isSharingByURL($url, $uid)
|
||||
public static function isSharingByURL(string $url, int $uid): bool
|
||||
{
|
||||
$cid = self::getIdForURL($url, $uid);
|
||||
|
||||
|
@ -425,7 +426,7 @@ class Contact
|
|||
* @throws HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function getBasepath($url, $dont_update = false)
|
||||
public static function getBasepath(string $url, bool $dont_update = false): string
|
||||
{
|
||||
$contact = DBA::selectFirst('contact', ['id', 'baseurl'], ['uid' => 0, 'nurl' => Strings::normaliseLink($url)]);
|
||||
if (!DBA::isResult($contact)) {
|
||||
|
@ -459,7 +460,7 @@ class Contact
|
|||
*
|
||||
* @return boolean Is it the same server?
|
||||
*/
|
||||
public static function isLocal($url)
|
||||
public static function isLocal(string $url): bool
|
||||
{
|
||||
if (!parse_url($url, PHP_URL_SCHEME)) {
|
||||
$addr_parts = explode('@', $url);
|
||||
|
@ -476,7 +477,7 @@ class Contact
|
|||
*
|
||||
* @return boolean Is it the same server?
|
||||
*/
|
||||
public static function isLocalById(int $cid)
|
||||
public static function isLocalById(int $cid): bool
|
||||
{
|
||||
$contact = DBA::selectFirst('contact', ['url', 'baseurl'], ['id' => $cid]);
|
||||
if (!DBA::isResult($contact)) {
|
||||
|
@ -500,7 +501,7 @@ class Contact
|
|||
* @return integer|boolean Public contact id for given user id
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function getPublicIdByUserId($uid)
|
||||
public static function getPublicIdByUserId(int $uid)
|
||||
{
|
||||
$self = DBA::selectFirst('contact', ['url'], ['self' => true, 'uid' => $uid]);
|
||||
if (!DBA::isResult($self)) {
|
||||
|
@ -519,7 +520,7 @@ class Contact
|
|||
* @throws HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function getPublicAndUserContactID($cid, $uid)
|
||||
public static function getPublicAndUserContactID(int $cid, int $uid): array
|
||||
{
|
||||
// We have to use the legacy function as long as the post update hasn't finished
|
||||
if (DI::config()->get('system', 'post_update_version') < 1427) {
|
||||
|
@ -560,7 +561,7 @@ class Contact
|
|||
* @throws HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
private static function legacyGetPublicAndUserContactID($cid, $uid)
|
||||
private static function legacyGetPublicAndUserContactID(int $cid, int $uid): array
|
||||
{
|
||||
if (empty($uid) || empty($cid)) {
|
||||
return [];
|
||||
|
@ -1526,7 +1527,7 @@ class Contact
|
|||
* @param int $type type of contact or account
|
||||
* @return string
|
||||
*/
|
||||
public static function getAccountType(int $type)
|
||||
public static function getAccountType(int $type): string
|
||||
{
|
||||
switch ($type) {
|
||||
case self::TYPE_ORGANISATION:
|
||||
|
@ -1552,11 +1553,11 @@ class Contact
|
|||
/**
|
||||
* Blocks a contact
|
||||
*
|
||||
* @param int $cid
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
* @param int $cid Contact id to block
|
||||
* @param string $reason Block reason
|
||||
* @return bool Whether it was successful
|
||||
*/
|
||||
public static function block($cid, $reason = null)
|
||||
public static function block(int $cid, string $reason = null): bool
|
||||
{
|
||||
$return = self::update(['blocked' => true, 'block_reason' => $reason], ['id' => $cid]);
|
||||
|
||||
|
@ -1566,11 +1567,10 @@ class Contact
|
|||
/**
|
||||
* Unblocks a contact
|
||||
*
|
||||
* @param int $cid
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
* @param int $cid Contact id to unblock
|
||||
* @return bool Whether it was successfull
|
||||
*/
|
||||
public static function unblock($cid)
|
||||
public static function unblock(int $cid): bool
|
||||
{
|
||||
$return = self::update(['blocked' => false, 'block_reason' => null], ['id' => $cid]);
|
||||
|
||||
|
@ -1580,7 +1580,7 @@ class Contact
|
|||
/**
|
||||
* Ensure that cached avatar exist
|
||||
*
|
||||
* @param integer $cid
|
||||
* @param integer $cid Contact id
|
||||
*/
|
||||
public static function checkAvatarCache(int $cid)
|
||||
{
|
||||
|
@ -1620,7 +1620,7 @@ class Contact
|
|||
* @param bool $no_update Don't perfom an update if no cached avatar was found
|
||||
* @return string photo path
|
||||
*/
|
||||
private static function getAvatarPath(array $contact, string $size, $no_update = false)
|
||||
private static function getAvatarPath(array $contact, string $size, bool $no_update = false): string
|
||||
{
|
||||
$contact = self::checkAvatarCacheByArray($contact, $no_update);
|
||||
|
||||
|
@ -1654,7 +1654,7 @@ class Contact
|
|||
* @param bool $no_update Don't perfom an update if no cached avatar was found
|
||||
* @return string photo path
|
||||
*/
|
||||
public static function getPhoto(array $contact, bool $no_update = false)
|
||||
public static function getPhoto(array $contact, bool $no_update = false): string
|
||||
{
|
||||
return self::getAvatarPath($contact, Proxy::SIZE_SMALL, $no_update);
|
||||
}
|
||||
|
@ -1666,7 +1666,7 @@ class Contact
|
|||
* @param bool $no_update Don't perfom an update if no cached avatar was found
|
||||
* @return string photo path
|
||||
*/
|
||||
public static function getThumb(array $contact, bool $no_update = false)
|
||||
public static function getThumb(array $contact, bool $no_update = false): string
|
||||
{
|
||||
return self::getAvatarPath($contact, Proxy::SIZE_THUMB, $no_update);
|
||||
}
|
||||
|
@ -1678,7 +1678,7 @@ class Contact
|
|||
* @param bool $no_update Don't perfom an update if no cached avatar was found
|
||||
* @return string photo path
|
||||
*/
|
||||
public static function getMicro(array $contact, bool $no_update = false)
|
||||
public static function getMicro(array $contact, bool $no_update = false): string
|
||||
{
|
||||
return self::getAvatarPath($contact, Proxy::SIZE_MICRO, $no_update);
|
||||
}
|
||||
|
@ -1690,7 +1690,7 @@ class Contact
|
|||
* @param bool $no_update Don't perfom an update if no cached avatar was found
|
||||
* @return array contact array with avatar cache fields
|
||||
*/
|
||||
private static function checkAvatarCacheByArray(array $contact, bool $no_update = false)
|
||||
private static function checkAvatarCacheByArray(array $contact, bool $no_update = false): array
|
||||
{
|
||||
$update = false;
|
||||
$contact_fields = [];
|
||||
|
@ -1796,7 +1796,7 @@ class Contact
|
|||
* @param string $size Size of the avatar picture
|
||||
* @return string avatar URL
|
||||
*/
|
||||
public static function getDefaultAvatar(array $contact, string $size)
|
||||
public static function getDefaultAvatar(array $contact, string $size): string
|
||||
{
|
||||
switch ($size) {
|
||||
case Proxy::SIZE_MICRO:
|
||||
|
@ -2614,7 +2614,7 @@ class Contact
|
|||
* @throws HTTPException\NotFoundException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function createFromProbeForUser(int $uid, $url, $network = '')
|
||||
public static function createFromProbeForUser(int $uid, string $url, string $network = ''): array
|
||||
{
|
||||
$result = ['cid' => -1, 'success' => false, 'message' => ''];
|
||||
|
||||
|
@ -2803,7 +2803,7 @@ class Contact
|
|||
* @throws HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function addRelationship(array $importer, array $contact, array $datarray, $sharing = false, $note = '')
|
||||
public static function addRelationship(array $importer, array $contact, array $datarray, bool $sharing = false, string $note = '')
|
||||
{
|
||||
// Should always be set
|
||||
if (empty($datarray['author-id'])) {
|
||||
|
@ -3030,7 +3030,7 @@ class Contact
|
|||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function pruneUnavailable(array $contact_ids)
|
||||
public static function pruneUnavailable(array $contact_ids): array
|
||||
{
|
||||
if (empty($contact_ids)) {
|
||||
return [];
|
||||
|
@ -3058,7 +3058,7 @@ class Contact
|
|||
* @throws HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function magicLink($contact_url, $url = '')
|
||||
public static function magicLink(string $contact_url, string $url = ''): string
|
||||
{
|
||||
if (!Session::isAuthenticated()) {
|
||||
return $url ?: $contact_url; // Equivalent to: ($url != '') ? $url : $contact_url;
|
||||
|
@ -3085,7 +3085,7 @@ class Contact
|
|||
* @throws HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function magicLinkById($cid, $url = '')
|
||||
public static function magicLinkById(int $cid, string $url = ''): string
|
||||
{
|
||||
$contact = DBA::selectFirst('contact', ['id', 'network', 'url', 'uid'], ['id' => $cid]);
|
||||
|
||||
|
@ -3102,7 +3102,7 @@ class Contact
|
|||
* @throws HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function magicLinkByContact($contact, $url = '')
|
||||
public static function magicLinkByContact(array $contact, string $url = ''): string
|
||||
{
|
||||
$destination = $url ?: $contact['url']; // Equivalent to ($url != '') ? $url : $contact['url'];
|
||||
|
||||
|
@ -3143,7 +3143,7 @@ class Contact
|
|||
*
|
||||
* @return boolean "true" if it is a forum
|
||||
*/
|
||||
public static function isForum($contactid)
|
||||
public static function isForum(int $contactid): bool
|
||||
{
|
||||
$fields = ['contact-type'];
|
||||
$condition = ['id' => $contactid];
|
||||
|
@ -3162,7 +3162,7 @@ class Contact
|
|||
* @param array $contact
|
||||
* @return bool
|
||||
*/
|
||||
public static function canReceivePrivateMessages(array $contact)
|
||||
public static function canReceivePrivateMessages(array $contact): bool
|
||||
{
|
||||
$protocol = $contact['network'] ?? $contact['protocol'] ?? Protocol::PHANTOM;
|
||||
$self = $contact['self'] ?? false;
|
||||
|
@ -3180,7 +3180,7 @@ class Contact
|
|||
* @return array with search results
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function searchByName(string $search, string $mode = '', int $uid = 0)
|
||||
public static function searchByName(string $search, string $mode = '', int $uid = 0): array
|
||||
{
|
||||
if (empty($search)) {
|
||||
return [];
|
||||
|
@ -3223,7 +3223,7 @@ class Contact
|
|||
* @param array $urls
|
||||
* @return array result "count", "added" and "updated"
|
||||
*/
|
||||
public static function addByUrls(array $urls)
|
||||
public static function addByUrls(array $urls): array
|
||||
{
|
||||
$added = 0;
|
||||
$updated = 0;
|
||||
|
@ -3256,7 +3256,7 @@ class Contact
|
|||
* @return array The profile array
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getRandomContact()
|
||||
public static function getRandomContact(): array
|
||||
{
|
||||
$contact = DBA::selectFirst('contact', ['id', 'network', 'url', 'uid'], [
|
||||
"`uid` = ? AND `network` = ? AND NOT `failed` AND `last-item` > ?",
|
||||
|
|
|
@ -62,7 +62,7 @@ class Conversation
|
|||
*/
|
||||
const RELAY = 3;
|
||||
|
||||
public static function getByItemUri($item_uri)
|
||||
public static function getByItemUri(string $item_uri)
|
||||
{
|
||||
return DBA::selectFirst('conversation', [], ['item-uri' => $item_uri]);
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ class Conversation
|
|||
* @return array Item array with removed conversation data
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function insert(array $arr)
|
||||
public static function insert(array $arr): array
|
||||
{
|
||||
if (in_array(($arr['network'] ?? '') ?: Protocol::PHANTOM,
|
||||
[Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, Protocol::TWITTER]) && !empty($arr['uri'])) {
|
||||
|
|
|
@ -41,7 +41,7 @@ use Friendica\Util\XML;
|
|||
class Event
|
||||
{
|
||||
|
||||
public static function getHTML(array $event, $simple = false, $uriid = 0)
|
||||
public static function getHTML(array $event, bool $simple = false, int $uriid = 0): string
|
||||
{
|
||||
if (empty($event)) {
|
||||
return '';
|
||||
|
@ -127,7 +127,7 @@ class Event
|
|||
* @param array $event Array which contains the event data.
|
||||
* @return string The event as a bbcode formatted string.
|
||||
*/
|
||||
private static function getBBCode(array $event)
|
||||
private static function getBBCode(array $event): string
|
||||
{
|
||||
$o = '';
|
||||
|
||||
|
@ -157,11 +157,10 @@ class Event
|
|||
/**
|
||||
* Extract bbcode formatted event data from a string.
|
||||
*
|
||||
* @params: string $s The string which should be parsed for event data.
|
||||
* @param $text
|
||||
* @param string $text The string which should be parsed for event data.
|
||||
* @return array The array with the event information.
|
||||
*/
|
||||
public static function fromBBCode($text)
|
||||
public static function fromBBCode(string $text): array
|
||||
{
|
||||
$ev = [];
|
||||
|
||||
|
@ -195,13 +194,13 @@ class Event
|
|||
return $ev;
|
||||
}
|
||||
|
||||
public static function sortByDate($event_list)
|
||||
public static function sortByDate(array $event_list): array
|
||||
{
|
||||
usort($event_list, ['self', 'compareDatesCallback']);
|
||||
return $event_list;
|
||||
}
|
||||
|
||||
private static function compareDatesCallback($event_a, $event_b)
|
||||
private static function compareDatesCallback(array $event_a, array $event_b)
|
||||
{
|
||||
$date_a = DateTimeFormat::local($event_a['start']);
|
||||
$date_b = DateTimeFormat::local($event_b['start']);
|
||||
|
@ -223,7 +222,7 @@ class Event
|
|||
* @return void
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function delete($event_id)
|
||||
public static function delete(int $event_id)
|
||||
{
|
||||
if ($event_id == 0) {
|
||||
return;
|
||||
|
@ -242,7 +241,7 @@ class Event
|
|||
* @return int The new event id.
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function store($arr)
|
||||
public static function store(array $arr): int
|
||||
{
|
||||
$event = [];
|
||||
$event['id'] = intval($arr['id'] ?? 0);
|
||||
|
@ -317,7 +316,7 @@ class Event
|
|||
return $event['id'];
|
||||
}
|
||||
|
||||
public static function getItemArrayForId(int $event_id, array $item = []):array
|
||||
public static function getItemArrayForId(int $event_id, array $item = []): array
|
||||
{
|
||||
if (empty($event_id)) {
|
||||
return $item;
|
||||
|
@ -374,7 +373,7 @@ class Event
|
|||
return $item;
|
||||
}
|
||||
|
||||
public static function getItemArrayForImportedId(int $event_id, array $item = []):array
|
||||
public static function getItemArrayForImportedId(int $event_id, array $item = []): array
|
||||
{
|
||||
if (empty($event_id)) {
|
||||
return $item;
|
||||
|
@ -404,7 +403,7 @@ class Event
|
|||
* @return array Array with translations strings.
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function getStrings()
|
||||
public static function getStrings(): array
|
||||
{
|
||||
// First day of the week (0 = Sunday).
|
||||
$firstDay = DI::pConfig()->get(local_user(), 'system', 'first_day_of_week', 0);
|
||||
|
@ -477,7 +476,7 @@ class Event
|
|||
*
|
||||
* @todo We should replace this with a separate update function if there is some time left.
|
||||
*/
|
||||
private static function removeDuplicates(array $dates)
|
||||
private static function removeDuplicates(array $dates): array
|
||||
{
|
||||
$dates2 = [];
|
||||
|
||||
|
@ -500,7 +499,7 @@ class Event
|
|||
* @return array Query result
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function getListById($owner_uid, $event_id, $sql_extra = '')
|
||||
public static function getListById(int $owner_uid, int $event_id, string $sql_extra = ''): array
|
||||
{
|
||||
$return = [];
|
||||
|
||||
|
@ -536,7 +535,7 @@ class Event
|
|||
* @return array Query results.
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function getListByDate($owner_uid, $event_params, $sql_extra = '')
|
||||
public static function getListByDate(int $owner_uid, array $event_params, string $sql_extra = ''): array
|
||||
{
|
||||
$return = [];
|
||||
|
||||
|
@ -570,7 +569,7 @@ class Event
|
|||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function prepareListForTemplate(array $event_result)
|
||||
public static function prepareListForTemplate(array $event_result): array
|
||||
{
|
||||
$event_list = [];
|
||||
|
||||
|
@ -651,12 +650,12 @@ class Event
|
|||
* @param array $events Query result for events.
|
||||
* @param string $format The output format (ical/csv).
|
||||
*
|
||||
* @param $timezone
|
||||
* @param string $timezone Timezone (missing parameter!)
|
||||
* @return string Content according to selected export format.
|
||||
*
|
||||
* @todo Implement timezone support
|
||||
*/
|
||||
private static function formatListForExport(array $events, $format)
|
||||
private static function formatListForExport(array $events, string $format): string
|
||||
{
|
||||
$o = '';
|
||||
|
||||
|
@ -757,7 +756,7 @@ class Event
|
|||
* @return array Query results.
|
||||
* @throws \Exception
|
||||
*/
|
||||
private static function getListByUserId($uid = 0)
|
||||
private static function getListByUserId(int $uid = 0): array
|
||||
{
|
||||
$return = [];
|
||||
|
||||
|
@ -797,7 +796,7 @@ class Event
|
|||
* @throws \Exception
|
||||
* @todo Respect authenticated users with events_by_uid().
|
||||
*/
|
||||
public static function exportListByUserId($uid, $format = 'ical')
|
||||
public static function exportListByUserId(int $uid, string $format = 'ical'): array
|
||||
{
|
||||
$process = false;
|
||||
|
||||
|
@ -845,7 +844,8 @@ class Event
|
|||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function getItemHTML(array $item) {
|
||||
public static function getItemHTML(array $item): string
|
||||
{
|
||||
$same_date = false;
|
||||
$finish = false;
|
||||
|
||||
|
@ -933,10 +933,11 @@ class Event
|
|||
* @return array The array with the location data.
|
||||
* 'name' => The name of the location,<br>
|
||||
* 'address' => The address of the location,<br>
|
||||
* 'coordinates' => Latitude and longitude (e.g. '48.864716,2.349014').<br>
|
||||
* 'coordinates' => Latitude and longitude (e.g. '48.864716,2.349014').<br>
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
private static function locationToArray($s = '') {
|
||||
private static function locationToArray(string $s = ''): array
|
||||
{
|
||||
if ($s == '') {
|
||||
return [];
|
||||
}
|
||||
|
@ -981,7 +982,7 @@ class Event
|
|||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function createBirthday($contact, $birthday)
|
||||
public static function createBirthday(array $contact, string $birthday): bool
|
||||
{
|
||||
// Check for duplicates
|
||||
$condition = [
|
||||
|
@ -1011,8 +1012,7 @@ class Event
|
|||
'type' => 'birthday',
|
||||
];
|
||||
|
||||
self::store($values);
|
||||
|
||||
return true;
|
||||
// Check if self::store() was success
|
||||
return (self::store($values) > 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ class FContact
|
|||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function getByURL($handle, $update = null)
|
||||
public static function getByURL(string $handle, $update = null): array
|
||||
{
|
||||
$person = DBA::selectFirst('fcontact', [], ['network' => Protocol::DIASPORA, 'addr' => $handle]);
|
||||
if (!DBA::isResult($person)) {
|
||||
|
@ -90,7 +90,7 @@ class FContact
|
|||
* @param array $arr The fcontact data
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function updateFromProbeArray($arr)
|
||||
public static function updateFromProbeArray(array $arr)
|
||||
{
|
||||
$uriid = ItemURI::insert(['uri' => $arr['url'], 'guid' => $arr['guid']]);
|
||||
|
||||
|
@ -122,12 +122,12 @@ class FContact
|
|||
* get a url (scheme://domain.tld/u/user) from a given Diaspora*
|
||||
* fcontact guid
|
||||
*
|
||||
* @param mixed $fcontact_guid Hexadecimal string guid
|
||||
* @param string $fcontact_guid Hexadecimal string guid
|
||||
*
|
||||
* @return string the contact url or null
|
||||
* @return string|null the contact url or null
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function getUrlByGuid($fcontact_guid)
|
||||
public static function getUrlByGuid(string $fcontact_guid)
|
||||
{
|
||||
Logger::info('fcontact', ['guid' => $fcontact_guid]);
|
||||
|
||||
|
|
|
@ -2054,7 +2054,7 @@ class GServer
|
|||
* @return int
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getProtocol(int $gsid)
|
||||
public static function getProtocol(int $gsid): int
|
||||
{
|
||||
if (empty($gsid)) {
|
||||
return null;
|
||||
|
|
|
@ -60,7 +60,7 @@ class ParsedLogIterator implements \Iterator
|
|||
* @param string $filename File to open
|
||||
* @return $this
|
||||
*/
|
||||
public function open(string $filename)
|
||||
public function open(string $filename): ParsedLogIterator
|
||||
{
|
||||
$this->reader->open($filename);
|
||||
return $this;
|
||||
|
@ -70,7 +70,7 @@ class ParsedLogIterator implements \Iterator
|
|||
* @param int $limit Max num of lines to read
|
||||
* @return $this
|
||||
*/
|
||||
public function withLimit(int $limit)
|
||||
public function withLimit(int $limit): ParsedLogIterator
|
||||
{
|
||||
$this->limit = $limit;
|
||||
return $this;
|
||||
|
@ -80,7 +80,7 @@ class ParsedLogIterator implements \Iterator
|
|||
* @param array $filters filters per column
|
||||
* @return $this
|
||||
*/
|
||||
public function withFilters(array $filters)
|
||||
public function withFilters(array $filters): ParsedLogIterator
|
||||
{
|
||||
$this->filters = $filters;
|
||||
return $this;
|
||||
|
@ -90,7 +90,7 @@ class ParsedLogIterator implements \Iterator
|
|||
* @param string $search string to search to filter lines
|
||||
* @return $this
|
||||
*/
|
||||
public function withSearch(string $search)
|
||||
public function withSearch(string $search): ParsedLogIterator
|
||||
{
|
||||
$this->search = $search;
|
||||
return $this;
|
||||
|
@ -100,10 +100,10 @@ class ParsedLogIterator implements \Iterator
|
|||
* Check if parsed log line match filters.
|
||||
* Always match if no filters are set.
|
||||
*
|
||||
* @param ParsedLogLine $parsedlogline
|
||||
* @return bool
|
||||
* @param ParsedLogLine $parsedlogline ParsedLogLine instance
|
||||
* @return bool Wether the parse log line matches
|
||||
*/
|
||||
private function filter($parsedlogline)
|
||||
private function filter(ParsedLogLine $parsedlogline): bool
|
||||
{
|
||||
$match = true;
|
||||
foreach ($this->filters as $filter => $filtervalue) {
|
||||
|
@ -126,7 +126,7 @@ class ParsedLogIterator implements \Iterator
|
|||
* @param ParsedLogLine $parsedlogline
|
||||
* @return bool
|
||||
*/
|
||||
private function search($parsedlogline)
|
||||
private function search(ParsedLogLine $parsedlogline): bool
|
||||
{
|
||||
if ($this->search != "") {
|
||||
return strstr($parsedlogline->logline, $this->search) !== false;
|
||||
|
|
|
@ -110,7 +110,7 @@ class Photo
|
|||
* @throws \Exception
|
||||
* @see \Friendica\Database\DBA::select
|
||||
*/
|
||||
public static function getPhotosForUser($uid, $resourceid, array $conditions = [], array $params = [])
|
||||
public static function getPhotosForUser(int $uid, string $resourceid, array $conditions = [], array $params = [])
|
||||
{
|
||||
$conditions["resource-id"] = $resourceid;
|
||||
$conditions["uid"] = $uid;
|
||||
|
|
|
@ -237,7 +237,7 @@ class Profile
|
|||
|
||||
if (!local_user()) {
|
||||
$a->setCurrentTheme($profile['theme']);
|
||||
$a->setCurrentMobileTheme(DI::pConfig()->get($a->getProfileOwner(), 'system', 'mobile_theme'));
|
||||
$a->setCurrentMobileTheme(DI::pConfig()->get($a->getProfileOwner(), 'system', 'mobile_theme') ?? '');
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -134,7 +134,7 @@ class User
|
|||
*
|
||||
* @return array system account
|
||||
*/
|
||||
public static function getSystemAccount()
|
||||
public static function getSystemAccount(): array
|
||||
{
|
||||
$system = Contact::selectFirst([], ['self' => true, 'uid' => 0]);
|
||||
if (!DBA::isResult($system)) {
|
||||
|
@ -244,7 +244,7 @@ class User
|
|||
*
|
||||
* @return string actor account name
|
||||
*/
|
||||
public static function getActorName()
|
||||
public static function getActorName(): string
|
||||
{
|
||||
$system_actor_name = DI::config()->get('system', 'actor_name');
|
||||
if (!empty($system_actor_name)) {
|
||||
|
@ -278,7 +278,7 @@ class User
|
|||
* @return boolean
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function exists($uid)
|
||||
public static function exists(int $uid): bool
|
||||
{
|
||||
return DBA::exists('user', ['uid' => $uid]);
|
||||
}
|
||||
|
@ -289,7 +289,7 @@ class User
|
|||
* @return array|boolean User record if it exists, false otherwise
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getById($uid, array $fields = [])
|
||||
public static function getById(int $uid, array $fields = [])
|
||||
{
|
||||
return !empty($uid) ? DBA::selectFirst('user', $fields, ['uid' => $uid]) : [];
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ class User
|
|||
* @return array|boolean User record if it exists, false otherwise
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getByNickname($nickname, array $fields = [])
|
||||
public static function getByNickname(string $nickname, array $fields = [])
|
||||
{
|
||||
return DBA::selectFirst('user', $fields, ['nickname' => $nickname]);
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ class User
|
|||
* @return integer user id
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getIdForURL(string $url)
|
||||
public static function getIdForURL(string $url): int
|
||||
{
|
||||
// Avoid database queries when the local node hostname isn't even part of the url.
|
||||
if (!Contact::isLocal($url)) {
|
||||
|
@ -380,7 +380,7 @@ class User
|
|||
* @param array $fields
|
||||
* @return array user
|
||||
*/
|
||||
public static function getFirstAdmin(array $fields = [])
|
||||
public static function getFirstAdmin(array $fields = []) : array
|
||||
{
|
||||
if (!empty(DI::config()->get('config', 'admin_nickname'))) {
|
||||
return self::getByNickname(DI::config()->get('config', 'admin_nickname'), $fields);
|
||||
|
@ -469,7 +469,7 @@ class User
|
|||
* @return boolean|array
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getOwnerDataByNick($nick)
|
||||
public static function getOwnerDataByNick(string $nick)
|
||||
{
|
||||
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $nick]);
|
||||
|
||||
|
@ -488,7 +488,7 @@ class User
|
|||
* @return int group id
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getDefaultGroup($uid)
|
||||
public static function getDefaultGroup(int $uid): int
|
||||
{
|
||||
$user = DBA::selectFirst('user', ['def_gid'], ['uid' => $uid]);
|
||||
if (DBA::isResult($user)) {
|
||||
|
@ -512,7 +512,7 @@ class User
|
|||
* @throws HTTPException\ForbiddenException
|
||||
* @throws HTTPException\NotFoundException
|
||||
*/
|
||||
public static function getIdFromPasswordAuthentication($user_info, $password, $third_party = false)
|
||||
public static function getIdFromPasswordAuthentication($user_info, string $password, bool $third_party = false)
|
||||
{
|
||||
// Addons registered with the "authenticate" hook may create the user on the
|
||||
// fly. `getAuthenticationInfo` will fail if the user doesn't exist yet. If
|
||||
|
@ -580,7 +580,7 @@ class User
|
|||
* @return int User Id if authentication is successful
|
||||
* @throws HTTPException\ForbiddenException
|
||||
*/
|
||||
public static function getIdFromAuthenticateHooks($username, $password)
|
||||
public static function getIdFromAuthenticateHooks(string $username, string $password): int
|
||||
{
|
||||
$addon_auth = [
|
||||
'username' => $username,
|
||||
|
@ -613,7 +613,7 @@ class User
|
|||
* - User array with at least the uid and the hashed password
|
||||
*
|
||||
* @param mixed $user_info
|
||||
* @return array
|
||||
* @return array|null Null if not found/determined
|
||||
* @throws HTTPException\NotFoundException
|
||||
*/
|
||||
public static function getAuthenticationInfo($user_info)
|
||||
|
@ -671,7 +671,7 @@ class User
|
|||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function generateNewPassword()
|
||||
public static function generateNewPassword(): string
|
||||
{
|
||||
return ucfirst(Strings::getRandomName(8)) . random_int(1000, 9999);
|
||||
}
|
||||
|
@ -683,7 +683,7 @@ class User
|
|||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function isPasswordExposed($password)
|
||||
public static function isPasswordExposed(string $password): bool
|
||||
{
|
||||
$cache = new CacheItemPool();
|
||||
$cache->changeConfig([
|
||||
|
@ -712,7 +712,7 @@ class User
|
|||
* @param string $password
|
||||
* @return string
|
||||
*/
|
||||
private static function hashPasswordLegacy($password)
|
||||
private static function hashPasswordLegacy(string $password): string
|
||||
{
|
||||
return hash('whirlpool', $password);
|
||||
}
|
||||
|
@ -724,7 +724,7 @@ class User
|
|||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function hashPassword($password)
|
||||
public static function hashPassword(string $password): string
|
||||
{
|
||||
if (!trim($password)) {
|
||||
throw new Exception(DI::l10n()->t('Password can\'t be empty'));
|
||||
|
@ -741,7 +741,7 @@ class User
|
|||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function updatePassword($uid, $password)
|
||||
public static function updatePassword(int $uid, string $password): bool
|
||||
{
|
||||
$password = trim($password);
|
||||
|
||||
|
@ -771,7 +771,7 @@ class User
|
|||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
private static function updatePasswordHashed($uid, $pasword_hashed)
|
||||
private static function updatePasswordHashed(int $uid, string $pasword_hashed): bool
|
||||
{
|
||||
$fields = [
|
||||
'password' => $pasword_hashed,
|
||||
|
@ -792,7 +792,7 @@ class User
|
|||
* @param string $nickname The nickname that should be checked
|
||||
* @return boolean True is the nickname is blocked on the node
|
||||
*/
|
||||
public static function isNicknameBlocked($nickname)
|
||||
public static function isNicknameBlocked(string $nickname): bool
|
||||
{
|
||||
$forbidden_nicknames = DI::config()->get('system', 'forbidden_nicknames', '');
|
||||
if (!empty($forbidden_nicknames)) {
|
||||
|
@ -829,7 +829,7 @@ class User
|
|||
* @return string avatar link
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getAvatarUrl(array $user, string $size = ''):string
|
||||
public static function getAvatarUrl(array $user, string $size = ''): string
|
||||
{
|
||||
if (empty($user['nickname'])) {
|
||||
DI::logger()->warning('Missing user nickname key', ['trace' => System::callstack(20)]);
|
||||
|
@ -871,7 +871,7 @@ class User
|
|||
* @return string banner link
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getBannerUrl(array $user):string
|
||||
public static function getBannerUrl(array $user): string
|
||||
{
|
||||
if (empty($user['nickname'])) {
|
||||
DI::logger()->warning('Missing user nickname key', ['trace' => System::callstack(20)]);
|
||||
|
@ -913,7 +913,7 @@ class User
|
|||
* @throws ImagickException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function create(array $data)
|
||||
public static function create(array $data): array
|
||||
{
|
||||
$return = ['user' => null, 'password' => ''];
|
||||
|
||||
|
@ -1255,7 +1255,7 @@ class User
|
|||
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function block(int $uid, bool $block = true)
|
||||
public static function block(int $uid, bool $block = true): bool
|
||||
{
|
||||
return DBA::update('user', ['blocked' => $block], ['uid' => $uid]);
|
||||
}
|
||||
|
@ -1270,7 +1270,7 @@ class User
|
|||
* @throws HTTPException\InternalServerErrorException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function allow(string $hash)
|
||||
public static function allow(string $hash): bool
|
||||
{
|
||||
$register = Register::getByHash($hash);
|
||||
if (!DBA::isResult($register)) {
|
||||
|
@ -1316,7 +1316,7 @@ class User
|
|||
* @return bool True, if the deny was successfull
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function deny(string $hash)
|
||||
public static function deny(string $hash): bool
|
||||
{
|
||||
$register = Register::getByHash($hash);
|
||||
if (!DBA::isResult($register)) {
|
||||
|
@ -1348,7 +1348,7 @@ class User
|
|||
* @throws ErrorException
|
||||
* @throws ImagickException
|
||||
*/
|
||||
public static function createMinimal(string $name, string $email, string $nick, string $lang = L10n::DEFAULT)
|
||||
public static function createMinimal(string $name, string $email, string $nick, string $lang = L10n::DEFAULT): bool
|
||||
{
|
||||
if (empty($name) ||
|
||||
empty($email) ||
|
||||
|
@ -1418,7 +1418,7 @@ class User
|
|||
* @return NULL|boolean from notification() and email() inherited
|
||||
* @throws HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function sendRegisterPendingEmail($user, $sitename, $siteurl, $password)
|
||||
public static function sendRegisterPendingEmail(array $user, string $sitename, string $siteurl, string $password)
|
||||
{
|
||||
$body = Strings::deindent(DI::l10n()->t(
|
||||
'
|
||||
|
@ -1461,7 +1461,7 @@ class User
|
|||
* @return NULL|boolean from notification() and email() inherited
|
||||
* @throws HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function sendRegisterOpenEmail(L10n $l10n, $user, $sitename, $siteurl, $password)
|
||||
public static function sendRegisterOpenEmail(L10n $l10n, array $user, string $sitename, string $siteurl, string $password)
|
||||
{
|
||||
$preamble = Strings::deindent($l10n->t(
|
||||
'
|
||||
|
@ -1520,7 +1520,7 @@ class User
|
|||
* @return bool
|
||||
* @throws HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function remove(int $uid)
|
||||
public static function remove(int $uid): bool
|
||||
{
|
||||
if (empty($uid)) {
|
||||
return false;
|
||||
|
@ -1574,7 +1574,7 @@ class User
|
|||
* ]
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function identities($uid)
|
||||
public static function identities(int $uid): array
|
||||
{
|
||||
if (empty($uid)) {
|
||||
return [];
|
||||
|
@ -1646,7 +1646,7 @@ class User
|
|||
* @param int $uid
|
||||
* @return bool
|
||||
*/
|
||||
public static function hasIdentities(int $uid):bool
|
||||
public static function hasIdentities(int $uid): bool
|
||||
{
|
||||
if (empty($uid)) {
|
||||
return false;
|
||||
|
@ -1679,7 +1679,7 @@ class User
|
|||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getStatistics()
|
||||
public static function getStatistics(): array
|
||||
{
|
||||
$statistics = [
|
||||
'total_users' => 0,
|
||||
|
@ -1732,10 +1732,10 @@ class User
|
|||
* @param string $order Order of the user list (Default is 'contact.name')
|
||||
* @param bool $descending Order direction (Default is ascending)
|
||||
*
|
||||
* @return array The list of the users
|
||||
* @return array|bool The list of the users
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getList($start = 0, $count = Pager::ITEMS_PER_PAGE, $type = 'all', $order = 'name', bool $descending = false)
|
||||
public static function getList(int $start = 0, int $count = Pager::ITEMS_PER_PAGE, string $type = 'all', string $order = 'name', bool $descending = false)
|
||||
{
|
||||
$param = ['limit' => [$start, $count], 'order' => [$order => $descending]];
|
||||
$condition = [];
|
||||
|
|
|
@ -59,12 +59,13 @@ class Notify extends BaseModule
|
|||
}
|
||||
}
|
||||
|
||||
private static function dispatchPublic($postdata)
|
||||
private static function dispatchPublic(array $postdata)
|
||||
{
|
||||
$msg = Diaspora::decodeRaw($postdata, '', true);
|
||||
if (!$msg) {
|
||||
if (!is_array($msg)) {
|
||||
// We have to fail silently to be able to hand it over to the salmon parser
|
||||
return false;
|
||||
Logger::warning('Diaspora::decodeRaw() has failed for some reason.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Fetch the corresponding public contact
|
||||
|
@ -88,10 +89,10 @@ class Notify extends BaseModule
|
|||
System::xmlExit($ret, 'Done');
|
||||
}
|
||||
|
||||
private static function dispatchPrivate($user, $postdata)
|
||||
private static function dispatchPrivate(array $user, string $postdata)
|
||||
{
|
||||
$msg = Diaspora::decodeRaw($postdata, $user['prvkey'] ?? '');
|
||||
if (!$msg) {
|
||||
if (!is_array($msg)) {
|
||||
System::xmlExit(4, 'Unable to parse message');
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,6 @@ class Poll extends BaseModule
|
|||
protected function rawContent(array $request = [])
|
||||
{
|
||||
$last_update = $request['last_update'] ?? '';
|
||||
System::httpExit(OStatus::feed($this->parameters['nickname'], $last_update, 10), Response::TYPE_ATOM);
|
||||
System::httpExit(OStatus::feed($this->parameters['nickname'], $last_update, 10) ?? '', Response::TYPE_ATOM);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ class Directory extends BaseModule
|
|||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function formatEntry(array $contact, $photo_size = 'photo')
|
||||
public static function formatEntry(array $contact, string $photo_size = 'photo'): array
|
||||
{
|
||||
$itemurl = (($contact['addr'] != "") ? $contact['addr'] : $contact['url']);
|
||||
|
||||
|
@ -166,7 +166,7 @@ class Directory extends BaseModule
|
|||
'img_hover' => $contact['name'],
|
||||
'name' => $contact['name'],
|
||||
'details' => $details,
|
||||
'account_type' => Model\Contact::getAccountType($contact['contact-type']),
|
||||
'account_type' => Model\Contact::getAccountType($contact['contact-type'] ?? ''),
|
||||
'profile' => $profile,
|
||||
'location' => $location_e,
|
||||
'tags' => $contact['pub_keywords'],
|
||||
|
|
|
@ -1445,7 +1445,7 @@ class Probe
|
|||
* @return array|bool OStatus data or "false" on error or "true" on short mode
|
||||
* @throws HTTPException\InternalServerErrorException
|
||||
*/
|
||||
private static function ostatus($webfinger, $short = false)
|
||||
private static function ostatus(array $webfinger, bool $short = false)
|
||||
{
|
||||
$data = [];
|
||||
|
||||
|
|
|
@ -33,9 +33,9 @@ class ProfileFields extends BaseCollection
|
|||
|
||||
/**
|
||||
* @param callable $callback
|
||||
* @return ProfileFields
|
||||
* @return ProfileFields (as an extended form of BaseCollection)
|
||||
*/
|
||||
public function map(callable $callback): ProfileFields
|
||||
public function map(callable $callback): BaseCollection
|
||||
{
|
||||
return parent::map($callback);
|
||||
}
|
||||
|
@ -43,9 +43,9 @@ class ProfileFields extends BaseCollection
|
|||
/**
|
||||
* @param callable|null $callback
|
||||
* @param int $flag
|
||||
* @return ProfileFields
|
||||
* @return ProfileFields as an extended version of BaseCollection
|
||||
*/
|
||||
public function filter(callable $callback = null, int $flag = 0): ProfileFields
|
||||
public function filter(callable $callback = null, int $flag = 0): BaseCollection
|
||||
{
|
||||
return parent::filter($callback, $flag);
|
||||
}
|
||||
|
|
|
@ -212,7 +212,7 @@ final class Activity
|
|||
*
|
||||
* @return bool True, if the activity is hidden
|
||||
*/
|
||||
public function isHidden(string $activity)
|
||||
public function isHidden(string $activity): bool
|
||||
{
|
||||
foreach (self::HIDDEN_ACTIVITIES as $hiddenActivity) {
|
||||
if ($this->match($activity, $hiddenActivity)) {
|
||||
|
@ -231,7 +231,7 @@ final class Activity
|
|||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function match(string $haystack, string $needle)
|
||||
public function match(string $haystack, string $needle): bool
|
||||
{
|
||||
return (($haystack === $needle) ||
|
||||
((basename($needle) === $haystack) &&
|
||||
|
|
|
@ -104,12 +104,12 @@ class ActivityPub
|
|||
* @return array
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function fetchContent(string $url, int $uid = 0)
|
||||
public static function fetchContent(string $url, int $uid = 0): array
|
||||
{
|
||||
return HTTPSignature::fetch($url, $uid);
|
||||
}
|
||||
|
||||
private static function getAccountType($apcontact)
|
||||
private static function getAccountType(array $apcontact): int
|
||||
{
|
||||
$accounttype = -1;
|
||||
|
||||
|
@ -146,7 +146,7 @@ class ActivityPub
|
|||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function probeProfile($url, $update = true)
|
||||
public static function probeProfile(string $url, bool $update = true): array
|
||||
{
|
||||
$apcontact = APContact::getByURL($url, $update);
|
||||
if (empty($apcontact)) {
|
||||
|
@ -204,7 +204,7 @@ class ActivityPub
|
|||
* @param integer $uid User ID
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function fetchOutbox($url, $uid)
|
||||
public static function fetchOutbox(string $url, int $uid)
|
||||
{
|
||||
$data = self::fetchContent($url, $uid);
|
||||
if (empty($data)) {
|
||||
|
@ -235,7 +235,7 @@ class ActivityPub
|
|||
* @param integer $uid Optional user id
|
||||
* @return array Endpoint items
|
||||
*/
|
||||
public static function fetchItems(string $url, int $uid = 0)
|
||||
public static function fetchItems(string $url, int $uid = 0): array
|
||||
{
|
||||
$data = self::fetchContent($url, $uid);
|
||||
if (empty($data)) {
|
||||
|
@ -268,7 +268,7 @@ class ActivityPub
|
|||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function isSupportedByContactUrl($url, $update = null)
|
||||
public static function isSupportedByContactUrl(string $url, $update = null)
|
||||
{
|
||||
return !empty(APContact::getByURL($url, $update));
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ class Processor
|
|||
*
|
||||
* @return string with replaced emojis
|
||||
*/
|
||||
private static function replaceEmojis(int $uri_id, string $body, array $emojis)
|
||||
private static function replaceEmojis(int $uri_id, string $body, array $emojis): string
|
||||
{
|
||||
$body = strtr($body,
|
||||
array_combine(
|
||||
|
@ -690,7 +690,7 @@ class Processor
|
|||
* @param string $url message URL
|
||||
* @return string with GUID
|
||||
*/
|
||||
private static function getGUIDByURL(string $url)
|
||||
private static function getGUIDByURL(string $url): string
|
||||
{
|
||||
$parsed = parse_url($url);
|
||||
|
||||
|
@ -711,7 +711,7 @@ class Processor
|
|||
* @param array $item
|
||||
* @return boolean Is the message wanted?
|
||||
*/
|
||||
private static function isSolicitedMessage(array $activity, array $item)
|
||||
private static function isSolicitedMessage(array $activity, array $item): bool
|
||||
{
|
||||
// The checks are split to improve the support when searching why a message was accepted.
|
||||
if (count($activity['receiver']) != 1) {
|
||||
|
@ -972,7 +972,7 @@ class Processor
|
|||
* @return int|bool New mail table row id or false on error
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
private static function postMail($activity, $item)
|
||||
private static function postMail(array $activity, array $item)
|
||||
{
|
||||
if (($item['gravity'] != 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']]);
|
||||
|
@ -1113,7 +1113,7 @@ class Processor
|
|||
* @return string fetched message URL
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function fetchMissingActivity(string $url, array $child = [], string $relay_actor = '', int $completion = Receiver::COMPLETION_MANUAL)
|
||||
public static function fetchMissingActivity(string $url, array $child = [], string $relay_actor = '', int $completion = Receiver::COMPLETION_MANUAL): string
|
||||
{
|
||||
if (!empty($child['receiver'])) {
|
||||
$uid = ActivityPub\Receiver::getFirstUserFromReceivers($child['receiver']);
|
||||
|
@ -1208,7 +1208,7 @@ class Processor
|
|||
* @param string $id object ID
|
||||
* @return boolean true if message is accepted
|
||||
*/
|
||||
private static function acceptIncomingMessage(array $activity, string $id)
|
||||
private static function acceptIncomingMessage(array $activity, string $id): bool
|
||||
{
|
||||
if (empty($activity['as:object'])) {
|
||||
Logger::info('No object field in activity - accepted', ['id' => $id]);
|
||||
|
@ -1248,7 +1248,7 @@ class Processor
|
|||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function followUser($activity)
|
||||
public static function followUser(array $activity)
|
||||
{
|
||||
$uid = User::getIdForURL($activity['object_id']);
|
||||
if (empty($uid)) {
|
||||
|
@ -1326,7 +1326,7 @@ class Processor
|
|||
* @param array $activity
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function updatePerson($activity)
|
||||
public static function updatePerson(array $activity)
|
||||
{
|
||||
if (empty($activity['object_id'])) {
|
||||
return;
|
||||
|
@ -1342,7 +1342,7 @@ class Processor
|
|||
* @param array $activity
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function deletePerson($activity)
|
||||
public static function deletePerson(array $activity)
|
||||
{
|
||||
if (empty($activity['object_id']) || empty($activity['actor'])) {
|
||||
Logger::info('Empty object id or actor.');
|
||||
|
@ -1369,7 +1369,7 @@ class Processor
|
|||
* @param array $activity
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function blockAccount($activity)
|
||||
public static function blockAccount(array $activity)
|
||||
{
|
||||
$cid = Contact::getIdForURL($activity['actor']);
|
||||
if (empty($cid)) {
|
||||
|
@ -1392,7 +1392,7 @@ class Processor
|
|||
* @param array $activity
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function unblockAccount($activity)
|
||||
public static function unblockAccount(array $activity)
|
||||
{
|
||||
$cid = Contact::getIdForURL($activity['actor']);
|
||||
if (empty($cid)) {
|
||||
|
@ -1416,7 +1416,7 @@ class Processor
|
|||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function acceptFollowUser($activity)
|
||||
public static function acceptFollowUser(array $activity)
|
||||
{
|
||||
$uid = User::getIdForURL($activity['object_actor']);
|
||||
if (empty($uid)) {
|
||||
|
@ -1450,7 +1450,7 @@ class Processor
|
|||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function rejectFollowUser($activity)
|
||||
public static function rejectFollowUser(array $activity)
|
||||
{
|
||||
$uid = User::getIdForURL($activity['object_actor']);
|
||||
if (empty($uid)) {
|
||||
|
@ -1483,7 +1483,7 @@ class Processor
|
|||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function undoActivity($activity)
|
||||
public static function undoActivity(array $activity)
|
||||
{
|
||||
if (empty($activity['object_id'])) {
|
||||
return;
|
||||
|
@ -1508,7 +1508,7 @@ class Processor
|
|||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function undoFollowUser($activity)
|
||||
public static function undoFollowUser(array $activity)
|
||||
{
|
||||
$uid = User::getIdForURL($activity['object_object']);
|
||||
if (empty($uid)) {
|
||||
|
@ -1543,7 +1543,7 @@ class Processor
|
|||
* @param integer $cid Contact ID
|
||||
* @throws \Exception
|
||||
*/
|
||||
private static function switchContact($cid)
|
||||
private static function switchContact(int $cid)
|
||||
{
|
||||
$contact = DBA::selectFirst('contact', ['network', 'url'], ['id' => $cid]);
|
||||
if (!DBA::isResult($contact) || in_array($contact['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN]) || Contact::isLocal($contact['url'])) {
|
||||
|
@ -1563,7 +1563,7 @@ class Processor
|
|||
* @return array
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
private static function getImplicitMentionList(array $parent)
|
||||
private static function getImplicitMentionList(array $parent): array
|
||||
{
|
||||
$parent_terms = Tag::getByURIId($parent['uri-id'], [Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION]);
|
||||
|
||||
|
@ -1601,7 +1601,7 @@ class Processor
|
|||
* @param array $parent
|
||||
* @return string
|
||||
*/
|
||||
private static function removeImplicitMentionsFromBody(string $body, array $parent)
|
||||
private static function removeImplicitMentionsFromBody(string $body, array $parent): string
|
||||
{
|
||||
if (DI::config()->get('system', 'disable_implicit_mentions')) {
|
||||
return $body;
|
||||
|
|
|
@ -84,8 +84,9 @@ class Receiver
|
|||
* @param $header
|
||||
* @param integer $uid User ID
|
||||
* @throws \Exception
|
||||
* @todo Find type for $body/$header
|
||||
*/
|
||||
public static function processInbox($body, $header, $uid)
|
||||
public static function processInbox($body, $header, int $uid)
|
||||
{
|
||||
$activity = json_decode($body, true);
|
||||
if (empty($activity)) {
|
||||
|
@ -220,11 +221,11 @@ class Receiver
|
|||
* @param string $object_id Object ID of the the provided object
|
||||
* @param integer $uid User ID
|
||||
*
|
||||
* @return string with object type
|
||||
* @return string with object type or NULL
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
private static function fetchObjectType($activity, $object_id, $uid = 0)
|
||||
private static function fetchObjectType(array $activity, string $object_id, int $uid = 0)
|
||||
{
|
||||
if (!empty($activity['as:object'])) {
|
||||
$object_type = JsonLD::fetchElement($activity['as:object'], '@type');
|
||||
|
@ -268,7 +269,7 @@ class Receiver
|
|||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function prepareObjectData($activity, $uid, $push, &$trust_source)
|
||||
public static function prepareObjectData(array $activity, int $uid, bool $push, bool &$trust_source): array
|
||||
{
|
||||
$id = JsonLD::fetchElement($activity, '@id');
|
||||
if (!empty($id) && !$trust_source) {
|
||||
|
@ -458,7 +459,7 @@ class Receiver
|
|||
* @param array $receivers Array with receivers
|
||||
* @return integer user id;
|
||||
*/
|
||||
public static function getFirstUserFromReceivers($receivers)
|
||||
public static function getFirstUserFromReceivers(array $receivers): int
|
||||
{
|
||||
foreach ($receivers as $receiver) {
|
||||
if (!empty($receiver)) {
|
||||
|
@ -479,7 +480,7 @@ class Receiver
|
|||
* @param array $signer The signer of the post
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function processActivity($activity, string $body = '', int $uid = null, bool $trust_source = false, bool $push = false, array $signer = [])
|
||||
public static function processActivity(array $activity, string $body = '', int $uid = null, bool $trust_source = false, bool $push = false, array $signer = [])
|
||||
{
|
||||
$type = JsonLD::fetchElement($activity, '@type');
|
||||
if (!$type) {
|
||||
|
@ -818,7 +819,7 @@ class Receiver
|
|||
*
|
||||
* @return int user id
|
||||
*/
|
||||
public static function getBestUserForActivity(array $activity)
|
||||
public static function getBestUserForActivity(array $activity): int
|
||||
{
|
||||
$uid = 0;
|
||||
$actor = JsonLD::fetchElement($activity, 'as:actor', '@id') ?? '';
|
||||
|
@ -844,7 +845,8 @@ class Receiver
|
|||
return $uid;
|
||||
}
|
||||
|
||||
public static function getReceiverURL($activity)
|
||||
// @TODO Missing documentation
|
||||
public static function getReceiverURL(array $activity): array
|
||||
{
|
||||
$urls = [];
|
||||
|
||||
|
@ -876,9 +878,9 @@ class Receiver
|
|||
* @return array with receivers (user id)
|
||||
* @throws \Exception
|
||||
*/
|
||||
private static function getReceivers($activity, $actor, $tags = [], $fetch_unlisted = false)
|
||||
private static function getReceivers(array $activity, string $actor, array $tags = [], bool $fetch_unlisted = false): array
|
||||
{
|
||||
$reply = $receivers = [];
|
||||
$reply = $receivers = $profile = [];
|
||||
|
||||
// When it is an answer, we inherite the receivers from the parent
|
||||
$replyto = JsonLD::fetchElement($activity, 'as:inReplyTo', '@id');
|
||||
|
@ -1005,7 +1007,7 @@ class Receiver
|
|||
* @return array with receivers (user id)
|
||||
* @throws \Exception
|
||||
*/
|
||||
private static function getReceiverForActor($actor, $tags, $receivers, $target_type, $profile)
|
||||
private static function getReceiverForActor(string $actor, array $tags, array $receivers, int $target_type, array $profile): array
|
||||
{
|
||||
$basecondition = ['rel' => [Contact::SHARING, Contact::FRIEND, Contact::FOLLOWER],
|
||||
'network' => Protocol::FEDERATED, 'archive' => false, 'pending' => false];
|
||||
|
@ -1047,13 +1049,12 @@ class Receiver
|
|||
* Tests if the contact is a valid receiver for this actor
|
||||
*
|
||||
* @param array $contact
|
||||
* @param string $actor
|
||||
* @param array $tags
|
||||
*
|
||||
* @return bool with receivers (user id)
|
||||
* @throws \Exception
|
||||
*/
|
||||
private static function isValidReceiverForActor($contact, $tags)
|
||||
private static function isValidReceiverForActor(array $contact, array $tags): bool
|
||||
{
|
||||
// Are we following the contact? Then this is a valid receiver
|
||||
if (in_array($contact['rel'], [Contact::SHARING, Contact::FRIEND])) {
|
||||
|
@ -1089,7 +1090,7 @@ class Receiver
|
|||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function switchContact($cid, $uid, $url)
|
||||
public static function switchContact(int $cid, int $uid, string $url)
|
||||
{
|
||||
if (DBA::exists('contact', ['id' => $cid, 'network' => Protocol::ACTIVITYPUB])) {
|
||||
Logger::info('Contact is already ActivityPub', ['id' => $cid, 'uid' => $uid, 'url' => $url]);
|
||||
|
@ -1108,7 +1109,7 @@ class Receiver
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @TODO Fix documentation and type-hints
|
||||
*
|
||||
* @param $receivers
|
||||
* @param $actor
|
||||
|
@ -1135,14 +1136,14 @@ class Receiver
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @TODO Fix documentation and type-hints
|
||||
*
|
||||
* @param $object_data
|
||||
* @param array $activity
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private static function addActivityFields($object_data, $activity)
|
||||
private static function addActivityFields($object_data, array $activity)
|
||||
{
|
||||
if (!empty($activity['published']) && empty($object_data['published'])) {
|
||||
$object_data['published'] = JsonLD::fetchElement($activity, 'as:published', '@value');
|
||||
|
@ -1262,7 +1263,7 @@ class Receiver
|
|||
* @param array $languages
|
||||
* @return array Languages
|
||||
*/
|
||||
public static function processLanguages(array $languages)
|
||||
public static function processLanguages(array $languages): array
|
||||
{
|
||||
if (empty($languages)) {
|
||||
return [];
|
||||
|
@ -1285,7 +1286,7 @@ class Receiver
|
|||
*
|
||||
* @return array with tags in a simplified format
|
||||
*/
|
||||
public static function processTags(array $tags)
|
||||
public static function processTags(array $tags): array
|
||||
{
|
||||
$taglist = [];
|
||||
|
||||
|
@ -1317,7 +1318,7 @@ class Receiver
|
|||
* @param array $emojis
|
||||
* @return array with emojis in a simplified format
|
||||
*/
|
||||
private static function processEmojis(array $emojis)
|
||||
private static function processEmojis(array $emojis): array
|
||||
{
|
||||
$emojilist = [];
|
||||
|
||||
|
@ -1343,7 +1344,7 @@ class Receiver
|
|||
*
|
||||
* @return array Attachments in a simplified format
|
||||
*/
|
||||
private static function processAttachments(array $attachments)
|
||||
private static function processAttachments(array $attachments): array
|
||||
{
|
||||
$attachlist = [];
|
||||
|
||||
|
@ -1460,7 +1461,7 @@ class Receiver
|
|||
*
|
||||
* @return array Questions in a simplified format
|
||||
*/
|
||||
private static function processQuestion(array $object)
|
||||
private static function processQuestion(array $object): array
|
||||
{
|
||||
$question = [];
|
||||
|
||||
|
@ -1518,10 +1519,10 @@ class Receiver
|
|||
* @param array $object
|
||||
* @param array $object_data
|
||||
*
|
||||
* @return array
|
||||
* @return array Object data (?)
|
||||
* @throws \Exception
|
||||
*/
|
||||
private static function getSource($object, $object_data)
|
||||
private static function getSource(array $object, array $object_data): array
|
||||
{
|
||||
$object_data['source'] = JsonLD::fetchElement($object, 'as:source', 'as:content', 'as:mediaType', 'text/bbcode');
|
||||
$object_data['source'] = JsonLD::fetchElement($object_data, 'source', '@value');
|
||||
|
@ -1650,10 +1651,10 @@ class Receiver
|
|||
*
|
||||
* @param array $object
|
||||
*
|
||||
* @return array
|
||||
* @return array|bool Object data or FALSE if $object does not contain @id element
|
||||
* @throws \Exception
|
||||
*/
|
||||
private static function processObject($object)
|
||||
private static function processObject(array $object)
|
||||
{
|
||||
if (!JsonLD::fetchElement($object, '@id')) {
|
||||
return false;
|
||||
|
@ -1767,7 +1768,7 @@ class Receiver
|
|||
$object_data['question'] = self::processQuestion($object);
|
||||
}
|
||||
|
||||
$receiverdata = self::getReceivers($object, $object_data['actor'], $object_data['tags'], true);
|
||||
$receiverdata = self::getReceivers($object, $object_data['actor'] ?? '', $object_data['tags'], true);
|
||||
$receivers = $reception_types = [];
|
||||
foreach ($receiverdata as $key => $data) {
|
||||
$receivers[$key] = $data['uid'];
|
||||
|
|
|
@ -68,7 +68,7 @@ class Transmitter
|
|||
* @param array $inboxes
|
||||
* @return array inboxes with added relay servers
|
||||
*/
|
||||
public static function addRelayServerInboxes(array $inboxes = [])
|
||||
public static function addRelayServerInboxes(array $inboxes = []): array
|
||||
{
|
||||
foreach (Relay::getList(['inbox']) as $contact) {
|
||||
$inboxes[$contact['inbox']] = $contact['inbox'];
|
||||
|
@ -83,7 +83,7 @@ class Transmitter
|
|||
* @param array $inboxes
|
||||
* @return array inboxes with added relay servers
|
||||
*/
|
||||
public static function addRelayServerInboxesForItem(int $item_id, array $inboxes = [])
|
||||
public static function addRelayServerInboxesForItem(int $item_id, array $inboxes = []): array
|
||||
{
|
||||
$item = Post::selectFirst(['uid'], ['id' => $item_id]);
|
||||
if (empty($item)) {
|
||||
|
|
|
@ -72,7 +72,7 @@ class DFRN
|
|||
* @return array importer
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function getImporter($cid, $uid = 0)
|
||||
public static function getImporter(int $cid, int $uid = 0): array
|
||||
{
|
||||
$condition = ['id' => $cid, 'blocked' => false, 'pending' => false];
|
||||
$contact = DBA::selectFirst('contact', [], $condition);
|
||||
|
@ -115,7 +115,7 @@ class DFRN
|
|||
* @throws \ImagickException
|
||||
* @todo Find proper type-hints
|
||||
*/
|
||||
public static function entries($items, $owner)
|
||||
public static function entries(array $items, array $owner): string
|
||||
{
|
||||
$doc = new DOMDocument('1.0', 'utf-8');
|
||||
$doc->formatOutput = true;
|
||||
|
@ -152,7 +152,7 @@ class DFRN
|
|||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function itemFeed(int $uri_id, int $uid, bool $conversation = false)
|
||||
public static function itemFeed(int $uri_id, int $uid, bool $conversation = false): string
|
||||
{
|
||||
if ($conversation) {
|
||||
$condition = ['parent-uri-id' => $uri_id];
|
||||
|
@ -222,7 +222,7 @@ class DFRN
|
|||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @todo Find proper type-hints
|
||||
*/
|
||||
public static function mail(array $mail, array $owner)
|
||||
public static function mail(array $mail, array $owner): string
|
||||
{
|
||||
$doc = new DOMDocument('1.0', 'utf-8');
|
||||
$doc->formatOutput = true;
|
||||
|
@ -259,7 +259,7 @@ class DFRN
|
|||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @todo Find proper type-hints
|
||||
*/
|
||||
public static function fsuggest($item, $owner)
|
||||
public static function fsuggest(array $item, array $owner): string
|
||||
{
|
||||
$doc = new DOMDocument('1.0', 'utf-8');
|
||||
$doc->formatOutput = true;
|
||||
|
@ -289,7 +289,7 @@ class DFRN
|
|||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @todo Find proper type-hints
|
||||
*/
|
||||
public static function relocate($owner, $uid)
|
||||
public static function relocate(array $owner, int $uid): string
|
||||
{
|
||||
|
||||
/* get site pubkey. this could be a new installation with no site keys*/
|
||||
|
@ -346,9 +346,9 @@ class DFRN
|
|||
*
|
||||
* @return object XML root object
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @todo Find proper type-hints
|
||||
* @todo Find proper type-hint for returned type
|
||||
*/
|
||||
private static function addHeader(DOMDocument $doc, $owner, $authorelement, $alternatelink = "", $public = false)
|
||||
private static function addHeader(DOMDocument $doc, array $owner, string $authorelement, string $alternatelink = '', bool $public = false)
|
||||
{
|
||||
|
||||
if ($alternatelink == "") {
|
||||
|
@ -428,8 +428,12 @@ class DFRN
|
|||
* viewer's timezone also, but first we are going to convert it from the birthday
|
||||
* person's timezone to GMT - so the viewer may find the birthday starting at
|
||||
* 6:00PM the day before, but that will correspond to midnight to the birthday person.
|
||||
*
|
||||
* @param int $uid User id
|
||||
* @param string $tz Time zone string, like UTC
|
||||
* @return string Formatted birthday string
|
||||
*/
|
||||
private static function determineNextBirthday($uid, $tz)
|
||||
private static function determineNextBirthday(int $uid, string $tz): string
|
||||
{
|
||||
$birthday = '';
|
||||
|
||||
|
@ -467,7 +471,7 @@ class DFRN
|
|||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @todo Find proper type-hints
|
||||
*/
|
||||
private static function addAuthor(DOMDocument $doc, array $owner, $authorelement, $public)
|
||||
private static function addAuthor(DOMDocument $doc, array $owner, string $authorelement, bool $public)
|
||||
{
|
||||
// Should the profile be "unsearchable" in the net? Then add the "hide" element
|
||||
$hide = DBA::exists('profile', ['uid' => $owner['uid'], 'net-publish' => false]);
|
||||
|
@ -592,7 +596,7 @@ class DFRN
|
|||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @todo Find proper type-hints
|
||||
*/
|
||||
private static function addEntryAuthor(DOMDocument $doc, $element, $contact_url, $item)
|
||||
private static function addEntryAuthor(DOMDocument $doc, string $element, string $contact_url, array $item)
|
||||
{
|
||||
$author = $doc->createElement($element);
|
||||
|
||||
|
@ -637,7 +641,7 @@ class DFRN
|
|||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @todo Find proper type-hints
|
||||
*/
|
||||
private static function createActivity(DOMDocument $doc, $element, $activity, $uriid)
|
||||
private static function createActivity(DOMDocument $doc, string $element, string $activity, int $uriid)
|
||||
{
|
||||
if ($activity) {
|
||||
$entry = $doc->createElement($element);
|
||||
|
@ -703,7 +707,7 @@ class DFRN
|
|||
* @return void XML attachment object
|
||||
* @todo Find proper type-hints
|
||||
*/
|
||||
private static function getAttachment($doc, $root, $item)
|
||||
private static function getAttachment($doc, $root, array $item)
|
||||
{
|
||||
foreach (Post\Media::getByURIId($item['uri-id'], [Post\Media::DOCUMENT, Post\Media::TORRENT, Post\Media::UNKNOWN]) as $attachment) {
|
||||
$attributes = ['rel' => 'enclosure',
|
||||
|
@ -737,7 +741,7 @@ class DFRN
|
|||
* @throws \ImagickException
|
||||
* @todo Find proper type-hints
|
||||
*/
|
||||
private static function entry(DOMDocument $doc, $type, array $item, array $owner, $comment = false, $cid = 0, $single = false)
|
||||
private static function entry(DOMDocument $doc, string $type, array $item, array $owner, bool $comment = false, int $cid = 0, bool $single = false)
|
||||
{
|
||||
$mentioned = [];
|
||||
|
||||
|
@ -961,13 +965,12 @@ class DFRN
|
|||
* @param array $owner Owner record
|
||||
* @param array $contact Contact record of the receiver
|
||||
* @param string $atom Content that will be transmitted
|
||||
*
|
||||
* @param bool $public_batch
|
||||
* @return int Deliver status. Negative values mean an error.
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function transmit($owner, $contact, $atom, $public_batch = false)
|
||||
public static function transmit(array $owner, array $contact, string $atom, bool $public_batch = false)
|
||||
{
|
||||
if (!$public_batch) {
|
||||
if (empty($contact['addr'])) {
|
||||
|
@ -1060,7 +1063,7 @@ class DFRN
|
|||
* @throws \ImagickException
|
||||
* @todo Find good type-hints for all parameter
|
||||
*/
|
||||
private static function fetchauthor(\DOMXPath $xpath, \DOMNode $context, $importer, $element, $onlyfetch, $xml = "")
|
||||
private static function fetchauthor(\DOMXPath $xpath, \DOMNode $context, array $importer, string $element, bool $onlyfetch, string $xml = ''): array
|
||||
{
|
||||
$author = [];
|
||||
$author["name"] = XML::getFirstNodeValue($xpath, $element."/atom:name/text()", $context);
|
||||
|
@ -1280,7 +1283,7 @@ class DFRN
|
|||
* @return string XML string
|
||||
* @todo Find good type-hints for all parameter
|
||||
*/
|
||||
private static function transformActivity($xpath, $activity, $element)
|
||||
private static function transformActivity($xpath, $activity, string $element): string
|
||||
{
|
||||
if (!is_object($activity)) {
|
||||
return "";
|
||||
|
@ -1335,7 +1338,7 @@ class DFRN
|
|||
* @throws \Exception
|
||||
* @todo Find good type-hints for all parameter
|
||||
*/
|
||||
private static function processMail($xpath, $mail, $importer)
|
||||
private static function processMail($xpath, $mail, array $importer)
|
||||
{
|
||||
Logger::notice("Processing mails");
|
||||
|
||||
|
@ -1364,7 +1367,7 @@ class DFRN
|
|||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @todo Find good type-hints for all parameter
|
||||
*/
|
||||
private static function processSuggestion($xpath, $suggestion, $importer)
|
||||
private static function processSuggestion($xpath, $suggestion, array $importer)
|
||||
{
|
||||
Logger::notice('Processing suggestions');
|
||||
|
||||
|
@ -1383,7 +1386,7 @@ class DFRN
|
|||
* @param integer $from_cid
|
||||
* @return bool Was the adding successful?
|
||||
*/
|
||||
private static function addSuggestion(int $uid, int $cid, int $from_cid, string $note = '')
|
||||
private static function addSuggestion(int $uid, int $cid, int $from_cid, string $note = ''): bool
|
||||
{
|
||||
$owner = User::getOwnerDataById($uid);
|
||||
$contact = Contact::getById($cid);
|
||||
|
@ -1440,7 +1443,7 @@ class DFRN
|
|||
* @throws \ImagickException
|
||||
* @todo Find good type-hints for all parameter
|
||||
*/
|
||||
private static function processRelocation($xpath, $relocation, $importer)
|
||||
private static function processRelocation($xpath, $relocation, array $importer): bool
|
||||
{
|
||||
Logger::notice("Processing relocations");
|
||||
|
||||
|
@ -1510,7 +1513,7 @@ class DFRN
|
|||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @todo set proper type-hints (array?)
|
||||
*/
|
||||
private static function updateContent($current, $item, $importer, $entrytype)
|
||||
private static function updateContent(array $current, array $item, array $importer, int $entrytype)
|
||||
{
|
||||
$changed = false;
|
||||
|
||||
|
@ -1542,7 +1545,7 @@ class DFRN
|
|||
* @throws \Exception
|
||||
* @todo set proper type-hints (array?)
|
||||
*/
|
||||
private static function getEntryType($importer, $item)
|
||||
private static function getEntryType(array $importer, array $item): int
|
||||
{
|
||||
if ($item["thr-parent"] != $item["uri"]) {
|
||||
$community = false;
|
||||
|
@ -1638,7 +1641,7 @@ class DFRN
|
|||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @todo set proper type-hints (array?)
|
||||
*/
|
||||
private static function processVerbs($entrytype, $importer, &$item, &$is_like)
|
||||
private static function processVerbs(int $entrytype, array $importer, array &$item, bool &$is_like)
|
||||
{
|
||||
Logger::info("Process verb ".$item["verb"]." and object-type ".$item["object-type"]." for entrytype ".$entrytype);
|
||||
|
||||
|
@ -1734,7 +1737,7 @@ class DFRN
|
|||
* @return void
|
||||
* @todo set proper type-hints
|
||||
*/
|
||||
private static function parseLinks($links, &$item)
|
||||
private static function parseLinks($links, array &$item)
|
||||
{
|
||||
$rel = "";
|
||||
$href = "";
|
||||
|
@ -1772,7 +1775,7 @@ class DFRN
|
|||
* @param array $imporer
|
||||
* @return boolean Is the message wanted?
|
||||
*/
|
||||
private static function isSolicitedMessage(array $item, array $importer)
|
||||
private static function isSolicitedMessage(array $item, array $importer): bool
|
||||
{
|
||||
if (DBA::exists('contact', ["`nurl` = ? AND `uid` != ? AND `rel` IN (?, ?)",
|
||||
Strings::normaliseLink($item["author-link"]), 0, Contact::FRIEND, Contact::SHARING])) {
|
||||
|
@ -1807,12 +1810,13 @@ class DFRN
|
|||
* @param object $entry entry elements
|
||||
* @param array $importer Record of the importer user mixed with contact of the content
|
||||
* @param string $xml xml
|
||||
* @param int $protocol Protocol
|
||||
* @return void
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
* @todo Add type-hints
|
||||
*/
|
||||
private static function processEntry($header, $xpath, $entry, $importer, $xml, $protocol)
|
||||
private static function processEntry(array $header, $xpath, $entry, array $importer, string $xml, int $protocol)
|
||||
{
|
||||
Logger::notice("Processing entries");
|
||||
|
||||
|
@ -2070,6 +2074,9 @@ class DFRN
|
|||
}
|
||||
}
|
||||
|
||||
// Need to initialize variable, otherwise E_NOTICE will happen
|
||||
$is_like = false;
|
||||
|
||||
if (!self::processVerbs($entrytype, $importer, $item, $is_like)) {
|
||||
Logger::info("Exiting because 'processVerbs' told us so");
|
||||
return;
|
||||
|
@ -2163,7 +2170,7 @@ class DFRN
|
|||
* @throws \Exception
|
||||
* @todo set proper type-hints
|
||||
*/
|
||||
private static function processDeletion($xpath, $deletion, $importer)
|
||||
private static function processDeletion($xpath, $deletion, array $importer)
|
||||
{
|
||||
Logger::notice("Processing deletions");
|
||||
$uri = null;
|
||||
|
@ -2224,9 +2231,8 @@ class DFRN
|
|||
* @return integer Import status
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
* @todo set proper type-hints
|
||||
*/
|
||||
public static function import($xml, $importer, $protocol, $direction)
|
||||
public static function import(string $xml, array $importer, int $protocol, int $direction): int
|
||||
{
|
||||
if ($xml == "") {
|
||||
return 400;
|
||||
|
@ -2365,7 +2371,7 @@ class DFRN
|
|||
*
|
||||
* @return string activity verb
|
||||
*/
|
||||
private static function constructVerb(array $item)
|
||||
private static function constructVerb(array $item): string
|
||||
{
|
||||
if ($item['verb']) {
|
||||
return $item['verb'];
|
||||
|
@ -2373,7 +2379,8 @@ class DFRN
|
|||
return Activity::POST;
|
||||
}
|
||||
|
||||
private static function tgroupCheck($uid, $item)
|
||||
// @TODO Documentation missing
|
||||
private static function tgroupCheck(int $uid, array $item): bool
|
||||
{
|
||||
$mention = false;
|
||||
|
||||
|
@ -2421,12 +2428,12 @@ class DFRN
|
|||
* item is assumed to be up-to-date. If the timestamps are equal it
|
||||
* assumes the update has been seen before and should be ignored.
|
||||
*
|
||||
* @param $existing
|
||||
* @param $update
|
||||
* @param array $existing
|
||||
* @param array $update
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
private static function isEditedTimestampNewer($existing, $update)
|
||||
private static function isEditedTimestampNewer(array $existing, array $update): bool
|
||||
{
|
||||
if (empty($existing['edited'])) {
|
||||
return true;
|
||||
|
@ -2449,7 +2456,7 @@ class DFRN
|
|||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function isSupportedByContactUrl($url)
|
||||
public static function isSupportedByContactUrl(string $url): bool
|
||||
{
|
||||
$probe = Probe::uri($url, Protocol::DFRN);
|
||||
return $probe['network'] == Protocol::DFRN;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -708,7 +708,6 @@ class HTTPSignature
|
|||
}
|
||||
}
|
||||
|
||||
// @TODO really a notice or more a warning?
|
||||
Logger::notice('Key could not be fetched', ['url' => $url, 'actor' => $actor]);
|
||||
return [];
|
||||
}
|
||||
|
|
|
@ -165,7 +165,7 @@ class Strings
|
|||
* @return string Formatted network name
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function formatNetworkName($network, $url = '')
|
||||
public static function formatNetworkName(string $network, string $url = ''): string
|
||||
{
|
||||
if ($network != '') {
|
||||
if ($url != '') {
|
||||
|
@ -176,6 +176,8 @@ class Strings
|
|||
|
||||
return $network_name;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -187,7 +189,7 @@ class Strings
|
|||
*
|
||||
* @return string Transformed string.
|
||||
*/
|
||||
public static function deindent($text, $chr = "[\t ]", $count = NULL)
|
||||
public static function deindent(string $text, string $chr = "[\t ]", int $count = null)
|
||||
{
|
||||
$lines = explode("\n", $text);
|
||||
|
||||
|
|
|
@ -269,7 +269,7 @@ class Delivery
|
|||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
private static function deliverDFRN($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup, $server_protocol)
|
||||
private static function deliverDFRN(string $cmd, array $contact, array $owner, array $items, array $target_item, bool $public_message, bool $top_level, bool $followup, int $server_protocol)
|
||||
{
|
||||
// Transmit Diaspora reshares via Diaspora if the Friendica contact support Diaspora
|
||||
if (Diaspora::isReshare($target_item['body'] ?? '') && !empty(FContact::getByURL($contact['addr'], false))) {
|
||||
|
@ -384,7 +384,7 @@ class Delivery
|
|||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
private static function deliverDiaspora($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup)
|
||||
private static function deliverDiaspora(string $cmd, array $contact, array $owner, array $items, array $target_item, bool $public_message, bool $top_level, bool $followup)
|
||||
{
|
||||
// We don't treat Forum posts as "wall-to-wall" to be able to post them via Diaspora
|
||||
$walltowall = $top_level && ($owner['id'] != $items[0]['contact-id']) & ($owner['account-type'] != Model\User::ACCOUNT_TYPE_COMMUNITY);
|
||||
|
@ -478,7 +478,7 @@ class Delivery
|
|||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
private static function deliverMail($cmd, $contact, $owner, $target_item, $thr_parent)
|
||||
private static function deliverMail(string $cmd, array $contact, array $owner, array $target_item, array $thr_parent)
|
||||
{
|
||||
if (DI::config()->get('system','imap_disabled')) {
|
||||
return;
|
||||
|
|
|
@ -34,7 +34,7 @@ use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
|||
*/
|
||||
class Directory
|
||||
{
|
||||
public static function execute($url = '')
|
||||
public static function execute(string $url = '')
|
||||
{
|
||||
$dir = Search::getGlobalDirectory();
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ class AppDouble extends App
|
|||
$this->isLoggedIn = $isLoggedIn;
|
||||
}
|
||||
|
||||
public function isLoggedIn()
|
||||
public function isLoggedIn(): bool
|
||||
{
|
||||
return $this->isLoggedIn;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue