diff options
| author | 2024-06-09 20:32:12 +0200 | |
|---|---|---|
| committer | 2024-06-09 20:32:12 +0200 | |
| commit | 5b28a35003a015e29770094932157f13a3f7f5c0 (patch) | |
| tree | 4cbe4100379ca0d148115ad31f5a1c0c95ff7c80 /app/views | |
| parent | e98c57841b843ed881f06ce6ed1c9c89942c27b8 (diff) | |
Pass PHPStan level 9 (#6544)
* More PHPStan
* More, passing
* 4 more files
* Update to PHPStan 1.11.4
Needed for fixed bug: Consider numeric-string types after string concat
https://github.com/phpstan/phpstan/releases/tag/1.11.4
* Pass PHPStan level 9
Start tracking booleansInConditions
* Fix mark as read
* Fix doctype
* ctype_digit
Diffstat (limited to 'app/views')
| -rw-r--r-- | app/views/helpers/feed/update.phtml | 26 | ||||
| -rw-r--r-- | app/views/helpers/index/article.phtml | 4 | ||||
| -rw-r--r-- | app/views/helpers/index/normal/entry_bottom.phtml | 8 | ||||
| -rw-r--r-- | app/views/helpers/index/normal/entry_header.phtml | 8 | ||||
| -rw-r--r-- | app/views/helpers/stream-footer.phtml | 12 | ||||
| -rw-r--r-- | app/views/javascript/actualize.phtml | 14 | ||||
| -rw-r--r-- | app/views/user/profile.phtml | 4 |
7 files changed, 37 insertions, 39 deletions
diff --git a/app/views/helpers/feed/update.phtml b/app/views/helpers/feed/update.phtml index 0d9252910..8390fa6bf 100644 --- a/app/views/helpers/feed/update.phtml +++ b/app/views/helpers/feed/update.phtml @@ -421,6 +421,7 @@ <fieldset id="html_xpath"> <?php + /** @var array<string> $xpath */ $xpath = Minz_Helper::htmlspecialchars_utf8($this->feed->attributeArray('xpath') ?? []); ?> <p class="help"><?= _i('help') ?> <?= _t('sub.feed.kind.html_xpath.help') ?></p> @@ -516,6 +517,7 @@ <fieldset id="json_dotnotation"> <?php + /** @var array<string,string> $jsonSettings */ $jsonSettings = Minz_Helper::htmlspecialchars_utf8($this->feed->attributeArray('json_dotnotation') ?? []); ?> <p class="help"><?= _i('help') ?> <?= _t('sub.feed.kind.json_dotnotation.help') ?></p> @@ -634,17 +636,19 @@ </div> <div class="form-group"> + <?php + /** @var array<int,int|string> $curlParams */ + $curlParams = $this->feed->attributeArray('curl_params') ?? []; + ?> <label class="group-name" for="curl_params_cookie"><?= _t('sub.feed.css_cookie') ?></label> <div class="group-controls"> <input type="text" name="curl_params_cookie" id="curl_params_cookie" class="w100" value="<?= - $this->feed->attributeArray('curl_params') !== null && !empty($this->feed->attributeArray('curl_params')[CURLOPT_COOKIE]) ? - $this->feed->attributeArray('curl_params')[CURLOPT_COOKIE] : '' + !empty($curlParams[CURLOPT_COOKIE]) ? $curlParams[CURLOPT_COOKIE] : '' ?>" placeholder="<?= _t('gen.short.blank_to_disable') ?>" /> <p class="help"><?= _i('help') ?> <?= _t('sub.feed.css_cookie_help') ?></p> <label for="curl_params_cookiefile"> <input type="checkbox" name="curl_params_cookiefile" id="curl_params_cookiefile" value="1"<?= - $this->feed->attributeArray('curl_params') !== null && isset($this->feed->attributeArray('curl_params')[CURLOPT_COOKIEFILE]) ? - ' checked="checked"' : '' + isset($curlParams[CURLOPT_COOKIEFILE]) ? ' checked="checked"' : '' ?> /> <?= _t('sub.feed.accept_cookies') ?> </label> @@ -656,8 +660,7 @@ <label class="group-name" for="curl_params_redirects"><?= _t('sub.feed.max_http_redir') ?></label> <div class="group-controls"> <input type="number" name="curl_params_redirects" id="curl_params_redirects" class="w50" min="-1" value="<?= - $this->feed->attributeArray('curl_params') !== null && !empty($this->feed->attributeArray('curl_params')[CURLOPT_MAXREDIRS]) ? - $this->feed->attributeArray('curl_params')[CURLOPT_MAXREDIRS] : '' + !empty($curlParams[CURLOPT_MAXREDIRS]) ? $curlParams[CURLOPT_MAXREDIRS] : '' ?>" placeholder="<?= _t('gen.short.blank_to_disable') ?>" /> <p class="help"><?= _i('help') ?> <?= _t('sub.feed.max_http_redir_help') ?></p> </div> @@ -678,8 +681,7 @@ <label class="group-name" for="curl_params_useragent"><?= _t('sub.feed.useragent') ?></label> <div class="group-controls"> <input type="text" name="curl_params_useragent" id="curl_params_useragent" class="w100" value="<?= - $this->feed->attributeArray('curl_params') !== null && !empty($this->feed->attributeArray('curl_params')[CURLOPT_USERAGENT]) ? - $this->feed->attributeArray('curl_params')[CURLOPT_USERAGENT] : '' + !empty($curlParams[CURLOPT_USERAGENT]) ? $curlParams[CURLOPT_USERAGENT] : '' ?>" placeholder="<?= _t('gen.short.blank_to_disable') ?>" /> <p class="help"><?= _i('help') ?> <?= _t('sub.feed.useragent_help') ?></p> </div> @@ -689,18 +691,14 @@ <label class="group-name" for="proxy_type"><?= _t('sub.feed.proxy') ?></label> <div class="group-controls"> <select name="proxy_type" id="proxy_type"><?php - $type = ''; - if ($this->feed->attributeArray('curl_params') !== null && isset($this->feed->attributeArray('curl_params')[CURLOPT_PROXYTYPE])) { - $type = $this->feed->attributeArray('curl_params')[CURLOPT_PROXYTYPE]; - } + $type = $curlParams[CURLOPT_PROXYTYPE] ?? ''; foreach(['' => '', 3 => 'NONE', 0 => 'HTTP', 2 => 'HTTPS', 4 => 'SOCKS4', 6 => 'SOCKS4A', 5 => 'SOCKS5', 7 => 'SOCKS5H'] as $k => $v) { echo '<option value="' . $k . ($type === $k ? '" selected="selected' : '' ) . '">' . $v . '</option>'; } ?> </select> <input type="text" name="curl_params" id="curl_params" value="<?= - $this->feed->attributeArray('curl_params') !== null && !empty($this->feed->attributeArray('curl_params')[CURLOPT_PROXY]) ? - $this->feed->attributeArray('curl_params')[CURLOPT_PROXY] : '' + !empty($curlParams[CURLOPT_PROXY]) ? $curlParams[CURLOPT_PROXY] : '' ?>" placeholder="<?= _t('gen.short.blank_to_disable') ?>" /> <p class="help"><?= _i('help') ?> <?= _t('sub.feed.proxy_help') ?></p> </div> diff --git a/app/views/helpers/index/article.phtml b/app/views/helpers/index/article.phtml index 56fd06b4f..bfdfdb8d1 100644 --- a/app/views/helpers/index/article.phtml +++ b/app/views/helpers/index/article.phtml @@ -10,11 +10,11 @@ <?php $favoriteUrl = ['c' => 'entry', 'a' => 'bookmark', 'params' => ['id' => $entry->id()]]; if ($entry->isFavorite()) { - $favoriteUrl['params']['is_favorite'] = 0; + $favoriteUrl['params']['is_favorite'] = '0'; } $readUrl = ['c' => 'entry', 'a' => 'read', 'params' => ['id' => $entry->id()]]; if ($entry->isRead()) { - $readUrl['params']['is_read'] = 0; + $readUrl['params']['is_read'] = '0'; } ?> <div class="article-header-topline"> diff --git a/app/views/helpers/index/normal/entry_bottom.phtml b/app/views/helpers/index/normal/entry_bottom.phtml index e5bfd7fd0..21bd1d355 100644 --- a/app/views/helpers/index/normal/entry_bottom.phtml +++ b/app/views/helpers/index/normal/entry_bottom.phtml @@ -12,9 +12,9 @@ if (FreshRSS_Auth::hasAccess()) { if ($bottomline_read) { ?><li class="item manage"><?php - $arUrl = array('c' => 'entry', 'a' => 'read', 'params' => array('id' => $this->entry->id())); + $arUrl = ['c' => 'entry', 'a' => 'read', 'params' => ['id' => $this->entry->id()]]; if ($this->entry->isRead()) { - $arUrl['params']['is_read'] = 0; + $arUrl['params']['is_read'] = '0'; } ?><a class="item-element read" href="<?= Minz_Url::display($arUrl) ?>" title="<?= _t('conf.shortcut.mark_read') ?>"><?php echo _i($this->entry->isRead() ? 'read' : 'unread'); ?></a><?php @@ -22,9 +22,9 @@ } if ($bottomline_favorite) { ?><li class="item manage"><?php - $arUrl = array('c' => 'entry', 'a' => 'bookmark', 'params' => array('id' => $this->entry->id())); + $arUrl = ['c' => 'entry', 'a' => 'bookmark', 'params' => ['id' => $this->entry->id()]]; if ($this->entry->isFavorite()) { - $arUrl['params']['is_favorite'] = 0; + $arUrl['params']['is_favorite'] = '0'; } ?><a class="item-element bookmark" href="<?= Minz_Url::display($arUrl) ?>" title="<?= _t('conf.shortcut.mark_favorite') ?>"><?php echo _i($this->entry->isFavorite() ? 'starred' : 'non-starred'); ?></a><?php diff --git a/app/views/helpers/index/normal/entry_header.phtml b/app/views/helpers/index/normal/entry_header.phtml index 0db375309..e4befb346 100644 --- a/app/views/helpers/index/normal/entry_header.phtml +++ b/app/views/helpers/index/normal/entry_header.phtml @@ -14,9 +14,9 @@ if (FreshRSS_Auth::hasAccess()) { if ($topline_read) { ?><li class="item manage"><?php - $arUrl = array('c' => 'entry', 'a' => 'read', 'params' => array('id' => $this->entry->id())); + $arUrl = ['c' => 'entry', 'a' => 'read', 'params' => ['id' => $this->entry->id()]]; if ($this->entry->isRead()) { - $arUrl['params']['is_read'] = 0; + $arUrl['params']['is_read'] = '0'; } ?><a class="item-element read" href="<?= Minz_Url::display($arUrl) ?>" title="<?= _t('conf.shortcut.mark_read') ?>"><?php echo _i($this->entry->isRead() ? 'read' : 'unread'); ?></a><?php @@ -24,9 +24,9 @@ } if ($topline_favorite) { ?><li class="item manage"><?php - $arUrl = array('c' => 'entry', 'a' => 'bookmark', 'params' => array('id' => $this->entry->id())); + $arUrl = ['c' => 'entry', 'a' => 'bookmark', 'params' => ['id' => $this->entry->id()]]; if ($this->entry->isFavorite()) { - $arUrl['params']['is_favorite'] = 0; + $arUrl['params']['is_favorite'] = '0'; } ?><a class="item-element bookmark" href="<?= Minz_Url::display($arUrl) ?>" title="<?= _t('conf.shortcut.mark_favorite') ?>"><?php echo _i($this->entry->isFavorite() ? 'starred' : 'non-starred'); ?></a><?php diff --git a/app/views/helpers/stream-footer.phtml b/app/views/helpers/stream-footer.phtml index 0cbab601a..9681cff02 100644 --- a/app/views/helpers/stream-footer.phtml +++ b/app/views/helpers/stream-footer.phtml @@ -3,20 +3,20 @@ /** @var FreshRSS_View $this */ $url_next = Minz_Request::currentRequest(); $url_next['params']['next'] = FreshRSS_Context::$next_id; - $url_next['params']['state'] = FreshRSS_Context::$state; - $url_next['params']['ajax'] = 1; + $url_next['params']['state'] = (string)FreshRSS_Context::$state; + $url_next['params']['ajax'] = '1'; - $url_mark_read = array( + $url_mark_read = [ 'c' => 'entry', 'a' => 'read', - 'params' => array( + 'params' => [ 'get' => FreshRSS_Context::currentGet(), 'nextGet' => FreshRSS_Context::$next_get, 'idMax' => FreshRSS_Context::$id_max, 'search' => htmlspecialchars_decode(FreshRSS_Context::$search->getRawInput(), ENT_QUOTES), 'state' => FreshRSS_Context::$state, - ) - ); + ], + ]; $hasAccess = FreshRSS_Auth::hasAccess(); if ($hasAccess) { diff --git a/app/views/javascript/actualize.phtml b/app/views/javascript/actualize.phtml index bce316d85..314f83012 100644 --- a/app/views/javascript/actualize.phtml +++ b/app/views/javascript/actualize.phtml @@ -5,21 +5,21 @@ declare(strict_types=1); $categories = []; foreach ($this->categories as $category) { $categories[] = [ - 'url' => Minz_Url::display(array('c' => 'category', 'a' => 'refreshOpml', 'params' => array('id' => $category->id(), 'ajax' => '1')), 'php'), + 'url' => Minz_Url::display(['c' => 'category', 'a' => 'refreshOpml', 'params' => ['id' => $category->id(), 'ajax' => '1']], 'php'), 'title' => $category->name(), ]; } -$feeds = array(); +$feeds = []; foreach ($this->feeds as $feed) { - $feeds[] = array( - 'url' => Minz_Url::display(array('c' => 'feed', 'a' => 'actualize', 'params' => array('id' => $feed->id(), 'ajax' => '1')), 'php'), + $feeds[] = [ + 'url' => Minz_Url::display(['c' => 'feed', 'a' => 'actualize', 'params' => ['id' => $feed->id(), 'ajax' => '1']], 'php'), 'title' => $feed->name(), - ); + ]; } -echo json_encode(array( +echo json_encode([ 'categories' => $categories, 'feeds' => $feeds, 'feedback_no_refresh' => _t('feedback.sub.feed.no_refresh'), 'feedback_actualize' => _t('feedback.sub.actualize'), -)); +]); diff --git a/app/views/user/profile.phtml b/app/views/user/profile.phtml index 3a80065ef..b2e8a7d7b 100644 --- a/app/views/user/profile.phtml +++ b/app/views/user/profile.phtml @@ -60,8 +60,8 @@ <div class="group-controls"> <input type="text" id="token" name="token" value="<?= $token ?>" placeholder="<?= _t('gen.short.blank_to_disable') ?>" data-leave-validation="<?= $token ?>"/> <p class="help"><?= _i('help') ?> <?= _t('admin.auth.token_help') ?></p> - <kbd><?= Minz_Url::display(array('a' => 'rss', 'params' => array('user' => Minz_User::name(), - 'token' => $token, 'hours' => FreshRSS_Context::userConf()->since_hours_posts_per_rss)), 'html', true) ?></kbd> + <kbd><?= Minz_Url::display(['a' => 'rss', 'params' => ['user' => Minz_User::name() ?? '', + 'token' => $token, 'hours' => FreshRSS_Context::userConf()->since_hours_posts_per_rss]], 'html', true) ?></kbd> <p class="help"><?= _i('help') ?> <?= _t('conf.query.help') ?></a></p> </div> </div> |
