From 288ed04ccc30b58373576dc3be811aee43e67034 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Fri, 31 Mar 2023 08:23:39 +0200 Subject: PHPStan level 6 for all PDO and Exception classes (#5239) * PHPStan level 6 for all PDO and Exception classes Contributes to https://github.com/FreshRSS/FreshRSS/issues/4112 * Fix type * Now also our remaining own librairies * Motivation for a few more files * A few more DAO classes * Last interface --- app/Models/DatabaseDAO.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'app/Models/DatabaseDAO.php') diff --git a/app/Models/DatabaseDAO.php b/app/Models/DatabaseDAO.php index bf9cbb2d3..28dd36cd9 100644 --- a/app/Models/DatabaseDAO.php +++ b/app/Models/DatabaseDAO.php @@ -63,13 +63,15 @@ class FreshRSS_DatabaseDAO extends Minz_ModelPdo { return count(array_keys($tables, true, true)) == count($tables); } + /** @return array> */ public function getSchema(string $table): array { $sql = 'DESC `_' . $table . '`'; $stm = $this->pdo->query($sql); return $this->listDaoToSchema($stm->fetchAll(PDO::FETCH_ASSOC)); } - public function checkTable(string $table, $schema): bool { + /** @param array $schema */ + public function checkTable(string $table, array $schema): bool { $columns = $this->getSchema($table); $ok = (count($columns) == count($schema)); @@ -120,6 +122,10 @@ class FreshRSS_DatabaseDAO extends Minz_ModelPdo { )); } + /** + * @param array $dao + * @return array + */ public function daoToSchema(array $dao): array { return array( 'name' => $dao['Field'], @@ -129,7 +135,11 @@ class FreshRSS_DatabaseDAO extends Minz_ModelPdo { ); } - public function listDaoToSchema($listDAO): array { + /** + * @param array> $listDAO + * @return array> + */ + public function listDaoToSchema(array $listDAO): array { $list = array(); foreach ($listDAO as $dao) { @@ -185,14 +195,14 @@ class FreshRSS_DatabaseDAO extends Minz_ModelPdo { return $ok; } - public function minorDbMaintenance() { + public function minorDbMaintenance(): void { $catDAO = FreshRSS_Factory::createCategoryDao(); $catDAO->resetDefaultCategoryName(); $this->ensureCaseInsensitiveGuids(); } - private static function stdError($error): bool { + private static function stdError(string $error): bool { if (defined('STDERR')) { fwrite(STDERR, $error . "\n"); } -- cgit v1.2.3