aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2023-05-11 13:02:04 +0200
committerGravatar GitHub <noreply@github.com> 2023-05-11 13:02:04 +0200
commit6e2f2f1c1e98ecd86aa89c6547beb742d7385d18 (patch)
tree7ba9f5aebb01d12045b9067a86b5060ba13dca18 /app
parentfe7d9bbcd68660a59b813346c236b61b25a51c80 (diff)
A few additional PHPStan rules (#5388)
A subset of https://github.com/phpstan/phpstan-strict-rules
Diffstat (limited to 'app')
-rw-r--r--app/Controllers/feedController.php2
-rw-r--r--app/Controllers/indexController.php9
-rw-r--r--app/Controllers/javascriptController.php5
-rw-r--r--app/Controllers/statsController.php23
-rw-r--r--app/Controllers/tagController.php6
-rw-r--r--app/Controllers/userController.php16
-rw-r--r--app/Mailers/UserMailer.php1
-rw-r--r--app/Models/ActionController.php1
-rw-r--r--app/Models/BooleanSearch.php12
-rw-r--r--app/Models/CategoryDAO.php6
-rw-r--r--app/Models/CategoryDAOSQLite.php2
-rw-r--r--app/Models/Context.php8
-rw-r--r--app/Models/DatabaseDAO.php4
-rw-r--r--app/Models/DatabaseDAOSQLite.php10
-rw-r--r--app/Models/Entry.php18
-rw-r--r--app/Models/EntryDAOSQLite.php2
-rw-r--r--app/Models/Feed.php8
-rw-r--r--app/Models/FeedDAO.php6
-rw-r--r--app/Models/FeedDAOSQLite.php2
-rw-r--r--app/Models/FormAuth.php2
-rw-r--r--app/Models/Search.php4
-rw-r--r--app/Models/Share.php6
-rw-r--r--app/Models/StatsDAO.php2
-rw-r--r--app/Models/TagDAO.php2
-rwxr-xr-xapp/actualize_script.php2
-rw-r--r--app/install.php6
-rw-r--r--app/layout/aside_feed.phtml4
-rw-r--r--app/layout/header.phtml2
-rw-r--r--app/layout/nav_menu.phtml2
-rw-r--r--app/views/auth/index.phtml2
-rwxr-xr-xapp/views/helpers/logs_pagination.phtml12
31 files changed, 87 insertions, 100 deletions
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php
index fc03f7224..c007c3050 100644
--- a/app/Controllers/feedController.php
+++ b/app/Controllers/feedController.php
@@ -348,7 +348,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
}
// Set maxFeeds to a minimum of 10
- if (!is_int($maxFeeds) || $maxFeeds < 10) {
+ if ($maxFeeds < 10) {
$maxFeeds = 10;
}
diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php
index 3f5c419f1..0e680934a 100644
--- a/app/Controllers/indexController.php
+++ b/app/Controllers/indexController.php
@@ -192,13 +192,8 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {
}
$get = FreshRSS_Context::currentGet(true);
- if (is_array($get)) {
- $type = $get[0];
- $id = (int)$get[1];
- } else {
- $type = $get;
- $id = 0;
- }
+ $type = (string)$get[0];
+ $id = (int)$get[1];
$catDAO = FreshRSS_Factory::createCategoryDao();
$categories = $catDAO->listCategories(true, true);
diff --git a/app/Controllers/javascriptController.php b/app/Controllers/javascriptController.php
index d3f73b2f9..eea8fc233 100644
--- a/app/Controllers/javascriptController.php
+++ b/app/Controllers/javascriptController.php
@@ -2,7 +2,10 @@
class FreshRSS_javascript_Controller extends FreshRSS_ActionController {
- /** @var FreshRSS_ViewJavascript */
+ /**
+ * @var FreshRSS_ViewJavascript
+ * @phpstan-ignore-next-line
+ */
protected $view;
public function __construct() {
diff --git a/app/Controllers/statsController.php b/app/Controllers/statsController.php
index d9c4fe5f4..3ce42dd2c 100644
--- a/app/Controllers/statsController.php
+++ b/app/Controllers/statsController.php
@@ -5,7 +5,10 @@
*/
class FreshRSS_stats_Controller extends FreshRSS_ActionController {
- /** @var FreshRSS_ViewStats */
+ /**
+ * @var FreshRSS_ViewStats
+ * @phpstan-ignore-next-line
+ */
protected $view;
public function __construct() {
@@ -57,7 +60,7 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController {
$this->view->repartitions = $statsDAO->calculateEntryRepartition();
$entryCount = $statsDAO->calculateEntryCount();
- if (is_array($entryCount) && count($entryCount) > 0) {
+ if (count($entryCount) > 0) {
$this->view->entryCount = $entryCount;
$this->view->average = round(array_sum(array_values($entryCount)) / count($entryCount), 2);
} else {
@@ -67,21 +70,17 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController {
$feedByCategory = [];
$feedByCategory_calculated = $statsDAO->calculateFeedByCategory();
- if (is_array($feedByCategory_calculated)) {
- for ($i = 0; $i < count($feedByCategory_calculated); $i++) {
- $feedByCategory['label'][$i] = $feedByCategory_calculated[$i]['label'];
- $feedByCategory['data'][$i] = $feedByCategory_calculated[$i]['data'];
- }
+ for ($i = 0; $i < count($feedByCategory_calculated); $i++) {
+ $feedByCategory['label'][$i] = $feedByCategory_calculated[$i]['label'];
+ $feedByCategory['data'][$i] = $feedByCategory_calculated[$i]['data'];
}
$this->view->feedByCategory = $feedByCategory;
$entryByCategory = [];
$entryByCategory_calculated = $statsDAO->calculateEntryByCategory();
- if (is_array($entryByCategory_calculated)) {
- for ($i = 0; $i < count($entryByCategory_calculated); $i++) {
- $entryByCategory['label'][$i] = $entryByCategory_calculated[$i]['label'];
- $entryByCategory['data'][$i] = $entryByCategory_calculated[$i]['data'];
- }
+ for ($i = 0; $i < count($entryByCategory_calculated); $i++) {
+ $entryByCategory['label'][$i] = $entryByCategory_calculated[$i]['label'];
+ $entryByCategory['data'][$i] = $entryByCategory_calculated[$i]['data'];
}
$this->view->entryByCategory = $entryByCategory;
diff --git a/app/Controllers/tagController.php b/app/Controllers/tagController.php
index c9dc7ce3e..eb259df12 100644
--- a/app/Controllers/tagController.php
+++ b/app/Controllers/tagController.php
@@ -96,12 +96,8 @@ class FreshRSS_tag_Controller extends FreshRSS_ActionController {
}
$name = Minz_Request::paramString('name');
- $lengthOfName = 0;
- if (is_string($name)) {
- $lengthOfName = strlen($name);
- }
$tagDAO = FreshRSS_Factory::createTagDao();
- if ($lengthOfName > 0 && null === $tagDAO->searchByName($name)) {
+ if (strlen($name) > 0 && null === $tagDAO->searchByName($name)) {
$tagDAO->addTag(['name' => $name]);
Minz_Request::good(_t('feedback.tag.created', $name), ['c' => 'tag', 'a' => 'index']);
}
diff --git a/app/Controllers/userController.php b/app/Controllers/userController.php
index ed8e6cc44..650f96fb2 100644
--- a/app/Controllers/userController.php
+++ b/app/Controllers/userController.php
@@ -41,11 +41,9 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {
$userConfig->passwordHash = $passwordHash;
}
- if (is_array($userConfigUpdated)) {
- foreach ($userConfigUpdated as $configName => $configValue) {
- if ($configValue !== null) {
- $userConfig->_param($configName, $configValue);
- }
+ foreach ($userConfigUpdated as $configName => $configValue) {
+ if ($configValue !== null) {
+ $userConfig->_param($configName, $configValue);
}
}
@@ -224,9 +222,7 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {
}
}
- if (is_array($userConfigOverride)) {
- $userConfig = array_merge($userConfig, $userConfigOverride);
- }
+ $userConfig = array_merge($userConfig, $userConfigOverride);
$ok = self::checkUsername($new_user_name);
$homeDir = join_path(DATA_PATH, 'users', $new_user_name);
@@ -234,11 +230,11 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {
if ($ok) {
$languages = Minz_Translate::availableLanguages();
- if (empty($userConfig['language']) || !in_array($userConfig['language'], $languages)) {
+ if (empty($userConfig['language']) || !in_array($userConfig['language'], $languages, true)) {
$userConfig['language'] = 'en';
}
- $ok &= !in_array(strtoupper($new_user_name), array_map('strtoupper', listUsers())); //Not an existing user, case-insensitive
+ $ok &= !in_array(strtoupper($new_user_name), array_map('strtoupper', listUsers()), true); //Not an existing user, case-insensitive
$configPath = join_path($homeDir, 'config.php');
$ok &= !file_exists($configPath);
diff --git a/app/Mailers/UserMailer.php b/app/Mailers/UserMailer.php
index c722a5520..6b10ccc74 100644
--- a/app/Mailers/UserMailer.php
+++ b/app/Mailers/UserMailer.php
@@ -7,6 +7,7 @@ class FreshRSS_User_Mailer extends Minz_Mailer {
/**
* @var FreshRSS_View
+ * @phpstan-ignore-next-line
*/
protected $view;
diff --git a/app/Models/ActionController.php b/app/Models/ActionController.php
index 2e0aaa730..69548feb3 100644
--- a/app/Models/ActionController.php
+++ b/app/Models/ActionController.php
@@ -4,6 +4,7 @@ class FreshRSS_ActionController extends Minz_ActionController {
/**
* @var FreshRSS_View
+ * @phpstan-ignore-next-line
*/
protected $view;
}
diff --git a/app/Models/BooleanSearch.php b/app/Models/BooleanSearch.php
index ea03165d5..d4d8a42ab 100644
--- a/app/Models/BooleanSearch.php
+++ b/app/Models/BooleanSearch.php
@@ -43,12 +43,12 @@ class FreshRSS_BooleanSearch {
*/
private function parseUserQueryNames(string $input): string {
$all_matches = [];
- if (preg_match_all('/\bsearch:(?P<delim>[\'"])(?P<search>.*)(?P=delim)/U', $input, $matches)) {
- $all_matches[] = $matches;
+ if (preg_match_all('/\bsearch:(?P<delim>[\'"])(?P<search>.*)(?P=delim)/U', $input, $matchesFound)) {
+ $all_matches[] = $matchesFound;
}
- if (preg_match_all('/\bsearch:(?P<search>[^\s"]*)/', $input, $matches)) {
- $all_matches[] = $matches;
+ if (preg_match_all('/\bsearch:(?P<search>[^\s"]*)/', $input, $matchesFound)) {
+ $all_matches[] = $matchesFound;
}
if (!empty($all_matches)) {
@@ -82,8 +82,8 @@ class FreshRSS_BooleanSearch {
private function parseUserQueryIds(string $input): string {
$all_matches = [];
- if (preg_match_all('/\bS:(?P<search>\d+)/', $input, $matches)) {
- $all_matches[] = $matches;
+ if (preg_match_all('/\bS:(?P<search>\d+)/', $input, $matchesFound)) {
+ $all_matches[] = $matchesFound;
}
if (!empty($all_matches)) {
diff --git a/app/Models/CategoryDAO.php b/app/Models/CategoryDAO.php
index e89ceb773..ccfd5c08a 100644
--- a/app/Models/CategoryDAO.php
+++ b/app/Models/CategoryDAO.php
@@ -430,13 +430,13 @@ SQL;
$list = [];
$previousLine = [];
$feedsDao = [];
- $feedDao = FreshRSS_Factory::createFeedDAO();
+ $feedDao = FreshRSS_Factory::createFeedDao();
foreach ($listDAO as $line) {
if (!empty($previousLine['c_id']) && $line['c_id'] !== $previousLine['c_id']) {
// End of the current category, we add it to the $list
$cat = new FreshRSS_Category(
$previousLine['c_name'],
- $feedDao->daoToFeed($feedsDao, $previousLine['c_id'])
+ $feedDao::daoToFeed($feedsDao, $previousLine['c_id'])
);
$cat->_id($previousLine['c_id']);
$cat->_kind($previousLine['c_kind']);
@@ -454,7 +454,7 @@ SQL;
if ($previousLine != null) {
$cat = new FreshRSS_Category(
$previousLine['c_name'],
- $feedDao->daoToFeed($feedsDao, $previousLine['c_id'])
+ $feedDao::daoToFeed($feedsDao, $previousLine['c_id'])
);
$cat->_id($previousLine['c_id']);
$cat->_kind($previousLine['c_kind']);
diff --git a/app/Models/CategoryDAOSQLite.php b/app/Models/CategoryDAOSQLite.php
index 870106f20..c076d25f1 100644
--- a/app/Models/CategoryDAOSQLite.php
+++ b/app/Models/CategoryDAOSQLite.php
@@ -7,7 +7,7 @@ class FreshRSS_CategoryDAOSQLite extends FreshRSS_CategoryDAO {
if ($tableInfo = $this->pdo->query("PRAGMA table_info('category')")) {
$columns = $tableInfo->fetchAll(PDO::FETCH_COLUMN, 1);
foreach (['kind', 'lastUpdate', 'error', 'attributes'] as $column) {
- if (!in_array($column, $columns)) {
+ if (!in_array($column, $columns, true)) {
return $this->addColumn($column);
}
}
diff --git a/app/Models/Context.php b/app/Models/Context.php
index ce29ebd5c..c10119d7d 100644
--- a/app/Models/Context.php
+++ b/app/Models/Context.php
@@ -251,14 +251,14 @@ final class FreshRSS_Context {
* Return the current get as a string or an array.
*
* If $array is true, the first item of the returned value is 'f' or 'c' or 't' and the second is the id.
- * @phpstan-return ($asArray is true ? array{'c'|'f'|'t',bool|int} : string)
+ * @phpstan-return ($asArray is true ? array{'a'|'c'|'f'|'s'|'t'|'T',bool|int} : string)
* @return string|array{string,bool|int}
*/
public static function currentGet(bool $asArray = false) {
if (self::$current_get['all']) {
- return 'a';
+ return $asArray ? ['a', true] : 'a';
} elseif (self::$current_get['starred']) {
- return 's';
+ return $asArray ? ['s', true] : 's';
} elseif (self::$current_get['feed']) {
if ($asArray) {
return array('f', self::$current_get['feed']);
@@ -278,7 +278,7 @@ final class FreshRSS_Context {
return 't_' . self::$current_get['tag'];
}
} elseif (self::$current_get['tags']) {
- return 'T';
+ return $asArray ? ['T', true] : 'T';
}
return '';
}
diff --git a/app/Models/DatabaseDAO.php b/app/Models/DatabaseDAO.php
index 384e59b16..edbfd72cc 100644
--- a/app/Models/DatabaseDAO.php
+++ b/app/Models/DatabaseDAO.php
@@ -83,7 +83,7 @@ class FreshRSS_DatabaseDAO extends Minz_ModelPdo {
$ok = count($columns) === count($schema);
foreach ($columns as $c) {
- $ok &= in_array($c['name'], $schema);
+ $ok &= in_array($c['name'], $schema, true);
}
return (bool)$ok;
@@ -131,7 +131,7 @@ class FreshRSS_DatabaseDAO extends Minz_ModelPdo {
/**
* @param array<string,string|int|bool|null> $dao
- * @return array<string,string|int|bool|null>
+ * @return array{'name':string,'type':string,'notnull':bool,'default':mixed}
*/
public function daoToSchema(array $dao): array {
return [
diff --git a/app/Models/DatabaseDAOSQLite.php b/app/Models/DatabaseDAOSQLite.php
index 8bd8d60ed..5168f5e19 100644
--- a/app/Models/DatabaseDAOSQLite.php
+++ b/app/Models/DatabaseDAOSQLite.php
@@ -50,14 +50,14 @@ class FreshRSS_DatabaseDAOSQLite extends FreshRSS_DatabaseDAO {
}
/**
- * @param array<string,string> $dao
- * @return array<string,string|bool>
+ * @param array<string,string|int|bool|null> $dao
+ * @return array{'name':string,'type':string,'notnull':bool,'default':mixed}
*/
public function daoToSchema(array $dao): array {
return [
- 'name' => $dao['name'],
- 'type' => strtolower($dao['type']),
- 'notnull' => $dao['notnull'] === '1' ? true : false,
+ 'name' => (string)$dao['name'],
+ 'type' => strtolower((string)$dao['type']),
+ 'notnull' => $dao['notnull'] == '1' ? true : false,
'default' => $dao['dflt_value'],
];
}
diff --git a/app/Models/Entry.php b/app/Models/Entry.php
index b0beaaa99..2b0216bbe 100644
--- a/app/Models/Entry.php
+++ b/app/Models/Entry.php
@@ -156,9 +156,9 @@ class FreshRSS_Entry extends Minz_Model {
$content = $this->content;
- $thumbnail = $this->attributes('thumbnail');
- if (!empty($thumbnail['url'])) {
- $elink = $thumbnail['url'];
+ $thumbnailAttribute = $this->attributes('thumbnail');
+ if (!empty($thumbnailAttribute['url'])) {
+ $elink = $thumbnailAttribute['url'];
if ($allowDuplicateEnclosures || !self::containsLink($content, $elink)) {
$content .= <<<HTML
<figure class="enclosure">
@@ -243,7 +243,7 @@ HTML;
if ($searchEnclosures || $searchBodyImages) {
$dom = new DOMDocument();
$dom->loadHTML('<?xml version="1.0" encoding="UTF-8" ?>' . $this->content, LIBXML_NONET | LIBXML_NOERROR | LIBXML_NOWARNING);
- $xpath = new DOMXpath($dom);
+ $xpath = new DOMXPath($dom);
}
if ($searchEnclosures) {
// Legacy code for database entries < FreshRSS 1.20.1
@@ -522,10 +522,10 @@ HTML;
// Searches are combined by OR and are not recursive
$ok = true;
if ($filter->getEntryIds()) {
- $ok &= in_array($this->id, $filter->getEntryIds());
+ $ok &= in_array($this->id, $filter->getEntryIds(), true);
}
if ($ok && $filter->getNotEntryIds()) {
- $ok &= !in_array($this->id, $filter->getNotEntryIds());
+ $ok &= !in_array($this->id, $filter->getNotEntryIds(), true);
}
if ($ok && $filter->getMinDate()) {
$ok &= strnatcmp($this->id, $filter->getMinDate() . '000000') >= 0;
@@ -552,10 +552,10 @@ HTML;
$ok &= $this->date > $filter->getNotMaxPubdate();
}
if ($ok && $filter->getFeedIds()) {
- $ok &= in_array($this->feedId, $filter->getFeedIds());
+ $ok &= in_array($this->feedId, $filter->getFeedIds(), true);
}
if ($ok && $filter->getNotFeedIds()) {
- $ok &= !in_array($this->feedId, $filter->getFeedIds());
+ $ok &= !in_array($this->feedId, $filter->getFeedIds(), true);
}
if ($ok && $filter->getAuthor()) {
foreach ($filter->getAuthor() as $author) {
@@ -719,7 +719,7 @@ HTML;
$filterednode->parentNode->removeChild($filterednode);
}
}
- $content .= $doc->saveHtml($node) . "\n";
+ $content .= $doc->saveHTML($node) . "\n";
}
}
$html = trim(sanitizeHTML($content, $base));
diff --git a/app/Models/EntryDAOSQLite.php b/app/Models/EntryDAOSQLite.php
index bcd139f5f..58a61828b 100644
--- a/app/Models/EntryDAOSQLite.php
+++ b/app/Models/EntryDAOSQLite.php
@@ -27,7 +27,7 @@ class FreshRSS_EntryDAOSQLite extends FreshRSS_EntryDAO {
if ($tableInfo = $this->pdo->query("PRAGMA table_info('entry')")) {
$columns = $tableInfo->fetchAll(PDO::FETCH_COLUMN, 1) ?: [];
foreach (['attributes'] as $column) {
- if (!in_array($column, $columns)) {
+ if (!in_array($column, $columns, true)) {
return $this->addColumn($column);
}
}
diff --git a/app/Models/Feed.php b/app/Models/Feed.php
index f833b2834..b418d2641 100644
--- a/app/Models/Feed.php
+++ b/app/Models/Feed.php
@@ -504,7 +504,7 @@ class FreshRSS_Feed extends Minz_Model {
$text = html_only_entity_decode($category->get_label());
//Some feeds use a single category with comma-separated tags
$labels = explode(',', $text);
- if (is_array($labels)) {
+ if (!empty($labels)) {
foreach ($labels as $label) {
$tags[] = trim($label);
}
@@ -892,7 +892,7 @@ class FreshRSS_Feed extends Minz_Model {
*/
public function _filtersAction(string $action, array $filters): void {
$action = trim($action);
- if ($action == '' || !is_array($filters)) {
+ if ($action == '') {
return;
}
$filters = array_unique(array_map('trim', $filters));
@@ -969,8 +969,8 @@ class FreshRSS_Feed extends Minz_Model {
$hubFilename = PSHB_PATH . '/feeds/' . sha1($url) . '/!hub.json';
$hubFile = @file_get_contents($hubFilename);
$hubJson = $hubFile ? json_decode($hubFile, true) : array();
- if (!isset($hubJson['error']) || $hubJson['error'] !== (bool)$error) {
- $hubJson['error'] = (bool)$error;
+ if (!isset($hubJson['error']) || $hubJson['error'] !== $error) {
+ $hubJson['error'] = $error;
file_put_contents($hubFilename, json_encode($hubJson));
Minz_Log::warning('Set error to ' . ($error ? 1 : 0) . ' for ' . $url, PSHB_LOG);
}
diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php
index 12597b46c..67543b597 100644
--- a/app/Models/FeedDAO.php
+++ b/app/Models/FeedDAO.php
@@ -585,10 +585,6 @@ SQL;
public static function daoToFeed(array $listDAO, ?int $catID = null): array {
$list = array();
- if (!is_array($listDAO)) {
- $listDAO = array($listDAO);
- }
-
foreach ($listDAO as $key => $dao) {
if (!isset($dao['name'])) {
continue;
@@ -611,7 +607,7 @@ SQL;
$myFeed->_lastUpdate($dao['lastUpdate'] ?? 0);
$myFeed->_priority($dao['priority'] ?? 10);
$myFeed->_pathEntries($dao['pathEntries'] ?? '');
- $myFeed->_httpAuth(base64_decode($dao['httpAuth'] ?? ''));
+ $myFeed->_httpAuth(base64_decode($dao['httpAuth'] ?? '', true) ?: '');
$myFeed->_error($dao['error'] ?? 0);
$myFeed->_ttl($dao['ttl'] ?? FreshRSS_Feed::TTL_DEFAULT);
$myFeed->_attributes('', $dao['attributes'] ?? '');
diff --git a/app/Models/FeedDAOSQLite.php b/app/Models/FeedDAOSQLite.php
index 08a352d5f..441a7d636 100644
--- a/app/Models/FeedDAOSQLite.php
+++ b/app/Models/FeedDAOSQLite.php
@@ -7,7 +7,7 @@ class FreshRSS_FeedDAOSQLite extends FreshRSS_FeedDAO {
if ($tableInfo = $this->pdo->query("PRAGMA table_info('feed')")) {
$columns = $tableInfo->fetchAll(PDO::FETCH_COLUMN, 1);
foreach (['attributes', 'kind'] as $column) {
- if (!in_array($column, $columns)) {
+ if (!in_array($column, $columns, true)) {
return $this->addColumn($column);
}
}
diff --git a/app/Models/FormAuth.php b/app/Models/FormAuth.php
index 476daba53..52c75d73d 100644
--- a/app/Models/FormAuth.php
+++ b/app/Models/FormAuth.php
@@ -21,7 +21,7 @@ class FreshRSS_FormAuth {
}
$token_file = DATA_PATH . '/tokens/' . $token . '.txt';
- $mtime = @filemtime($token_file);
+ $mtime = @filemtime($token_file) ?: 0;
$limits = FreshRSS_Context::$system_conf->limits;
$cookie_duration = empty($limits['cookie_duration']) ? FreshRSS_Auth::DEFAULT_COOKIE_DURATION : $limits['cookie_duration'];
if ($mtime + $cookie_duration < time()) {
diff --git a/app/Models/Search.php b/app/Models/Search.php
index d165b05f0..d2ba23eda 100644
--- a/app/Models/Search.php
+++ b/app/Models/Search.php
@@ -142,7 +142,7 @@ class FreshRSS_Search {
return $this->label_ids;
}
/** @return array<int>|'*'|null */
- public function getNotlabelIds() {
+ public function getNotLabelIds() {
return $this->not_label_ids;
}
/** @return array<string>|null */
@@ -150,7 +150,7 @@ class FreshRSS_Search {
return $this->label_names;
}
/** @return array<string>|null */
- public function getNotlabelNames(): ?array {
+ public function getNotLabelNames(): ?array {
return $this->not_label_names;
}
diff --git a/app/Models/Share.php b/app/Models/Share.php
index b01d285f3..a0bae22b3 100644
--- a/app/Models/Share.php
+++ b/app/Models/Share.php
@@ -137,11 +137,11 @@ class FreshRSS_Share {
$this->isDeprecated = $isDeprecated;
$this->transforms = $transforms;
- if (!in_array($form_type, array('simple', 'advanced'))) {
+ if (!in_array($form_type, ['simple', 'advanced'], true)) {
$form_type = 'simple';
}
$this->form_type = $form_type;
- if (!in_array($method, array('GET', 'POST'))) {
+ if (!in_array($method, ['GET', 'POST'], true)) {
$method = 'GET';
}
$this->method = $method;
@@ -304,7 +304,7 @@ class FreshRSS_Share {
* @return string the transformed data.
*/
private static function transform(string $data, array $transform): string {
- if (!is_array($transform) || empty($transform)) {
+ if (empty($transform)) {
return $data;
}
diff --git a/app/Models/StatsDAO.php b/app/Models/StatsDAO.php
index fb21407a5..53219843e 100644
--- a/app/Models/StatsDAO.php
+++ b/app/Models/StatsDAO.php
@@ -58,7 +58,7 @@ SQL;
*/
public function calculateEntryCount(): array {
$count = $this->initEntryCountArray();
- $midnight = mktime(0, 0, 0);
+ $midnight = mktime(0, 0, 0) ?: 0;
$oldest = $midnight - (self::ENTRY_COUNT_PERIOD * 86400);
// Get stats per day for the last 30 days
diff --git a/app/Models/TagDAO.php b/app/Models/TagDAO.php
index 32f67f0ab..7888caca8 100644
--- a/app/Models/TagDAO.php
+++ b/app/Models/TagDAO.php
@@ -378,7 +378,7 @@ INNER JOIN `_entrytag` et ON et.id_tag = t.id
SQL;
$values = array();
- if (is_array($entries) && count($entries) > 0) {
+ if (count($entries) > 0) {
if (count($entries) > FreshRSS_DatabaseDAO::MAX_VARIABLE_NUMBER) {
// Split a query with too many variables parameters
$idsChunks = array_chunk($entries, FreshRSS_DatabaseDAO::MAX_VARIABLE_NUMBER);
diff --git a/app/actualize_script.php b/app/actualize_script.php
index 67dcc9631..93479e74d 100755
--- a/app/actualize_script.php
+++ b/app/actualize_script.php
@@ -42,7 +42,7 @@ function notice(string $message): void {
// Avoid having multiple actualization processes at the same time
$mutexFile = TMP_PATH . '/actualize.freshrss.lock';
$mutexTtl = 900; // seconds (refreshed before each new feed)
-if (file_exists($mutexFile) && ((time() - @filemtime($mutexFile)) > $mutexTtl)) {
+if (file_exists($mutexFile) && ((time() - (@filemtime($mutexFile) ?: 0)) > $mutexTtl)) {
unlink($mutexFile);
}
diff --git a/app/install.php b/app/install.php
index cb49b8de7..65efe40f1 100644
--- a/app/install.php
+++ b/app/install.php
@@ -31,7 +31,7 @@ function initTranslate(): void {
Minz_Session::_param('language', get_best_language());
}
- if (!in_array(Minz_Session::param('language'), $available_languages)) {
+ if (!in_array(Minz_Session::param('language'), $available_languages, true)) {
Minz_Session::_param('language', 'en');
}
@@ -265,7 +265,7 @@ function checkStep(): void {
/** @return array<string,string> */
function checkStep0(): array {
$languages = Minz_Translate::availableLanguages();
- $language = Minz_Session::param('language') != '' && in_array(Minz_Session::param('language'), $languages);
+ $language = Minz_Session::param('language') != '' && in_array(Minz_Session::param('language'), $languages, true);
$sessionWorking = Minz_Session::param('sessionWorking') === 'ok';
return array(
@@ -565,7 +565,7 @@ function printStep2(): void {
}
function no_auth(string $auth_type): bool {
- return !in_array($auth_type, array('form', 'http_auth', 'none'));
+ return !in_array($auth_type, ['form', 'http_auth', 'none'], true);
}
function printStep3(): void {
diff --git a/app/layout/aside_feed.phtml b/app/layout/aside_feed.phtml
index 410a0ce60..7f18e531c 100644
--- a/app/layout/aside_feed.phtml
+++ b/app/layout/aside_feed.phtml
@@ -46,7 +46,7 @@
<?php
$t_active = FreshRSS_Context::isCurrentGet('T');
- $t_show = ($t_active && in_array(FreshRSS_Context::$user_conf->display_categories, [ 'active', 'remember' ])) || FreshRSS_Context::$user_conf->display_categories === 'all';
+ $t_show = ($t_active && in_array(FreshRSS_Context::$user_conf->display_categories, ['active', 'remember'], true)) || FreshRSS_Context::$user_conf->display_categories === 'all';
?>
<li id="tags" class="tree-folder category tags<?= $t_active ? ' active' : '' ?>" data-unread="<?= format_number($this->nbUnreadTags) ?>">
<div class="tree-folder-title">
@@ -81,7 +81,7 @@
$position = $cat->attributes('position');
if (!empty($feeds)) {
$c_active = FreshRSS_Context::isCurrentGet('c_' . $cat->id());
- $c_show = ($c_active && in_array(FreshRSS_Context::$user_conf->display_categories, [ 'active', 'remember' ]))
+ $c_show = ($c_active && in_array(FreshRSS_Context::$user_conf->display_categories, ['active', 'remember'], true))
|| FreshRSS_Context::$user_conf->display_categories === 'all';
?>
<li id="c_<?= $cat->id() ?>" class="tree-folder category<?= $c_active ? ' active' : '' ?>"<?=
diff --git a/app/layout/header.phtml b/app/layout/header.phtml
index f2330431b..c49d98508 100644
--- a/app/layout/header.phtml
+++ b/app/layout/header.phtml
@@ -20,7 +20,7 @@
placeholder="<?= _t('gen.menu.search') ?>" />
<?php $param_a = Minz_Request::actionName(); ?>
- <?php if (in_array($param_a, ['normal', 'global', 'reader'])) { ?>
+ <?php if (in_array($param_a, ['normal', 'global', 'reader'], true)) { ?>
<input type="hidden" name="a" value="<?= $param_a ?>" />
<?php } ?>
diff --git a/app/layout/nav_menu.phtml b/app/layout/nav_menu.phtml
index 594913935..0937fe61f 100644
--- a/app/layout/nav_menu.phtml
+++ b/app/layout/nav_menu.phtml
@@ -40,7 +40,7 @@
<span>
<form action="<?= _url('index', 'index') ?>" method="get">
<?php $param_a = Minz_Request::actionName(); ?>
- <?php if (in_array($param_a, ['normal', 'global', 'reader'])) { ?>
+ <?php if (in_array($param_a, ['normal', 'global', 'reader'], true)) { ?>
<input type="hidden" name="a" value="<?= $param_a ?>" />
<?php } ?>
diff --git a/app/views/auth/index.phtml b/app/views/auth/index.phtml
index a18ab49e2..45183592a 100644
--- a/app/views/auth/index.phtml
+++ b/app/views/auth/index.phtml
@@ -16,7 +16,7 @@
<label class="group-name" for="auth_type"><?= _t('admin.auth.type') ?></label>
<div class="group-controls">
<select id="auth_type" name="auth_type" required="required" data-leave-validation="<?= FreshRSS_Context::$system_conf->auth_type ?>">
- <?php if (!in_array(FreshRSS_Context::$system_conf->auth_type, array('form', 'http_auth', 'none'))) { ?>
+ <?php if (!in_array(FreshRSS_Context::$system_conf->auth_type, ['form', 'http_auth', 'none'], true)) { ?>
<option selected="selected"></option>
<?php } ?>
<option value="form"<?= FreshRSS_Context::$system_conf->auth_type === 'form' ? ' selected="selected"' : '',
diff --git a/app/views/helpers/logs_pagination.phtml b/app/views/helpers/logs_pagination.phtml
index c7b9ca0ca..c9f18dc07 100755
--- a/app/views/helpers/logs_pagination.phtml
+++ b/app/views/helpers/logs_pagination.phtml
@@ -18,13 +18,13 @@
<?php $params[$getteur] = $this->currentPage - 1; ?>
-
+
<li class="item pager-previous">
<?php if ($this->currentPage > 1) { ?>
<a href="<?= Minz_Url::display(array('c' => $c, 'a' => $a, 'params' => $params)) ?>">‹ <?= _t('conf.logs.pagination.previous') ?></a>
<?php } ?>
</li>
-
+
<?php if ($this->currentPage - 2 > 1) { ?>
<li class="item">…</a></li>
@@ -32,7 +32,7 @@
<?php
for ($i = $this->currentPage - 2; $i <= $this->currentPage + 2; $i++) {
- if($i > 0 && $i <= $this->nbPage) {
+ if ($i > 0 && $i <= $this->nbPage) {
$params[$getteur] = $i;
if ($i != $this->currentPage) {
$class = '';
@@ -46,18 +46,18 @@
}
} ?>
- <?php if ($this->nbPage > $i - 1) { ?>
+ <?php if ($this->nbPage > $this->currentPage + 2) { ?>
<li class="item">…</a></li>
<?php } ?>
<?php $params[$getteur] = $this->currentPage + 1; ?>
-
+
<li class="item pager-next">
<?php if ($this->currentPage < $this->nbPage) { ?>
<a href="<?= Minz_Url::display(array('c' => $c, 'a' => $a, 'params' => $params)) ?>"><?= _t('conf.logs.pagination.next') ?> ›</a>
<?php } ?>
</li>
-
+
<?php $params[$getteur] = $this->nbPage; ?>
<li class="item pager-last">
<a href="<?= Minz_Url::display(array('c' => $c, 'a' => $a, 'params' => $params)) ?>"><?= _t('conf.logs.pagination.last') ?> »</a>