aboutsummaryrefslogtreecommitdiff
path: root/app/Models/DatabaseDAO.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2023-03-31 08:23:39 +0200
committerGravatar GitHub <noreply@github.com> 2023-03-31 08:23:39 +0200
commit288ed04ccc30b58373576dc3be811aee43e67034 (patch)
tree27f4c571e04d64c97737416dfa2b8d65f481dfd8 /app/Models/DatabaseDAO.php
parentc9d5fe2da12cbc3a071ebf9a518afe2789bb3d61 (diff)
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
Diffstat (limited to 'app/Models/DatabaseDAO.php')
-rw-r--r--app/Models/DatabaseDAO.php18
1 files changed, 14 insertions, 4 deletions
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<array<string,string|bool>> */
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<string> $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<string,string> $dao
+ * @return array<string,string|bool>
+ */
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<array<string,string>> $listDAO
+ * @return array<array<string,string|bool>>
+ */
+ 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");
}