diff options
| author | 2023-04-17 16:27:35 +0200 | |
|---|---|---|
| committer | 2023-04-17 16:27:35 +0200 | |
| commit | 8cc8127c3c8ed1b99135b21424134eabec30f150 (patch) | |
| tree | 13600cd462f592de644ed8ef3dd04fc199dc1d87 | |
| parent | 62496339b6a43fcbb8267fb0f14ac2b165bf5826 (diff) | |
phpstan level 7 for user-info.php (#5309)
* phpstan level 7 for user-info.php
* phpstan level 7 for user-info.php
* phpstan level 7 for user-info.php
---------
Co-authored-by: Luc <sanchezluc+freshrss@gmail.com>
| -rw-r--r-- | app/Models/EntryDAO.php | 4 | ||||
| -rwxr-xr-x | cli/user-info.php | 20 | ||||
| -rw-r--r-- | tests/phpstan-next.txt | 1 |
3 files changed, 20 insertions, 5 deletions
diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index ab71fb0c3..365ee67fa 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -1295,8 +1295,8 @@ SQL; } $res = $stm->fetchAll(PDO::FETCH_COLUMN, 0); rsort($res); - $all = empty($res[0]) ? 0 : intval($res[0]); - $unread = empty($res[1]) ? 0 : intval($res[1]); + $all = empty($res[0]) ? 0 : (int)$res[0]; + $unread = empty($res[1]) ? 0 : (int)$res[1]; return array('all' => $all, 'unread' => $unread, 'read' => $all - $unread); } diff --git a/cli/user-info.php b/cli/user-info.php index 8fc8f20df..6365ef6a4 100755 --- a/cli/user-info.php +++ b/cli/user-info.php @@ -64,6 +64,21 @@ foreach ($users as $username) { $nbEntries = $entryDAO->countUnreadRead(); $nbFavorites = $entryDAO->countUnreadReadFavorites(); + if ($nbFavorites === false) { + $nbFavorites = [ + 'all' => 0, + ]; + } + + $feedList = $feedDAO->listFeedsIds(); + + if ($nbEntries === false) { + $nbEntries = [ + 'read' => 0, + 'unread' => 0, + ]; + } + $data = array( 'default' => $username === FreshRSS_Context::$system_conf->default_user ? '*' : '', 'user' => $username, @@ -72,7 +87,7 @@ foreach ($users as $username) { 'last_user_activity' => FreshRSS_UserDAO::mtime($username), 'database_size' => $databaseDAO->size(), 'categories' => $catDAO->count(), - 'feeds' => count($feedDAO->listFeedsIds()), + 'feeds' => count($feedList === false ? [] : $feedList), 'reads' => (int)$nbEntries['read'], 'unreads' => (int)$nbEntries['unread'], 'favourites' => (int)$nbFavorites['all'], @@ -84,11 +99,12 @@ foreach ($users as $username) { $data['last_user_activity'] = date('c', $data['last_user_activity']); $data['database_size'] = format_bytes($data['database_size']); } + if ($formatJson) { $data['default'] = !empty($data['default']); $data['admin'] = !empty($data['admin']); $data['enabled'] = !empty($data['enabled']); - $data['last_user_activity'] = gmdate('Y-m-d\TH:i:s\Z', $data['last_user_activity']); + $data['last_user_activity'] = gmdate('Y-m-d\TH:i:s\Z', (int)$data['last_user_activity']); $jsonOutput[] = $data; } else { vprintf(DATA_FORMAT, $data); diff --git a/tests/phpstan-next.txt b/tests/phpstan-next.txt index 9af4161db..246a7a422 100644 --- a/tests/phpstan-next.txt +++ b/tests/phpstan-next.txt @@ -35,7 +35,6 @@ ./cli/delete-user.php ./cli/do-install.php ./cli/manipulate.translation.php -./cli/user-info.php ./lib/lib_date.php ./lib/Minz/ActionController.php ./lib/Minz/Error.php |
