diff options
| author | 2022-02-05 11:47:28 +0100 | |
|---|---|---|
| committer | 2022-02-05 11:47:28 +0100 | |
| commit | 87b181af21ad3644e30bdf44b6704083c8a391a2 (patch) | |
| tree | 1989db531aebf9b29ccb8ce2f1e9c4a1e43cf22d /app/Models/DatabaseDAOPGSQL.php | |
| parent | 4d5f3a20c0fee4f4fde160cc3a811289429795e1 (diff) | |
Draft:Add interface and add typehinting (#4130)
* Add interface and add typehinting
* Simplify and complete
* inheritdoc
Co-authored-by: Luc SANCHEZ <l.sanchez-ext@ubitransport.com>
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Diffstat (limited to 'app/Models/DatabaseDAOPGSQL.php')
| -rw-r--r-- | app/Models/DatabaseDAOPGSQL.php | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/app/Models/DatabaseDAOPGSQL.php b/app/Models/DatabaseDAOPGSQL.php index 75b01c90b..83332a027 100644 --- a/app/Models/DatabaseDAOPGSQL.php +++ b/app/Models/DatabaseDAOPGSQL.php @@ -9,7 +9,7 @@ class FreshRSS_DatabaseDAOPGSQL extends FreshRSS_DatabaseDAOSQLite { const UNDEFINED_COLUMN = '42703'; const UNDEFINED_TABLE = '42P01'; - public function tablesAreCorrect() { + public function tablesAreCorrect(): bool { $db = FreshRSS_Context::$system_conf->db; $dbowner = $db['user']; $sql = 'SELECT * FROM pg_catalog.pg_tables where tableowner=?'; @@ -33,14 +33,14 @@ class FreshRSS_DatabaseDAOPGSQL extends FreshRSS_DatabaseDAOSQLite { return count(array_keys($tables, true, true)) == count($tables); } - public function getSchema($table) { + public function getSchema(string $table): array { $sql = 'select column_name as field, data_type as type, column_default as default, is_nullable as null from INFORMATION_SCHEMA.COLUMNS where table_name = ?'; $stm = $this->pdo->prepare($sql); $stm->execute(array($this->pdo->prefix() . $table)); return $this->listDaoToSchema($stm->fetchAll(PDO::FETCH_ASSOC)); } - public function daoToSchema($dao) { + public function daoToSchema(array $dao): array { return array( 'name' => $dao['field'], 'type' => strtolower($dao['type']), @@ -49,7 +49,7 @@ class FreshRSS_DatabaseDAOPGSQL extends FreshRSS_DatabaseDAOSQLite { ); } - public function size($all = false) { + public function size(bool $all = false): int { if ($all) { $db = FreshRSS_Context::$system_conf->db; $sql = 'SELECT pg_database_size(:base)'; @@ -72,10 +72,11 @@ SQL; return 0; } $res = $stm->fetchAll(PDO::FETCH_COLUMN, 0); - return $res[0]; + return intval($res[0]); } - public function optimize() { + + public function optimize(): bool { $ok = true; $tables = array('category', 'feed', 'entry', 'entrytmp', 'tag', 'entrytag'); |
