* @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);
}
* @return array
* @throws \Exception
*/
- public static function selectFirst(array $fields = [], array $condition = [], array $params = [])
+ public static function selectFirst(array $fields = [], array $condition = [], array $params = []): array
{
$contact = DBA::selectFirst('contact', $fields, $condition, $params);
* @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);
*
* @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 = [])
{
* @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]);
}
* @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']]);
}
* @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);
* @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);
* @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;
* @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);
}
/**
- * 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;
* @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);
* @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)) {
*
* @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);
*
* @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)) {
* @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)) {
* @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) {
* @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 [];
* @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' => ''];
* @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'])) {
* @return array
* @throws \Exception
*/
- public static function pruneUnavailable(array $contact_ids)
+ public static function pruneUnavailable(array $contact_ids): array
{
if (empty($contact_ids)) {
return [];
* @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;
* @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]);
* @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'];
*
* @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];
* @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;
* @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 [];
* @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;
* @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` > ?",