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/helpers/feed/update.phtml | 97 ++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 45 deletions(-) (limited to 'app/views/helpers/feed') diff --git a/app/views/helpers/feed/update.phtml b/app/views/helpers/feed/update.phtml index af2503256..5d4f1cc4b 100644 --- a/app/views/helpers/feed/update.phtml +++ b/app/views/helpers/feed/update.phtml @@ -1,6 +1,9 @@ feed === null) { + throw new FreshRSS_Context_Exception('Feed not initialised!'); + } ?>

feed->name() ?>

@@ -184,9 +187,9 @@
@@ -195,12 +198,12 @@
@@ -210,9 +213,9 @@
@@ -222,9 +225,9 @@
@@ -245,7 +248,10 @@
- +
@@ -267,7 +273,8 @@ feed->attributes('archiving'); + $archiving = $this->feed->attributeArray('archiving'); + /** @var array<'default'?:bool,'keep_period'?:string,'keep_max'?:int,'keep_min'?:int,'keep_favourites'?:bool,'keep_labels'?:bool,'keep_unreads'?:bool>|null $archiving */ if (empty($archiving)) { $archiving = [ 'default' => true ]; } else { @@ -278,7 +285,7 @@ 'keep_period_count' => '3', 'keep_period_unit' => 'P1M', ]; - if (!empty($archiving['keep_period'])) { + if (!empty($archiving['keep_period']) && is_string($archiving['keep_period'])) { if (preg_match('/^PT?(?P\d+)[YMWDH]$/', $archiving['keep_period'], $matches)) { $volatile['enable_keep_period'] = true; $volatile['keep_period_count'] = $matches['count']; @@ -286,19 +293,19 @@ } } //Defaults - if (!isset($archiving['keep_max'])) { - $archiving['keep_max'] = false; + if (!isset($archiving['keep_max']) || !is_int($archiving['keep_max'])) { + $archiving['keep_max'] = 0; } - if (!isset($archiving['keep_min'])) { + if (!isset($archiving['keep_min']) || !is_int($archiving['keep_min'])) { $archiving['keep_min'] = 50; } - if (!isset($archiving['keep_favourites'])) { + if (!isset($archiving['keep_favourites']) || !is_bool($archiving['keep_favourites'])) { $archiving['keep_favourites'] = true; } - if (!isset($archiving['keep_labels'])) { + if (!isset($archiving['keep_labels']) || !is_bool($archiving['keep_labels'])) { $archiving['keep_labels'] = true; } - if (!isset($archiving['keep_unreads'])) { + if (!isset($archiving['keep_unreads']) || !is_bool($archiving['keep_unreads'])) { $archiving['keep_unreads'] = false; } ?> @@ -406,7 +413,7 @@
feed->attributes('xpath'))); + $xpath = Minz_Helper::htmlspecialchars_utf8($this->feed->attributeArray('xpath') ?? []); ?>

@@ -521,7 +528,7 @@
feed->attributes('path_entries_filter'))); + $path_entries_filter = Minz_Helper::htmlspecialchars_utf8($this->feed->attributeString('path_entries_filter') ?? ''); ?>
@@ -537,13 +544,13 @@

@@ -578,8 +585,8 @@

@@ -590,8 +597,8 @@

@@ -609,7 +616,7 @@
- +
@@ -617,9 +624,9 @@
@@ -627,7 +634,7 @@
-- cgit v1.2.3