summaryrefslogtreecommitdiff
path: root/app/Models
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2021-12-31 17:00:51 +0100
committerGravatar GitHub <noreply@github.com> 2021-12-31 17:00:51 +0100
commit77e9877316fcfacb26799afdf32d94c8411da80e (patch)
tree7fd9c85bf4854054be6536c14d120bc8b790debe /app/Models
parent09c84fb3bc44bf8e45619c27acc15b967aea14ce (diff)
Add PHPStan (#4021)
* Add PHPStan #fix https://github.com/FreshRSS/FreshRSS/issues/4016 https://phpstan.org/ ```sh composer run-script phpstan ``` * More fixes * Fix global variables * Add .phtml * Fix merge https://github.com/FreshRSS/FreshRSS/pull/4090 * Fix more warnings * Fix view errors and enable in CI * ReturnTypeWillChange * Dynamic view type * Fix Minz static/self bug
Diffstat (limited to 'app/Models')
-rw-r--r--app/Models/DatabaseDAO.php6
-rw-r--r--app/Models/EntryDAO.php2
-rw-r--r--app/Models/Search.php1
-rw-r--r--app/Models/TagDAO.php2
-rw-r--r--app/Models/UserDAO.php5
-rw-r--r--app/Models/View.php119
6 files changed, 128 insertions, 7 deletions
diff --git a/app/Models/DatabaseDAO.php b/app/Models/DatabaseDAO.php
index 86f72b14c..b1ce0cca6 100644
--- a/app/Models/DatabaseDAO.php
+++ b/app/Models/DatabaseDAO.php
@@ -24,7 +24,7 @@ class FreshRSS_DatabaseDAO extends Minz_ModelPdo {
$db = FreshRSS_Context::$system_conf->db;
try {
- $sql = sprintf($SQL_CREATE_DB, empty($db['base']) ? '' : $db['base']);
+ $sql = sprintf($GLOBALS['SQL_CREATE_DB'], empty($db['base']) ? '' : $db['base']);
return $this->pdo->exec($sql) === false ? 'Error during CREATE DATABASE' : '';
} catch (Exception $e) {
syslog(LOG_DEBUG, __method__ . ' notice: ' . $e->getMessage());
@@ -176,7 +176,7 @@ class FreshRSS_DatabaseDAO extends Minz_ModelPdo {
$ok = false;
try {
- $ok = $this->pdo->exec($SQL_UPDATE_GUID_LATIN1_BIN) !== false; //FreshRSS 1.12
+ $ok = $this->pdo->exec($GLOBALS['SQL_UPDATE_GUID_LATIN1_BIN']) !== false; //FreshRSS 1.12
} catch (Exception $e) {
$ok = false;
Minz_Log::error(__METHOD__ . ' error: ' . $e->getMessage());
@@ -277,6 +277,8 @@ class FreshRSS_DatabaseDAO extends Minz_ModelPdo {
$entryFrom = $entryDAOSQLite; $entryTo = $entryDAO;
$tagFrom = $tagDAOSQLite; $tagTo = $tagDAO;
break;
+ default:
+ return;
}
$idMaps = [];
diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php
index 7c133a2f4..7b7f5f53e 100644
--- a/app/Models/EntryDAO.php
+++ b/app/Models/EntryDAO.php
@@ -32,7 +32,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
try {
require(APP_PATH . '/SQL/install.sql.' . $this->pdo->dbType() . '.php');
Minz_Log::warning('SQL CREATE TABLE entrytmp...');
- $ok = $this->pdo->exec($SQL_CREATE_TABLE_ENTRYTMP . $SQL_CREATE_INDEX_ENTRY_1) !== false;
+ $ok = $this->pdo->exec($GLOBALS['SQL_CREATE_TABLE_ENTRYTMP'] . $GLOBALS['SQL_CREATE_INDEX_ENTRY_1']) !== false;
} catch (Exception $ex) {
Minz_Log::error(__method__ . ' error: ' . $ex->getMessage());
}
diff --git a/app/Models/Search.php b/app/Models/Search.php
index 47aaa6078..08669f738 100644
--- a/app/Models/Search.php
+++ b/app/Models/Search.php
@@ -570,7 +570,6 @@ class FreshRSS_Search {
* Supported delimiters are single quote (') and double quotes (").
*
* @param string $input
- * @return string
*/
private function parseSearch($input) {
$input = self::cleanSearch($input);
diff --git a/app/Models/TagDAO.php b/app/Models/TagDAO.php
index b5b59afd9..03ef5421b 100644
--- a/app/Models/TagDAO.php
+++ b/app/Models/TagDAO.php
@@ -20,7 +20,7 @@ class FreshRSS_TagDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
$databaseDAO->ensureCaseInsensitiveGuids();
Minz_Log::warning('SQL CREATE TABLE tag...');
- $ok = $this->pdo->exec($SQL_CREATE_TABLE_TAGS) !== false;
+ $ok = $this->pdo->exec($GLOBALS['SQL_CREATE_TABLE_TAGS']) !== false;
} catch (Exception $e) {
Minz_Log::error('FreshRSS_EntryDAO::createTagTable error: ' . $e->getMessage());
}
diff --git a/app/Models/UserDAO.php b/app/Models/UserDAO.php
index 1596fa5cc..c9a3436d8 100644
--- a/app/Models/UserDAO.php
+++ b/app/Models/UserDAO.php
@@ -5,9 +5,10 @@ class FreshRSS_UserDAO extends Minz_ModelPdo {
require(APP_PATH . '/SQL/install.sql.' . $this->pdo->dbType() . '.php');
try {
- $sql = $SQL_CREATE_TABLES . $SQL_CREATE_TABLE_ENTRYTMP . $SQL_CREATE_TABLE_TAGS;
+ $sql = $GLOBALS['$SQL_CREATE_TABLES'] . $GLOBALS['SQL_CREATE_TABLE_ENTRYTMP'] . $GLOBALS['SQL_CREATE_TABLE_TAGS'];
$ok = $this->pdo->exec($sql) !== false; //Note: Only exec() can take multiple statements safely.
} catch (Exception $e) {
+ $ok = false;
Minz_Log::error('Error while creating database for user ' . $this->current_user . ': ' . $e->getMessage());
}
@@ -26,7 +27,7 @@ class FreshRSS_UserDAO extends Minz_ModelPdo {
}
require(APP_PATH . '/SQL/install.sql.' . $this->pdo->dbType() . '.php');
- $ok = $this->pdo->exec($SQL_DROP_TABLES) !== false;
+ $ok = $this->pdo->exec($GLOBALS['SQL_DROP_TABLES']) !== false;
if ($ok) {
return true;
diff --git a/app/Models/View.php b/app/Models/View.php
new file mode 100644
index 000000000..22bc2c49a
--- /dev/null
+++ b/app/Models/View.php
@@ -0,0 +1,119 @@
+<?php
+
+class FreshRSS_View extends Minz_View {
+
+ // Main views
+ public $callbackBeforeEntries;
+ public $callbackBeforePagination;
+ public $categories;
+ public $category;
+ public $entries;
+ public $entry;
+ public $feed;
+ public $feeds;
+ public $nbUnreadTags;
+ public $tags;
+
+ // Substriptions
+ public $default_category;
+ public $displaySlider;
+ public $load_ok;
+ public $onlyFeedsWithError;
+ public $signalError;
+
+ // Manage users
+ public $details;
+ public $disable_aside;
+ public $show_email_field;
+ public $username;
+ public $users;
+
+ // Updates
+ public $last_update_time;
+ public $status_files;
+ public $status_php;
+ public $update_to_apply;
+
+ // Archiving
+ public $nb_total;
+ public $size_total;
+ public $size_user;
+
+ // Display
+ public $themes;
+
+ // Shortcuts
+ public $list_keys;
+
+ // User queries
+ public $queries;
+ public $query;
+
+ // Export / Import
+ public $content;
+ public $entriesRaw;
+ public $entryIdsTagNames;
+ public $list_title;
+ public $queryId;
+ public $type;
+
+ // Form login
+ public $cookie_days;
+ public $nonce;
+ public $salt1;
+
+ // Registration
+ public $can_register;
+ public $preferred_language;
+ public $show_tos_checkbox;
+ public $terms_of_service;
+
+ // Email validation
+ public $site_title;
+ public $validation_url;
+
+ // Logs
+ public $currentPage;
+ public $logsPaginator;
+ public $nbPage;
+
+ // RSS view
+ public $rss_title;
+ public $url;
+
+ // Content preview
+ public $fatalError;
+ public $htmlContent;
+ public $selectorSuccess;
+
+ // Extensions
+ public $ext_details;
+ public $extension_list;
+ public $extension;
+ public $extensions_installed;
+
+ // Errors
+ public $code;
+ public $errorMessage;
+
+ // Statistics
+ public $average;
+ public $averageDayOfWeek;
+ public $averageHour;
+ public $averageMonth;
+ public $days;
+ public $entryByCategory;
+ public $entryCount;
+ public $feedByCategory;
+ public $hours24Labels;
+ public $idleFeeds;
+ public $last30DaysLabel;
+ public $last30DaysLabels;
+ public $months;
+ public $repartition;
+ public $repartitionDayOfWeek;
+ public $repartitionHour;
+ public $repartitionMonth;
+ public $topFeed;
+
+}