From a80a5f48a16e7d232168a7aaa68e9a1804235ce1 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 18 Dec 2023 17:59:16 +0100 Subject: Pass PHPStan level 8 (#5946) * Pass PHPStan level 8 And prepare for PHPStan level 9 https://phpstan.org/user-guide/rule-levels * Revert wrong replace in comment * Fix PHPStan level 8 * Update PHPStan and other dev dependencies * Remove obsolete comment * noVariableVariables and towards bleedingEdge https://github.com/phpstan/phpstan-strict-rules https://phpstan.org/blog/what-is-bleeding-edge * More bleedingEdge * A bit more PHPStan level 9 * More PHPStan level 9 * Prepare for booleansInConditions Ignore int and null * Revert wrong line * More fixes * Fix keep_max_n_unread * Stricter attribute functions * Stricter callHooks and more PHPStan level 9 * More typing * A tiny more --- app/views/index/about.phtml | 4 ++-- app/views/index/global.phtml | 6 +++--- app/views/index/normal.phtml | 35 +++++++++++++++++++---------------- app/views/index/reader.phtml | 28 ++++++++++++++-------------- app/views/index/rss.phtml | 2 +- 5 files changed, 39 insertions(+), 36 deletions(-) (limited to 'app/views/index') diff --git a/app/views/index/about.phtml b/app/views/index/about.phtml index 5ee1729cd..1c41cf4d6 100644 --- a/app/views/index/about.phtml +++ b/app/views/index/about.phtml @@ -33,8 +33,8 @@ environment; - if ($env !== 'production' && FreshRSS_Context::$user_conf->is_admin) { ?> + $env = FreshRSS_Context::systemConf()->environment; + if ($env !== 'production' && FreshRSS_Context::userConf()->is_admin) { ?>

data/config.php

'environment' => ''
hide_read_feeds && + if (FreshRSS_Context::userConf()->hide_read_feeds && FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_NOT_READ) && !FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_READ)) { $class = ' state_unread'; @@ -62,7 +62,7 @@ ?>
  • - show_favicons): ?>✇ + show_favicons): ?>✇ name() ?>
  • @@ -82,6 +82,6 @@
    -
    display_posts ? '' : ' class="hide_posts"' ?>> +
    display_posts ? '' : ' class="hide_posts"' ?>>
    diff --git a/app/views/index/normal.phtml b/app/views/index/normal.phtml index 0d484f518..42c2e0072 100644 --- a/app/views/index/normal.phtml +++ b/app/views/index/normal.phtml @@ -11,10 +11,10 @@ call_user_func($this->callbackBeforeEntries, $this); $display_today = true; $display_yesterday = true; $display_others = true; -$hidePosts = !FreshRSS_Context::$user_conf->display_posts; -$lazyload = FreshRSS_Context::$user_conf->lazyload; -$content_width = FreshRSS_Context::$user_conf->content_width; -$MAX_TAGS_DISPLAYED = FreshRSS_Context::$user_conf->show_tags_max; +$hidePosts = !FreshRSS_Context::userConf()->display_posts; +$lazyload = FreshRSS_Context::userConf()->lazyload; +$content_width = FreshRSS_Context::userConf()->content_width; +$MAX_TAGS_DISPLAYED = FreshRSS_Context::userConf()->show_tags_max; $useKeepUnreadImportant = !FreshRSS_Context::isImportant() && !FreshRSS_Context::isFeed(); $today = @strtotime('today'); @@ -74,12 +74,15 @@ $today = @strtotime('today'); ?>" data-priority="feed->priority() ?>">renderHelper('index/normal/entry_header'); + if ($this->feed === null) { + throw new FreshRSS_Context_Exception('Feed not initialised!'); + } $tags = null; $firstTags = array(); $remainingTags = array(); - if (FreshRSS_Context::$user_conf->show_tags === 'h' || FreshRSS_Context::$user_conf->show_tags === 'f' || FreshRSS_Context::$user_conf->show_tags === 'b') { + if (FreshRSS_Context::userConf()->show_tags === 'h' || FreshRSS_Context::userConf()->show_tags === 'f' || FreshRSS_Context::userConf()->show_tags === 'b') { $tags = $this->entry->tags(); if (!empty($tags)) { if ($MAX_TAGS_DISPLAYED > 0) { @@ -93,14 +96,14 @@ $today = @strtotime('today'); ?>
    - show_feed_name === 't') { ?> + show_feed_name === 't') { ?> - show_tags === 'h' || FreshRSS_Context::$user_conf->show_tags === 'b') { ?> + show_tags === 'h' || FreshRSS_Context::userConf()->show_tags === 'b') { ?>

    entry->title() ?>

    - show_author_date === 'h' || FreshRSS_Context::$user_conf->show_author_date === 'b') { ?> + show_author_date === 'h' || FreshRSS_Context::userConf()->show_author_date === 'b') { ?>
    - show_feed_name === 'a') { ?> + show_feed_name === 'a') { ?> @@ -164,8 +167,8 @@ $today = @strtotime('today'); echo $lazyload && $hidePosts ? lazyimg($this->entry->content(true)) : $this->entry->content(true); ?>
    show_author_date === 'f' || FreshRSS_Context::$user_conf->show_author_date === 'b'; - $display_tags = FreshRSS_Context::$user_conf->show_tags === 'f' || FreshRSS_Context::$user_conf->show_tags === 'b'; + $display_authors_date = FreshRSS_Context::userConf()->show_author_date === 'f' || FreshRSS_Context::userConf()->show_author_date === 'b'; + $display_tags = FreshRSS_Context::userConf()->show_tags === 'f' || FreshRSS_Context::userConf()->show_tags === 'b'; if ($display_authors_date || $display_tags) { ?> @@ -173,9 +176,9 @@ $today = @strtotime('today');
    - show_feed_name === 'a') { ?> + show_feed_name === 'a') { ?> @@ -266,4 +269,4 @@ $today = @strtotime('today'); - 0 && FreshRSS_Context::$user_conf->show_nav_buttons) $this->partial('nav_entries'); ?> + 0 && FreshRSS_Context::userConf()->show_nav_buttons) $this->partial('nav_entries'); ?> diff --git a/app/views/index/reader.phtml b/app/views/index/reader.phtml index dc90a144a..f2d7ab46b 100644 --- a/app/views/index/reader.phtml +++ b/app/views/index/reader.phtml @@ -8,9 +8,9 @@ if (!Minz_Request::paramBoolean('ajax')) { call_user_func($this->callbackBeforeEntries, $this); -$lazyload = FreshRSS_Context::$user_conf->lazyload; -$content_width = FreshRSS_Context::$user_conf->content_width; -$MAX_TAGS_DISPLAYED = FreshRSS_Context::$user_conf->show_tags_max; +$lazyload = FreshRSS_Context::userConf()->lazyload; +$content_width = FreshRSS_Context::userConf()->content_width; +$MAX_TAGS_DISPLAYED = FreshRSS_Context::userConf()->show_tags_max; ?>

    @@ -35,7 +35,7 @@ $MAX_TAGS_DISPLAYED = FreshRSS_Context::$user_conf->show_tags_max; $firstTags = array(); $remainingTags = array(); - if (FreshRSS_Context::$user_conf->show_tags == 'h' || FreshRSS_Context::$user_conf->show_tags == 'f' || FreshRSS_Context::$user_conf->show_tags == 'b') { + if (FreshRSS_Context::userConf()->show_tags == 'h' || FreshRSS_Context::userConf()->show_tags == 'f' || FreshRSS_Context::userConf()->show_tags == 'b') { $tags = $this->entry->tags(); if (!empty($tags)) { if ($MAX_TAGS_DISPLAYED > 0) { @@ -69,15 +69,15 @@ $MAX_TAGS_DISPLAYED = FreshRSS_Context::$user_conf->show_tags_max; isRead() ? 'read' : 'unread') ?> isFavorite() ? 'starred' : 'non-starred') ?> - show_feed_name === 't') { ?> + show_feed_name === 't') { ?> - show_favicons): ?> + show_favicons): ?> ✇name() ?>
    - show_tags === 'h' || FreshRSS_Context::$user_conf->show_tags === 'b') { ?> + show_tags === 'h' || FreshRSS_Context::userConf()->show_tags === 'b') { ?>
    show_tags_max;

    title() ?>

    - show_author_date === 'h' || FreshRSS_Context::$user_conf->show_author_date === 'b') { ?> + show_author_date === 'h' || FreshRSS_Context::userConf()->show_author_date === 'b') { ?>
    - show_feed_name === 'a') { ?> + show_feed_name === 'a') { ?> @@ -141,17 +141,17 @@ $MAX_TAGS_DISPLAYED = FreshRSS_Context::$user_conf->show_tags_max; content(true) ?>
    show_author_date === 'f' || FreshRSS_Context::$user_conf->show_author_date === 'b'; - $display_tags = FreshRSS_Context::$user_conf->show_tags === 'f' || FreshRSS_Context::$user_conf->show_tags === 'b'; + $display_authors_date = FreshRSS_Context::userConf()->show_author_date === 'f' || FreshRSS_Context::userConf()->show_author_date === 'b'; + $display_tags = FreshRSS_Context::userConf()->show_tags === 'f' || FreshRSS_Context::userConf()->show_tags === 'b'; if ($display_authors_date || $display_tags) { ?>