From b1d24fbdb7d1cc948c946295035dad6df550fb7e Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Fri, 27 Dec 2024 12:12:49 +0100 Subject: PHPStan 2.0 (#7131) * PHPStan 2.0 fix https://github.com/FreshRSS/FreshRSS/issues/6989 https://github.com/phpstan/phpstan/releases/tag/2.0.0 https://github.com/phpstan/phpstan/blob/2.0.x/UPGRADING.md * More * More * Done * fix i18n CLI * Restore a PHPStan Next test For work towards PHPStan Level 10 * 4 more on Level 10 * fix getTagsForEntry * API at Level 10 * More Level 10 * Finish Minz at Level 10 * Finish CLI at Level 10 * Finish Controllers at Level 10 * More Level 10 * More * Pass bleedingEdge * Clean PHPStan options and add TODOs * Level 10 for main config * More * Consitency array vs. list * Sanitize themes get_infos * Simplify TagDAO->getTagsForEntries() * Finish reportAnyTypeWideningInVarTag * Prepare checkBenevolentUnionTypes and checkImplicitMixed * Fixes * Refix * Another fix * Casing of __METHOD__ constant --- app/Models/DatabaseDAOSQLite.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'app/Models/DatabaseDAOSQLite.php') diff --git a/app/Models/DatabaseDAOSQLite.php b/app/Models/DatabaseDAOSQLite.php index 231616f49..f59f6c9ae 100644 --- a/app/Models/DatabaseDAOSQLite.php +++ b/app/Models/DatabaseDAOSQLite.php @@ -24,18 +24,25 @@ class FreshRSS_DatabaseDAOSQLite extends FreshRSS_DatabaseDAO { $this->pdo->prefix() . 'entrytag' => false, ]; foreach ($res as $value) { - $tables[$value['name']] = true; + if (is_array($value) && is_string($value['name'] ?? null)) { + $tables[$value['name']] = true; + } } return count(array_keys($tables, true, true)) == count($tables); } - /** @return array */ + /** @return list */ #[\Override] public function getSchema(string $table): array { $sql = 'PRAGMA table_info(' . $table . ')'; $stm = $this->pdo->query($sql); - return $stm !== false ? $this->listDaoToSchema($stm->fetchAll(PDO::FETCH_ASSOC) ?: []) : []; + if ($stm !== false) { + $res = $stm->fetchAll(PDO::FETCH_ASSOC); + /** @var list $res */ + return $this->listDaoToSchema($res ?: []); + } + return []; } #[\Override] @@ -59,10 +66,10 @@ class FreshRSS_DatabaseDAOSQLite extends FreshRSS_DatabaseDAO { #[\Override] public function daoToSchema(array $dao): array { return [ - 'name' => (string)$dao['name'], - 'type' => strtolower((string)$dao['type']), - 'notnull' => $dao['notnull'] == '1' ? true : false, - 'default' => $dao['dflt_value'], + 'name' => is_string($dao['name'] ?? null) ? $dao['name'] : '', + 'type' => is_string($dao['type'] ?? null) ? strtolower($dao['type']) : '', + 'notnull' => empty($dao['notnull']), + 'default' => is_scalar($dao['dflt_value'] ?? null) ? $dao['dflt_value'] : null, ]; } -- cgit v1.2.3