diff options
| author | 2024-09-11 17:14:53 +0200 | |
|---|---|---|
| committer | 2024-09-11 17:14:53 +0200 | |
| commit | dfac9f5813df7d4c7c812c381364c8898333f559 (patch) | |
| tree | 978496d0a8d8b0d6b5dbe836c6829296133b337c /app/views | |
| parent | 31c8846791d4b5316fbc790202f79545c012f9c2 (diff) | |
PHPStan booleansInConditions (#6793)
* PHPStan booleansInConditions
* Uniformisation
Diffstat (limited to 'app/views')
| -rw-r--r-- | app/views/configure/archiving.phtml | 4 | ||||
| -rw-r--r-- | app/views/configure/queries.phtml | 4 | ||||
| -rw-r--r-- | app/views/configure/query.phtml | 2 | ||||
| -rw-r--r-- | app/views/helpers/feed/update.phtml | 3 | ||||
| -rw-r--r-- | app/views/helpers/index/article.phtml | 9 | ||||
| -rw-r--r-- | app/views/helpers/index/normal/entry_bottom.phtml | 3 | ||||
| -rw-r--r-- | app/views/helpers/index/normal/entry_header.phtml | 3 | ||||
| -rw-r--r-- | app/views/helpers/index/tags.phtml | 3 | ||||
| -rw-r--r-- | app/views/helpers/stream-footer.phtml | 2 | ||||
| -rw-r--r-- | app/views/index/normal.phtml | 11 | ||||
| -rw-r--r-- | app/views/stats/repartition.phtml | 4 | ||||
| -rw-r--r-- | app/views/subscription/feed.phtml | 2 |
12 files changed, 37 insertions, 13 deletions
diff --git a/app/views/configure/archiving.phtml b/app/views/configure/archiving.phtml index 86b8246e3..7ab8a2d9a 100644 --- a/app/views/configure/archiving.phtml +++ b/app/views/configure/archiving.phtml @@ -59,8 +59,8 @@ <div class="group-controls"> <label class="checkbox" for="enable_keep_period"> <input type="checkbox" name="enable_keep_period" id="enable_keep_period" value="1"<?= - FreshRSS_Context::userConf()->volatile['enable_keep_period'] ? ' checked="checked"' : '' ?> - data-leave-validation="<?= FreshRSS_Context::userConf()->volatile['enable_keep_period'] ? 1 : 0 ?>"/> + empty(FreshRSS_Context::userConf()->volatile['enable_keep_period']) ? '' : ' checked="checked"' ?> + data-leave-validation="<?= empty(FreshRSS_Context::userConf()->volatile['enable_keep_period']) ? 0 : 1 ?>"/> <?= _t('conf.archiving.keep_period') ?> <input type="number" id="keep_period_count" name="keep_period_count" min="0" value="<?= FreshRSS_Context::userConf()->volatile['keep_period_count'] ?>" data-leave-validation="<?= FreshRSS_Context::userConf()->volatile['keep_period_count'] ?>"/> diff --git a/app/views/configure/queries.phtml b/app/views/configure/queries.phtml index 26534307e..d085016fb 100644 --- a/app/views/configure/queries.phtml +++ b/app/views/configure/queries.phtml @@ -49,11 +49,11 @@ <li class="item"><?= _t('conf.query.state_' . $query->getState()) ?></li> <?php } ?> - <?php if ($query->getOrder()) { ?> + <?php if ($query->getOrder() !== '') { ?> <li class="item"><?= _t('conf.query.order_' . strtolower($query->getOrder())) ?></li> <?php } ?> - <?php if ($query->getGet()) { ?> + <?php if ($query->getGet() !== '') { ?> <li class="item"><?= _t('conf.query.get_' . $query->getGetType(), $query->getGetName()) ?></li> <?php } ?> <?php } ?> diff --git a/app/views/configure/query.phtml b/app/views/configure/query.phtml index e45820fbc..51051b98a 100644 --- a/app/views/configure/query.phtml +++ b/app/views/configure/query.phtml @@ -5,6 +5,6 @@ declare(strict_types=1); if (!Minz_Request::paramBoolean('ajax')) { $this->partial('aside_configure'); } -if ($this->query) { +if ($this->query !== null) { $this->renderHelper('configure/query'); } diff --git a/app/views/helpers/feed/update.phtml b/app/views/helpers/feed/update.phtml index 93a528532..7f0be0f0c 100644 --- a/app/views/helpers/feed/update.phtml +++ b/app/views/helpers/feed/update.phtml @@ -1,6 +1,9 @@ <?php declare(strict_types=1); /** @var FreshRSS_View $this */ + if ($this->feed === null) { + return; + } ?> <div class="post" id="feed_update"> <h1><?= $this->feed->name() ?></h1> diff --git a/app/views/helpers/index/article.phtml b/app/views/helpers/index/article.phtml index bdc108f1e..0a9c75bcd 100644 --- a/app/views/helpers/index/article.phtml +++ b/app/views/helpers/index/article.phtml @@ -4,6 +4,9 @@ /** @var FreshRSS_View $this */ $entry = $this->entry; $feed = $this->feed; + if ($feed === null || $entry === null) { + return; + } ?> <article class="flux_content" dir="auto"> <div class="content <?= FreshRSS_Context::userConf()->content_width ?>"> @@ -29,7 +32,7 @@ <div class="item manage"> <a class="bookmark" href="<?= Minz_Url::display($favoriteUrl) ?>" title="<?= _t('conf.shortcut.mark_favorite') ?>"><?= _i($entry->isFavorite() ? 'starred' : 'non-starred') ?></a> </div> - <?php } ?> + <?php } ?> <?php } ?> <div class="item"> <?php if (FreshRSS_Context::userConf()->show_feed_name === 't') { ?> @@ -42,7 +45,7 @@ <?php if (FreshRSS_Context::userConf()->topline_link && FreshRSS_Context::userConf()->show_article_icons == 't') { ?> <div class="item link"> - <a target="_blank" rel="noreferrer" href="<?= $this->entry->link() ?>" class="item-element" title="<?= _t('conf.shortcut.see_on_website') ?>"><?= _i('link') ?></a> + <a target="_blank" rel="noreferrer" href="<?= $entry->link() ?>" class="item-element" title="<?= _t('conf.shortcut.see_on_website') ?>"><?= _i('link') ?></a> </div> <?php } ?> </div> @@ -93,7 +96,7 @@ <?php if (FreshRSS_Context::userConf()->topline_link && FreshRSS_Context::userConf()->show_article_icons == 'a') { ?> <div class="item link"> - <a target="_blank" rel="noreferrer" href="<?= $this->entry->link() ?>" class="item-element" title="<?= _t('conf.shortcut.see_on_website') ?>"><?= _i('link') ?></a> + <a target="_blank" rel="noreferrer" href="<?= $entry->link() ?>" class="item-element" title="<?= _t('conf.shortcut.see_on_website') ?>"><?= _i('link') ?></a> </div> <?php } ?> </div> diff --git a/app/views/helpers/index/normal/entry_bottom.phtml b/app/views/helpers/index/normal/entry_bottom.phtml index 1de8395bc..51c103a74 100644 --- a/app/views/helpers/index/normal/entry_bottom.phtml +++ b/app/views/helpers/index/normal/entry_bottom.phtml @@ -1,6 +1,9 @@ <?php declare(strict_types=1); /** @var FreshRSS_View $this */ + if ($this->entry === null) { + return; + } $bottomline_read = FreshRSS_Context::userConf()->bottomline_read; $bottomline_favorite = FreshRSS_Context::userConf()->bottomline_favorite; $bottomline_sharing = FreshRSS_Context::userConf()->bottomline_sharing && (count(FreshRSS_Context::userConf()->sharing) > 0); diff --git a/app/views/helpers/index/normal/entry_header.phtml b/app/views/helpers/index/normal/entry_header.phtml index ecaf0f0d6..a2f8d00fc 100644 --- a/app/views/helpers/index/normal/entry_header.phtml +++ b/app/views/helpers/index/normal/entry_header.phtml @@ -11,6 +11,9 @@ $topline_date = FreshRSS_Context::userConf()->topline_date; $topline_link = FreshRSS_Context::userConf()->topline_link; $lazyload = FreshRSS_Context::userConf()->lazyload; + if ($this->feed === null || $this->entry === null) { + return; + } ?><ul class="horizontal-list flux_header website<?= $topline_website ?>" data-website-name="<?= $this->feed->name() ?>" data-article-authors="<?= implode(', ', $this->entry->authors()) ?>"><?php if (FreshRSS_Auth::hasAccess()) { if ($topline_read) { diff --git a/app/views/helpers/index/tags.phtml b/app/views/helpers/index/tags.phtml index 8f67784dd..3308bd7e9 100644 --- a/app/views/helpers/index/tags.phtml +++ b/app/views/helpers/index/tags.phtml @@ -1,6 +1,9 @@ <?php declare(strict_types=1); /** @var FreshRSS_View $this */ + if ($this->entry === null) { + return; + } [$firstTags,$remainingTags] = $this->entry->tagsFormattingHelper(); ?> <div class="tags"> diff --git a/app/views/helpers/stream-footer.phtml b/app/views/helpers/stream-footer.phtml index 9681cff02..bd6a8a880 100644 --- a/app/views/helpers/stream-footer.phtml +++ b/app/views/helpers/stream-footer.phtml @@ -27,7 +27,7 @@ <div id="stream-footer"> <?php }?> <div class="stream-footer-inner"> - <?php if (FreshRSS_Context::$next_id) { ?> + <?php if (FreshRSS_Context::$next_id !== '') { ?> <button id="load_more" type="submit" class="btn" formaction="<?= Minz_Url::display($url_next) ?>"><?= _t('gen.stream.load_more') ?></button> <?php } elseif ($hasAccess) { ?> <?= _t('gen.stream.nothing_to_load') ?><br /> diff --git a/app/views/index/normal.phtml b/app/views/index/normal.phtml index 40adc7f16..fe4af1a86 100644 --- a/app/views/index/normal.phtml +++ b/app/views/index/normal.phtml @@ -74,6 +74,9 @@ $today = @strtotime('today'); ?>" data-priority="<?= $this->feed->priority() ?>"><?php $this->renderHelper('index/normal/entry_header'); + if ($this->feed === null || $this->entry === null) { + throw new Exception('Unexpected side effect!'); // Should never occur. Only for PHPStan + } ?><article class="flux_content" dir="auto"> <div class="content <?= FreshRSS_Context::userConf()->content_width ?>"> <header> @@ -86,6 +89,9 @@ $today = @strtotime('today'); <?php } ?> <?php if (FreshRSS_Context::userConf()->show_tags === 'h' || FreshRSS_Context::userConf()->show_tags === 'b') { $this->renderHelper('index/tags'); + if ($this->feed === null || $this->entry === null) { + throw new Exception('Unexpected side effect!'); // Should never occur. Only for PHPStan + } } ?> <h1 class="title"><a target="_blank" rel="noreferrer" class="go_website" href="<?= $this->entry->link() ?>" title="<?= _t('conf.shortcut.see_on_website')?>"><?= $this->entry->title() ?></a></h1> <?php if (FreshRSS_Context::userConf()->show_author_date === 'h' || FreshRSS_Context::userConf()->show_author_date === 'b') { ?> @@ -196,4 +202,7 @@ $today = @strtotime('today'); <?= _i('close') ?> </a> -<?php if ($nbEntries > 0 && FreshRSS_Context::userConf()->show_nav_buttons) $this->partial('nav_entries'); ?> +<?php + if ($nbEntries > 0 && FreshRSS_Context::userConf()->show_nav_buttons) { + $this->partial('nav_entries'); + } diff --git a/app/views/stats/repartition.phtml b/app/views/stats/repartition.phtml index 030db0906..dd4ff9b29 100644 --- a/app/views/stats/repartition.phtml +++ b/app/views/stats/repartition.phtml @@ -17,7 +17,7 @@ if (!empty($feeds)) { echo '<optgroup label="', $category->name(), '">'; foreach ($feeds as $feed) { - if ($this->feed && $feed->id() == $this->feed->id()) { + if ($this->feed !== null && $feed->id() == $this->feed->id()) { echo '<option value="', $feed->id(), '" selected="selected" data-url="', _url('stats', 'repartition', 'id', $feed->id()), '">', $feed->name(), '</option>'; } else { @@ -30,7 +30,7 @@ }?> </select> - <?php if ($this->feed) {?> + <?php if ($this->feed !== null) {?> <a class="btn" href="<?= _url('subscription', 'feed', 'id', $this->feed->id()) ?>"> <?= _i('configure') ?> <?= _t('gen.action.manage') ?> </a> diff --git a/app/views/subscription/feed.phtml b/app/views/subscription/feed.phtml index 934e3c690..cbe91cd4d 100644 --- a/app/views/subscription/feed.phtml +++ b/app/views/subscription/feed.phtml @@ -6,7 +6,7 @@ if (!Minz_Request::paramBoolean('ajax')) { $this->partial('aside_subscription'); } -if ($this->feed) { +if ($this->feed !== null) { $this->renderHelper('feed/update'); } else { ?> |
