* @return int ID of inserted post
* @throws \Exception
*/
- public static function insert(int $uri_id, array $data = [])
+ public static function insert(int $uri_id, array $data = []): int
{
if (empty($uri_id)) {
throw new BadMethodCallException('Empty URI_id');
* @param object $stmt statement object
* @param bool $do_close
* @return array Data array
+ * @todo Find proper type-hint for $stmt and maybe avoid boolean
*/
- public static function toArray($stmt, $do_close = true) {
+ public static function toArray($stmt, bool $do_close = true)
+ {
if (is_bool($stmt)) {
return $stmt;
}
* @return boolean Are there rows for that condition?
* @throws \Exception
*/
- public static function exists($condition) {
+ public static function exists(array $condition): bool
+ {
return DBA::exists('post-user-view', $condition);
}
* $count = Post::count($condition);
* @throws \Exception
*/
- public static function count(array $condition = [], array $params = [])
+ public static function count(array $condition = [], array $params = []): int
{
return DBA::count('post-user-view', $condition, $params);
}
* $count = Post::count($condition);
* @throws \Exception
*/
- public static function countThread(array $condition = [], array $params = [])
+ public static function countThread(array $condition = [], array $params = []): int
{
return DBA::count('post-thread-user-view', $condition, $params);
}
* $count = Post::count($condition);
* @throws \Exception
*/
- public static function countPosts(array $condition = [], array $params = [])
+ public static function countPosts(array $condition = [], array $params = []): int
{
return DBA::count('post-view', $condition, $params);
}
* @throws \Exception
* @see DBA::select
*/
- public static function selectFirst(array $fields = [], array $condition = [], $params = [])
+ public static function selectFirst(array $fields = [], array $condition = [], array $params = [])
{
$params['limit'] = 1;
* @throws \Exception
* @see DBA::select
*/
- public static function selectFirstPost(array $fields = [], array $condition = [], $params = [])
+ public static function selectFirstPost(array $fields = [], array $condition = [], array $params = [])
{
$params['limit'] = 1;
* @throws \Exception
* @see DBA::select
*/
- public static function selectFirstThread(array $fields = [], array $condition = [], $params = [])
+ public static function selectFirstThread(array $fields = [], array $condition = [], array $params = [])
{
$params['limit'] = 1;
* @return array
* @throws \Exception
*/
- public static function selectToArray(array $fields = [], array $condition = [], $params = [])
+ public static function selectToArray(array $fields = [], array $condition = [], array $params = [])
{
$result = self::select($fields, $condition, $params);
* @return boolean|object
* @throws \Exception
*/
- private static function selectView(string $view, array $selected = [], array $condition = [], $params = [])
+ private static function selectView(string $view, array $selected = [], array $condition = [], array $params = [])
{
if (empty($selected)) {
$selected = array_merge(Item::DISPLAY_FIELDLIST, Item::ITEM_FIELDLIST);
* @return boolean|object
* @throws \Exception
*/
- public static function select(array $selected = [], array $condition = [], $params = [])
+ public static function select(array $selected = [], array $condition = [], array $params = [])
{
return self::selectView('post-user-view', $selected, $condition, $params);
}
* @return boolean|object
* @throws \Exception
*/
- public static function selectPosts(array $selected = [], array $condition = [], $params = [])
+ public static function selectPosts(array $selected = [], array $condition = [], array $params = [])
{
return self::selectView('post-view', $selected, $condition, $params);
}
* @return boolean|object
* @throws \Exception
*/
- public static function selectThread(array $selected = [], array $condition = [], $params = [])
+ public static function selectThread(array $selected = [], array $condition = [], array $params = [])
{
return self::selectView('post-thread-user-view', $selected, $condition, $params);
}
* @return boolean|object
* @throws \Exception
*/
- private static function selectViewForUser(string $view, $uid, array $selected = [], array $condition = [], $params = [])
+ private static function selectViewForUser(string $view, int $uid, array $selected = [], array $condition = [], array $params = [])
{
if (empty($selected)) {
$selected = Item::DISPLAY_FIELDLIST;
* @return boolean|object
* @throws \Exception
*/
- public static function selectForUser($uid, array $selected = [], array $condition = [], $params = [])
+ public static function selectForUser(int $uid, array $selected = [], array $condition = [], array $params = [])
{
return self::selectViewForUser('post-user-view', $uid, $selected, $condition, $params);
}
* @return boolean|object
* @throws \Exception
*/
- public static function selectPostsForUser($uid, array $selected = [], array $condition = [], $params = [])
+ public static function selectPostsForUser(int $uid, array $selected = [], array $condition = [], array $params = [])
{
return self::selectViewForUser('post-view', $uid, $selected, $condition, $params);
}
* @return boolean|object
* @throws \Exception
*/
- public static function selectThreadForUser($uid, array $selected = [], array $condition = [], $params = [])
+ public static function selectThreadForUser(int $uid, array $selected = [], array $condition = [], array $params = [])
{
return self::selectViewForUser('post-thread-user-view', $uid, $selected, $condition, $params);
}
* @throws \Exception
* @see DBA::select
*/
- public static function selectFirstForUser($uid, array $selected = [], array $condition = [], $params = [])
+ public static function selectFirstForUser(int $uid, array $selected = [], array $condition = [], array $params = [])
{
$params['limit'] = 1;
* @return boolean was the delete successful?
* @throws \Exception
*/
- public static function delete(array $conditions, array $options = [])
+ public static function delete(array $conditions, array $options = []): bool
{
return DBA::delete('post', $conditions, $options);
}
*
* @param integer User ID
*
- * @return array Profile data
+ * @return array|bool Profile data or false on error
* @throws \Exception
*/
- public static function getByUID($uid)
+ public static function getByUID(int $uid)
{
return DBA::selectFirst('profile', [], ['uid' => $uid]);
}
* @param int $id The contact owner ID
* @param array $fields The selected fields
*
- * @return array Profile data for the ID
+ * @return array|bool Profile data for the ID or false on error
* @throws \Exception
*/
public static function getById(int $uid, int $id, array $fields = [])
* Returns profile data for the contact owner
*
* @param int $uid The User ID
- * @param array $fields The fields to retrieve
+ * @param array|bool $fields The fields to retrieve or false on error
*
* @return array Array of profile data
* @throws \Exception
/**
* Update a profile entry and distribute the changes if needed
*
- * @param array $fields
- * @param integer $uid
- * @return boolean
+ * @param array $fields Profile fields to update
+ * @param integer $uid User id
+ * @return boolean Whether update was successful
*/
public static function update(array $fields, int $uid): bool
{
/**
* Publish a changed profile
- * @param int $uid
+ *
+ * @param int $uid User id
* @param bool $force Force publishing to the directory
+ * @return void
*/
public static function publishUpdate(int $uid, bool $force = false)
{
*
* @return string Location string
*/
- public static function formatLocation(array $profile)
+ public static function formatLocation(array $profile): string
{
$location = '';
*
* @param integer $uid User ID
* @param int $default_priority
+ * @return void
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- public static function publishFeed($uid, $default_priority = PRIORITY_HIGH)
+ public static function publishFeed(int $uid, int $default_priority = PRIORITY_HIGH)
{
$condition = ['push' => 0, 'uid' => $uid];
DBA::update('push_subscriber', ['push' => 1, 'next_try' => DBA::NULL_DATETIME], $condition);
* start workers to transmit the feed data
*
* @param int $default_priority
+ * @return void
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- public static function requeue($default_priority = PRIORITY_HIGH)
+ public static function requeue(int $default_priority = PRIORITY_HIGH)
{
// We'll push to each subscriber that has push > 0,
// i.e. there has been an update (set in notifier.php).
* @param string $hub_callback Callback address
* @param string $hub_topic Feed topic
* @param string $hub_secret Subscription secret
+ * @return void
* @throws \Exception
*/
- public static function renew($uid, $nick, $subscribe, $hub_callback, $hub_topic, $hub_secret)
+ public static function renew(int $uid, string $nick, int $subscribe, string $hub_callback, string $hub_topic, string $hub_secret)
{
// fetch the old subscription if it exists
$subscriber = DBA::selectFirst('push_subscriber', ['last_update', 'push'], ['callback_url' => $hub_callback]);
* Delay the push subscriber
*
* @param integer $id Subscriber ID
+ * @return void
* @throws \Exception
*/
- public static function delay($id)
+ public static function delay(int $id)
{
$subscriber = DBA::selectFirst('push_subscriber', ['push', 'callback_url', 'renewed', 'nickname'], ['id' => $id]);
if (!DBA::isResult($subscriber)) {
*
* @param integer $id Subscriber ID
* @param string $last_update Date of last transmitted item
+ * @return void
* @throws \Exception
*/
- public static function reset($id, $last_update)
+ public static function reset(int $id, string $last_update)
{
$subscriber = DBA::selectFirst('push_subscriber', ['callback_url', 'nickname'], ['id' => $id]);
if (!DBA::isResult($subscriber)) {