diff options
| author | 2024-08-01 20:31:40 +0200 | |
|---|---|---|
| committer | 2024-08-01 20:31:40 +0200 | |
| commit | d2247221bbf23a8fe19f66ea4ad7d0a59ffaa5b4 (patch) | |
| tree | f5174c1b1d174cd41dca20f350e1297894e1c6fa /app/Models/Context.php | |
| parent | b2c8cb74562b2f7cb290abd61ff1b6f35475f23a (diff) | |
Minor update whitespace PHPCS rules (#6666)
* Minor update whitespace PHPCS rules
To simplify our configuration, apply more rules, and be clearer about what is added or removed compared with PSR12.
Does not change our current conventions, but just a bit more consistent.
* Forgotten *.phtml
* Sort exclusion patterns + add a few for Extensions repo
* Relaxed some rules
Diffstat (limited to 'app/Models/Context.php')
| -rw-r--r-- | app/Models/Context.php | 260 |
1 files changed, 130 insertions, 130 deletions
diff --git a/app/Models/Context.php b/app/Models/Context.php index 7efb24ab1..988eedc71 100644 --- a/app/Models/Context.php +++ b/app/Models/Context.php @@ -347,23 +347,23 @@ final class FreshRSS_Context { $type = substr($get, 0, 1); $id = substr($get, 2); - switch($type) { - case 'a': - return self::$current_get['all']; - case 'i': - return self::$current_get['important']; - case 's': - return self::$current_get['starred']; - case 'f': - return self::$current_get['feed'] == $id; - case 'c': - return self::$current_get['category'] == $id; - case 't': - return self::$current_get['tag'] == $id; - case 'T': - return self::$current_get['tags'] || self::$current_get['tag']; - default: - return false; + switch ($type) { + case 'a': + return self::$current_get['all']; + case 'i': + return self::$current_get['important']; + case 's': + return self::$current_get['starred']; + case 'f': + return self::$current_get['feed'] == $id; + case 'c': + return self::$current_get['category'] == $id; + case 't': + return self::$current_get['tag'] == $id; + case 'T': + return self::$current_get['tags'] || self::$current_get['tag']; + default: + return false; } } @@ -393,84 +393,84 @@ final class FreshRSS_Context { self::$categories = $catDAO->listCategories(true, $details); } - switch($type) { - case 'a': - self::$current_get['all'] = true; - self::$name = _t('index.feed.title'); - self::$description = FreshRSS_Context::systemConf()->meta_description; - self::$get_unread = self::$total_unread; - break; - case 'i': - self::$current_get['important'] = true; - self::$name = _t('index.menu.important'); - self::$description = FreshRSS_Context::systemConf()->meta_description; - self::$get_unread = self::$total_unread; - break; - case 's': - self::$current_get['starred'] = true; - self::$name = _t('index.feed.title_fav'); - self::$description = FreshRSS_Context::systemConf()->meta_description; - self::$get_unread = self::$total_starred['unread']; - - // Update state if favorite is not yet enabled. - self::$state = self::$state | FreshRSS_Entry::STATE_FAVORITE; - break; - case 'f': - // We try to find the corresponding feed. When allowing robots, always retrieve the full feed including description - $feed = FreshRSS_Context::systemConf()->allow_robots ? null : FreshRSS_Category::findFeed(self::$categories, $id); - if ($feed === null) { - $feedDAO = FreshRSS_Factory::createFeedDao(); - $feed = $feedDAO->searchById($id); + switch ($type) { + case 'a': + self::$current_get['all'] = true; + self::$name = _t('index.feed.title'); + self::$description = FreshRSS_Context::systemConf()->meta_description; + self::$get_unread = self::$total_unread; + break; + case 'i': + self::$current_get['important'] = true; + self::$name = _t('index.menu.important'); + self::$description = FreshRSS_Context::systemConf()->meta_description; + self::$get_unread = self::$total_unread; + break; + case 's': + self::$current_get['starred'] = true; + self::$name = _t('index.feed.title_fav'); + self::$description = FreshRSS_Context::systemConf()->meta_description; + self::$get_unread = self::$total_starred['unread']; + + // Update state if favorite is not yet enabled. + self::$state = self::$state | FreshRSS_Entry::STATE_FAVORITE; + break; + case 'f': + // We try to find the corresponding feed. When allowing robots, always retrieve the full feed including description + $feed = FreshRSS_Context::systemConf()->allow_robots ? null : FreshRSS_Category::findFeed(self::$categories, $id); if ($feed === null) { - throw new FreshRSS_Context_Exception('Invalid feed: ' . $id); + $feedDAO = FreshRSS_Factory::createFeedDao(); + $feed = $feedDAO->searchById($id); + if ($feed === null) { + throw new FreshRSS_Context_Exception('Invalid feed: ' . $id); + } } - } - self::$current_get['feed'] = $id; - self::$current_get['category'] = $feed->categoryId(); - self::$name = $feed->name(); - self::$description = $feed->description(); - self::$get_unread = $feed->nbNotRead(); - break; - case 'c': - // We try to find the corresponding category. - self::$current_get['category'] = $id; - if (!isset(self::$categories[$id])) { - $catDAO = FreshRSS_Factory::createCategoryDao(); - $cat = $catDAO->searchById($id); - if ($cat === null) { - throw new FreshRSS_Context_Exception('Invalid category: ' . $id); + self::$current_get['feed'] = $id; + self::$current_get['category'] = $feed->categoryId(); + self::$name = $feed->name(); + self::$description = $feed->description(); + self::$get_unread = $feed->nbNotRead(); + break; + case 'c': + // We try to find the corresponding category. + self::$current_get['category'] = $id; + if (!isset(self::$categories[$id])) { + $catDAO = FreshRSS_Factory::createCategoryDao(); + $cat = $catDAO->searchById($id); + if ($cat === null) { + throw new FreshRSS_Context_Exception('Invalid category: ' . $id); + } + self::$categories[$id] = $cat; + } else { + $cat = self::$categories[$id]; } - self::$categories[$id] = $cat; - } else { - $cat = self::$categories[$id]; - } - self::$name = $cat->name(); - self::$get_unread = $cat->nbNotRead(); - break; - case 't': - // We try to find the corresponding tag. - self::$current_get['tag'] = $id; - if (!isset(self::$tags[$id])) { - $tagDAO = FreshRSS_Factory::createTagDao(); - $tag = $tagDAO->searchById($id); - if ($tag === null) { - throw new FreshRSS_Context_Exception('Invalid tag: ' . $id); + self::$name = $cat->name(); + self::$get_unread = $cat->nbNotRead(); + break; + case 't': + // We try to find the corresponding tag. + self::$current_get['tag'] = $id; + if (!isset(self::$tags[$id])) { + $tagDAO = FreshRSS_Factory::createTagDao(); + $tag = $tagDAO->searchById($id); + if ($tag === null) { + throw new FreshRSS_Context_Exception('Invalid tag: ' . $id); + } + self::$tags[$id] = $tag; + } else { + $tag = self::$tags[$id]; } - self::$tags[$id] = $tag; - } else { - $tag = self::$tags[$id]; - } - self::$name = $tag->name(); - self::$get_unread = $tag->nbUnread(); - break; - case 'T': - $tagDAO = FreshRSS_Factory::createTagDao(); - self::$current_get['tags'] = true; - self::$name = _t('index.menu.tags'); - self::$get_unread = $tagDAO->countNotRead(); - break; - default: - throw new FreshRSS_Context_Exception('Invalid getter: ' . $get); + self::$name = $tag->name(); + self::$get_unread = $tag->nbUnread(); + break; + case 'T': + $tagDAO = FreshRSS_Factory::createTagDao(); + self::$current_get['tags'] = true; + self::$name = _t('index.menu.tags'); + self::$get_unread = $tagDAO->countNotRead(); + break; + default: + throw new FreshRSS_Context_Exception('Invalid getter: ' . $get); } self::_nextGet(); @@ -493,54 +493,54 @@ final class FreshRSS_Context { $another_unread_id = ''; $found_current_get = false; switch ($get[0]) { - case 'f': - // We search the next unread feed with the following priorities: next in same category, or previous in same category, or next, or previous. - foreach (self::$categories as $cat) { - $sameCat = false; - foreach ($cat->feeds() as $feed) { - if ($found_current_get) { - if ($feed->nbNotRead() > 0) { + case 'f': + // We search the next unread feed with the following priorities: next in same category, or previous in same category, or next, or previous. + foreach (self::$categories as $cat) { + $sameCat = false; + foreach ($cat->feeds() as $feed) { + if ($found_current_get) { + if ($feed->nbNotRead() > 0) { + $another_unread_id = $feed->id(); + break 2; + } + } elseif ($feed->id() == self::$current_get['feed']) { + $found_current_get = true; + } elseif ($feed->nbNotRead() > 0) { $another_unread_id = $feed->id(); - break 2; + $sameCat = true; } - } elseif ($feed->id() == self::$current_get['feed']) { - $found_current_get = true; - } elseif ($feed->nbNotRead() > 0) { - $another_unread_id = $feed->id(); - $sameCat = true; + } + if ($found_current_get && $sameCat) { + break; } } - if ($found_current_get && $sameCat) { - break; - } - } - // If there is no more unread feed, show main stream - self::$next_get = $another_unread_id == '' ? 'a' : 'f_' . $another_unread_id; - break; - case 'c': - // We search the next category with at least one unread article. - foreach (self::$categories as $cat) { - if ($cat->id() == self::$current_get['category']) { - // Here is our current category! Next one could be our - // champion if it has unread articles. - $found_current_get = true; - continue; - } + // If there is no more unread feed, show main stream + self::$next_get = $another_unread_id == '' ? 'a' : 'f_' . $another_unread_id; + break; + case 'c': + // We search the next category with at least one unread article. + foreach (self::$categories as $cat) { + if ($cat->id() == self::$current_get['category']) { + // Here is our current category! Next one could be our + // champion if it has unread articles. + $found_current_get = true; + continue; + } - if ($cat->nbNotRead() > 0) { - $another_unread_id = $cat->id(); - if ($found_current_get) { - // Unread articles and the current category has - // already been found? Leave the loop! - break; + if ($cat->nbNotRead() > 0) { + $another_unread_id = $cat->id(); + if ($found_current_get) { + // Unread articles and the current category has + // already been found? Leave the loop! + break; + } } } - } - // If there is no more unread category, show main stream - self::$next_get = $another_unread_id == '' ? 'a' : 'c_' . $another_unread_id; - break; + // If there is no more unread category, show main stream + self::$next_get = $another_unread_id == '' ? 'a' : 'c_' . $another_unread_id; + break; } } } |
