diff options
| author | 2023-11-16 22:43:00 +0100 | |
|---|---|---|
| committer | 2023-11-16 22:43:00 +0100 | |
| commit | 30c7a61a9b410f023c56ef19b9389a61647d8768 (patch) | |
| tree | bb58408980ce5b86f1d2b4a9be29d55b2d46dbb1 /app/Models | |
| parent | ee99e7e2cc228500efc1b539954c0ca6cd4c146d (diff) | |
Use strict_types (#5830)
* Little's optimisations and booleans in conditions
* Apply strict type
* Apply strict type
* Apply strict type
* Fix multiple bugs with PHP 8.2 and 8.3
* Many declares missing, more errors fixed
* Apply strict type
* Another approach
* Stronger typing for Minz_Session
* Fix case of SQLite
---------
Co-authored-by: Luc <sanchezluc+freshrss@gmail.com>
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Diffstat (limited to 'app/Models')
41 files changed, 46 insertions, 17 deletions
diff --git a/app/Models/ActionController.php b/app/Models/ActionController.php index 1a46cff36..a840ccc6d 100644 --- a/app/Models/ActionController.php +++ b/app/Models/ActionController.php @@ -1,5 +1,4 @@ <?php - declare(strict_types=1); class FreshRSS_ActionController extends Minz_ActionController { diff --git a/app/Models/Auth.php b/app/Models/Auth.php index 205b428a2..e5f7fc0b9 100644 --- a/app/Models/Auth.php +++ b/app/Models/Auth.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * This class handles all authentication process. @@ -20,7 +21,7 @@ class FreshRSS_Auth { self::removeAccess(); } - self::$login_ok = Minz_Session::param('loginOk', false); + self::$login_ok = Minz_Session::paramBoolean('loginOk'); $current_user = Minz_User::name(); if ($current_user === null) { $current_user = FreshRSS_Context::$system_conf->default_user; @@ -109,7 +110,7 @@ class FreshRSS_Auth { switch (FreshRSS_Context::$system_conf->auth_type) { case 'form': - self::$login_ok = Minz_Session::param('passwordHash') === FreshRSS_Context::$user_conf->passwordHash; + self::$login_ok = Minz_Session::paramString('passwordHash') === FreshRSS_Context::$user_conf->passwordHash; break; case 'http_auth': $current_user = Minz_User::name(); @@ -212,7 +213,7 @@ class FreshRSS_Auth { } public static function csrfToken(): string { - $csrf = Minz_Session::param('csrf'); + $csrf = Minz_Session::paramString('csrf'); if ($csrf == '') { $salt = FreshRSS_Context::$system_conf->salt; $csrf = sha1($salt . uniqid('' . random_int(0, mt_getrandmax()), true)); @@ -222,7 +223,7 @@ class FreshRSS_Auth { } public static function isCsrfOk(?string $token = null): bool { - $csrf = Minz_Session::param('csrf'); + $csrf = Minz_Session::paramString('csrf'); if ($token === null) { $token = $_POST['_csrf'] ?? ''; } diff --git a/app/Models/BooleanSearch.php b/app/Models/BooleanSearch.php index d8c47c878..8a750a713 100644 --- a/app/Models/BooleanSearch.php +++ b/app/Models/BooleanSearch.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * Contains Boolean search from the search form. @@ -67,7 +68,7 @@ class FreshRSS_BooleanSearch { $name = trim($matches['search'][$i]); if (!empty($queries[$name])) { $fromS[] = $matches[0][$i]; - $toS[] = '(' . trim($queries[$name]->getSearch()) . ')'; + $toS[] = '(' . trim($queries[$name]->getSearch()->getRawInput()) . ')'; } } } @@ -110,7 +111,7 @@ class FreshRSS_BooleanSearch { $id = (int)(trim($matches['search'][$i])) - 1; if (!empty($queries[$id])) { $fromS[] = $matches[0][$i]; - $toS[] = '(' . trim($queries[$id]->getSearch()) . ')'; + $toS[] = '(' . trim($queries[$id]->getSearch()->getRawInput()) . ')'; } } } diff --git a/app/Models/Category.php b/app/Models/Category.php index 370c49709..ab08a5b74 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); class FreshRSS_Category extends Minz_Model { diff --git a/app/Models/CategoryDAO.php b/app/Models/CategoryDAO.php index 72971f44b..5dfecb36d 100644 --- a/app/Models/CategoryDAO.php +++ b/app/Models/CategoryDAO.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); class FreshRSS_CategoryDAO extends Minz_ModelPdo { diff --git a/app/Models/CategoryDAOSQLite.php b/app/Models/CategoryDAOSQLite.php index ee6d5b7ad..268d579b1 100644 --- a/app/Models/CategoryDAOSQLite.php +++ b/app/Models/CategoryDAOSQLite.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); class FreshRSS_CategoryDAOSQLite extends FreshRSS_CategoryDAO { diff --git a/app/Models/Context.php b/app/Models/Context.php index 9fac52d44..ac5547aa1 100644 --- a/app/Models/Context.php +++ b/app/Models/Context.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * The context object handles the current configuration file and different diff --git a/app/Models/DatabaseDAO.php b/app/Models/DatabaseDAO.php index 1f31f161a..89327d6c9 100644 --- a/app/Models/DatabaseDAO.php +++ b/app/Models/DatabaseDAO.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * This class is used to test database is well-constructed. diff --git a/app/Models/DatabaseDAOPGSQL.php b/app/Models/DatabaseDAOPGSQL.php index 7976d5e14..4a92dd184 100644 --- a/app/Models/DatabaseDAOPGSQL.php +++ b/app/Models/DatabaseDAOPGSQL.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * This class is used to test database is well-constructed. diff --git a/app/Models/DatabaseDAOSQLite.php b/app/Models/DatabaseDAOSQLite.php index 261932867..787380637 100644 --- a/app/Models/DatabaseDAOSQLite.php +++ b/app/Models/DatabaseDAOSQLite.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * This class is used to test database is well-constructed (SQLite). diff --git a/app/Models/Days.php b/app/Models/Days.php index d3f1ba075..c445c6355 100644 --- a/app/Models/Days.php +++ b/app/Models/Days.php @@ -1,5 +1,4 @@ <?php - declare(strict_types=1); class FreshRSS_Days { diff --git a/app/Models/Entry.php b/app/Models/Entry.php index 249f607ee..e19a637d7 100644 --- a/app/Models/Entry.php +++ b/app/Models/Entry.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); class FreshRSS_Entry extends Minz_Model { public const STATE_READ = 1; @@ -437,7 +438,11 @@ HTML; return $this->hash; } - public function _id(string $value): void { + /** @param int|string $value String is for compatibility with 32-bit platforms */ + public function _id($value): void { + if (is_int($value)) { + $value = (string)$value; + } $this->id = $value; if ($this->date_added == 0) { $this->date_added = $value; @@ -741,11 +746,11 @@ HTML; } $content = ''; - $nodes = $xpath->query(new Gt\CssXPath\Translator($path)); + $nodes = $xpath->query((new Gt\CssXPath\Translator($path))->asXPath()); if ($nodes != false) { foreach ($nodes as $node) { if (!empty($attributes['path_entries_filter'])) { - $filterednodes = $xpath->query(new Gt\CssXPath\Translator($attributes['path_entries_filter']), $node) ?: []; + $filterednodes = $xpath->query((new Gt\CssXPath\Translator($attributes['path_entries_filter']))->asXPath(), $node) ?: []; foreach ($filterednodes as $filterednode) { $filterednode->parentNode->removeChild($filterednode); } diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index f2711d448..403f4e493 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); class FreshRSS_EntryDAO extends Minz_ModelPdo { diff --git a/app/Models/EntryDAOPGSQL.php b/app/Models/EntryDAOPGSQL.php index 0e8ffa463..39e86384d 100644 --- a/app/Models/EntryDAOPGSQL.php +++ b/app/Models/EntryDAOPGSQL.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); class FreshRSS_EntryDAOPGSQL extends FreshRSS_EntryDAOSQLite { diff --git a/app/Models/EntryDAOSQLite.php b/app/Models/EntryDAOSQLite.php index 136f6d550..66feb567b 100644 --- a/app/Models/EntryDAOSQLite.php +++ b/app/Models/EntryDAOSQLite.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); class FreshRSS_EntryDAOSQLite extends FreshRSS_EntryDAO { diff --git a/app/Models/Factory.php b/app/Models/Factory.php index d06c3c63d..eef3c81f5 100644 --- a/app/Models/Factory.php +++ b/app/Models/Factory.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); class FreshRSS_Factory { diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 38c6ca37e..d94763e6e 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); class FreshRSS_Feed extends Minz_Model { diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php index ef9db1e01..42a4e77f1 100644 --- a/app/Models/FeedDAO.php +++ b/app/Models/FeedDAO.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); class FreshRSS_FeedDAO extends Minz_ModelPdo { diff --git a/app/Models/FeedDAOSQLite.php b/app/Models/FeedDAOSQLite.php index 32d5bd0d2..c6bf9c8ae 100644 --- a/app/Models/FeedDAOSQLite.php +++ b/app/Models/FeedDAOSQLite.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); class FreshRSS_FeedDAOSQLite extends FreshRSS_FeedDAO { diff --git a/app/Models/FilterAction.php b/app/Models/FilterAction.php index bd8b12a7a..6487d5100 100644 --- a/app/Models/FilterAction.php +++ b/app/Models/FilterAction.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); class FreshRSS_FilterAction { diff --git a/app/Models/FormAuth.php b/app/Models/FormAuth.php index c19856c37..83fb60e3c 100644 --- a/app/Models/FormAuth.php +++ b/app/Models/FormAuth.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); class FreshRSS_FormAuth { public static function checkCredentials(string $username, string $hash, string $nonce, string $challenge): bool { diff --git a/app/Models/Log.php b/app/Models/Log.php index c3f4bb244..7760e76ca 100644 --- a/app/Models/Log.php +++ b/app/Models/Log.php @@ -1,5 +1,4 @@ <?php - declare(strict_types=1); class FreshRSS_Log extends Minz_Model { diff --git a/app/Models/LogDAO.php b/app/Models/LogDAO.php index 080af54ea..9d271455e 100644 --- a/app/Models/LogDAO.php +++ b/app/Models/LogDAO.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); final class FreshRSS_LogDAO { public static function logPath(?string $logFileName = null): string { diff --git a/app/Models/ReadingMode.php b/app/Models/ReadingMode.php index 51ff26fd5..c8ebe66f3 100644 --- a/app/Models/ReadingMode.php +++ b/app/Models/ReadingMode.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * Manage the reading modes in FreshRSS. diff --git a/app/Models/Search.php b/app/Models/Search.php index 56f8d3834..d5dd701c3 100644 --- a/app/Models/Search.php +++ b/app/Models/Search.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); require_once(LIB_PATH . '/lib_date.php'); diff --git a/app/Models/Share.php b/app/Models/Share.php index b0665a07c..57177c78c 100644 --- a/app/Models/Share.php +++ b/app/Models/Share.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * Manage the sharing options in FreshRSS. diff --git a/app/Models/StatsDAO.php b/app/Models/StatsDAO.php index 122ca14a8..2cef6c183 100644 --- a/app/Models/StatsDAO.php +++ b/app/Models/StatsDAO.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); class FreshRSS_StatsDAO extends Minz_ModelPdo { diff --git a/app/Models/StatsDAOPGSQL.php b/app/Models/StatsDAOPGSQL.php index 6e0e04c60..5204b04e3 100644 --- a/app/Models/StatsDAOPGSQL.php +++ b/app/Models/StatsDAOPGSQL.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); class FreshRSS_StatsDAOPGSQL extends FreshRSS_StatsDAO { diff --git a/app/Models/StatsDAOSQLite.php b/app/Models/StatsDAOSQLite.php index 7d5be10c0..2aa86f0da 100644 --- a/app/Models/StatsDAOSQLite.php +++ b/app/Models/StatsDAOSQLite.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); class FreshRSS_StatsDAOSQLite extends FreshRSS_StatsDAO { diff --git a/app/Models/SystemConfiguration.php b/app/Models/SystemConfiguration.php index bf5bed0d7..294ca1e3a 100644 --- a/app/Models/SystemConfiguration.php +++ b/app/Models/SystemConfiguration.php @@ -1,5 +1,4 @@ <?php - declare(strict_types=1); /** diff --git a/app/Models/Tag.php b/app/Models/Tag.php index 920422ac8..0e50763d0 100644 --- a/app/Models/Tag.php +++ b/app/Models/Tag.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); class FreshRSS_Tag extends Minz_Model { diff --git a/app/Models/TagDAO.php b/app/Models/TagDAO.php index a89c04695..bd52223a8 100644 --- a/app/Models/TagDAO.php +++ b/app/Models/TagDAO.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); class FreshRSS_TagDAO extends Minz_ModelPdo { diff --git a/app/Models/TagDAOPGSQL.php b/app/Models/TagDAOPGSQL.php index 1b8bb7784..de3b20f92 100644 --- a/app/Models/TagDAOPGSQL.php +++ b/app/Models/TagDAOPGSQL.php @@ -1,5 +1,4 @@ <?php - declare(strict_types=1); class FreshRSS_TagDAOPGSQL extends FreshRSS_TagDAO { diff --git a/app/Models/TagDAOSQLite.php b/app/Models/TagDAOSQLite.php index f1921c9f0..efa52807a 100644 --- a/app/Models/TagDAOSQLite.php +++ b/app/Models/TagDAOSQLite.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); class FreshRSS_TagDAOSQLite extends FreshRSS_TagDAO { diff --git a/app/Models/Themes.php b/app/Models/Themes.php index 902d3c94b..53ae1dc27 100644 --- a/app/Models/Themes.php +++ b/app/Models/Themes.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); class FreshRSS_Themes extends Minz_Model { diff --git a/app/Models/UserConfiguration.php b/app/Models/UserConfiguration.php index 1eceaab99..05e36aae6 100644 --- a/app/Models/UserConfiguration.php +++ b/app/Models/UserConfiguration.php @@ -1,5 +1,4 @@ <?php - declare(strict_types=1); /** diff --git a/app/Models/UserDAO.php b/app/Models/UserDAO.php index 0961da82e..1f85b5fe9 100644 --- a/app/Models/UserDAO.php +++ b/app/Models/UserDAO.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); class FreshRSS_UserDAO extends Minz_ModelPdo { diff --git a/app/Models/UserQuery.php b/app/Models/UserQuery.php index 3454ede31..85df49f1c 100644 --- a/app/Models/UserQuery.php +++ b/app/Models/UserQuery.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * Contains the description of a user query diff --git a/app/Models/View.php b/app/Models/View.php index b8d776fbc..17772a2ec 100644 --- a/app/Models/View.php +++ b/app/Models/View.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); class FreshRSS_View extends Minz_View { diff --git a/app/Models/ViewJavascript.php b/app/Models/ViewJavascript.php index 157ebe4ae..38a0a74f0 100644 --- a/app/Models/ViewJavascript.php +++ b/app/Models/ViewJavascript.php @@ -1,5 +1,4 @@ <?php - declare(strict_types=1); final class FreshRSS_ViewJavascript extends FreshRSS_View { diff --git a/app/Models/ViewStats.php b/app/Models/ViewStats.php index f07c19c91..25c749cd2 100644 --- a/app/Models/ViewStats.php +++ b/app/Models/ViewStats.php @@ -1,5 +1,4 @@ <?php - declare(strict_types=1); final class FreshRSS_ViewStats extends FreshRSS_View { |
