diff options
| author | 2024-12-27 12:12:49 +0100 | |
|---|---|---|
| committer | 2024-12-27 12:12:49 +0100 | |
| commit | b1d24fbdb7d1cc948c946295035dad6df550fb7e (patch) | |
| tree | 7b4365a04097a779659474fbb9281a9661512522 /app/Models/DatabaseDAOSQLite.php | |
| parent | 897e4a3f4a273d50c28157edb67612b2d7fa2e6f (diff) | |
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
Diffstat (limited to 'app/Models/DatabaseDAOSQLite.php')
| -rw-r--r-- | app/Models/DatabaseDAOSQLite.php | 21 |
1 files changed, 14 insertions, 7 deletions
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<array{name:string,type:string,notnull:bool,default:mixed}> */ + /** @return list<array{name:string,type:string,notnull:bool,default:mixed}> */ #[\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<array{name:string,type:string,notnull:bool,dflt_value:string|int|bool|null}> $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, ]; } |
