diff options
| author | 2023-12-18 17:59:16 +0100 | |
|---|---|---|
| committer | 2023-12-18 17:59:16 +0100 | |
| commit | a80a5f48a16e7d232168a7aaa68e9a1804235ce1 (patch) | |
| tree | a515b88592629dea7e83b96e26e2452d3f98a98e /app/views/helpers/category | |
| parent | 6bb45a87268157aab961a6a4a728d9a9bbe043b0 (diff) | |
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
Diffstat (limited to 'app/views/helpers/category')
| -rw-r--r-- | app/views/helpers/category/update.phtml | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/app/views/helpers/category/update.phtml b/app/views/helpers/category/update.phtml index 68132ad27..36c0abfe8 100644 --- a/app/views/helpers/category/update.phtml +++ b/app/views/helpers/category/update.phtml @@ -1,6 +1,9 @@ <?php declare(strict_types=1); /** @var FreshRSS_View $this */ + if ($this->category === null) { + throw new FreshRSS_Context_Exception('Category not initialised!'); + } ?> <div class="post"> <h2> @@ -28,7 +31,7 @@ <div class="form-group"> <label class="group-name" for="position"><?= _t('sub.category.position') ?></label> <div class="group-controls"> - <input type="number" name="position" id="position" min="1" value="<?= $this->category->attributes('position') ?>" /> + <input type="number" name="position" id="position" min="1" value="<?= $this->category->attributeInt('position') ?>" /> <p class="help"><?= _i('help') ?> <?= _t('sub.category.position_help') ?></p> </div> </div> @@ -46,7 +49,7 @@ <label class="group-name" for="opml_url"><?= _t('sub.category.opml_url') ?></label> <div class="group-controls"> <div class="stick"> - <input id="opml_url" name="opml_url" type="url" autocomplete="off" class="long" data-disable-update="refreshOpml" value="<?= $this->category->attributes('opml_url') ?>" /> + <input id="opml_url" name="opml_url" type="url" autocomplete="off" class="long" data-disable-update="refreshOpml" value="<?= $this->category->attributeString('opml_url') ?>" /> <button type="submit" class="btn" id="refreshOpml" formmethod="post" formaction="<?= _url('category', 'refreshOpml', 'id', $this->category->id()) ?>"> <?= _i('refresh') ?> <?= _t('gen.action.refresh_opml') ?> </button> @@ -90,7 +93,8 @@ <legend><?= _t('sub.category.archiving') ?></legend> <?php - $archiving = $this->category->attributes('archiving'); + $archiving = $this->category->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 { @@ -101,7 +105,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<count>\d+)[YMWDH]$/', $archiving['keep_period'], $matches)) { $volatile['enable_keep_period'] = true; $volatile['keep_period_count'] = $matches['count']; @@ -109,21 +113,21 @@ } } //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_favourites'])) { + if (!isset($archiving['keep_min']) || !is_int($archiving['keep_min'])) { + $archiving['keep_min'] = 50; + } + 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; } - if (!isset($archiving['keep_min'])) { - $archiving['keep_min'] = 50; - } ?> <p class="alert alert-warn"> |
