diff options
Diffstat (limited to 'classes/counters.php')
-rw-r--r-- | classes/counters.php | 52 |
1 files changed, 43 insertions, 9 deletions
diff --git a/classes/counters.php b/classes/counters.php index 8a8b8bc71..8756b5acf 100644 --- a/classes/counters.php +++ b/classes/counters.php @@ -1,7 +1,10 @@ <?php class Counters { - static function get_all() { + /** + * @return array<int, array<string, int|string>> + */ + static function get_all(): array { return array_merge( self::get_global(), self::get_virt(), @@ -11,7 +14,12 @@ class Counters { ); } - static function get_conditional(array $feed_ids = null, array $label_ids = null) { + /** + * @param array<int> $feed_ids + * @param array<int> $label_ids + * @return array<int, array<string, int|string>> + */ + static function get_conditional(array $feed_ids = null, array $label_ids = null): array { return array_merge( self::get_global(), self::get_virt(), @@ -21,7 +29,10 @@ class Counters { ); } - static private function get_cat_children(int $cat_id, int $owner_uid) { + /** + * @return array<int, int> + */ + static private function get_cat_children(int $cat_id, int $owner_uid): array { $unread = 0; $marked = 0; @@ -40,7 +51,11 @@ class Counters { return [$unread, $marked]; } - private static function get_cats(array $cat_ids = null) { + /** + * @param array<int> $cat_ids + * @return array<int, array<string, int|string>> + */ + private static function get_cats(array $cat_ids = null): array { $ret = []; /* Labels category */ @@ -129,7 +144,11 @@ class Counters { return $ret; } - private static function get_feeds(array $feed_ids = null) { + /** + * @param array<int> $feed_ids + * @return array<int, array<string, int|string>> + */ + private static function get_feeds(array $feed_ids = null): array { $ret = []; @@ -199,7 +218,10 @@ class Counters { return $ret; } - private static function get_global() { + /** + * @return array<int, array<string, int|string>> + */ + private static function get_global(): array { $ret = [ [ "id" => "global-unread", @@ -219,13 +241,16 @@ class Counters { return $ret; } - private static function get_virt() { + /** + * @return array<int, array<string, int|string>> + */ + private static function get_virt(): array { $ret = []; for ($i = 0; $i >= -4; $i--) { - $count = getFeedUnread($i); + $count = Feeds::_get_counters($i, false, true); if ($i == 0 || $i == -1 || $i == -2) $auxctr = Feeds::_get_counters($i, false); @@ -248,6 +273,11 @@ class Counters { if (is_array($feeds)) { foreach ($feeds as $feed) { + /** @var IVirtualFeed $feed['sender'] */ + + if (!implements_interface($feed['sender'], 'IVirtualFeed')) + continue; + $cv = [ "id" => PluginHost::pfeed_to_feed_id($feed['id']), "counter" => $feed['sender']->get_unread($feed['id']) @@ -263,7 +293,11 @@ class Counters { return $ret; } - static function get_labels(array $label_ids = null) { + /** + * @param array<int> $label_ids + * @return array<int, array<string, int|string>> + */ + static function get_labels(array $label_ids = null): array { $ret = []; |