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 --- lib/Minz/ModelPdo.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'lib/Minz/ModelPdo.php') diff --git a/lib/Minz/ModelPdo.php b/lib/Minz/ModelPdo.php index 26b5269a5..86f6df306 100644 --- a/lib/Minz/ModelPdo.php +++ b/lib/Minz/ModelPdo.php @@ -176,8 +176,8 @@ class Minz_ModelPdo { /** * @param array $values - * @phpstan-return ($mode is PDO::FETCH_ASSOC ? array>|null : array|null) - * @return array>|array|null + * @phpstan-return ($mode is PDO::FETCH_ASSOC ? list>|null : list|null) + * @return list>|list|null */ private function fetchAny(string $sql, array $values, int $mode, int $column = 0): ?array { $stm = $this->pdo->prepare($sql); @@ -204,15 +204,15 @@ class Minz_ModelPdo { switch ($mode) { case PDO::FETCH_COLUMN: $res = $stm->fetchAll(PDO::FETCH_COLUMN, $column); + /** @var list $res */ break; case PDO::FETCH_ASSOC: default: $res = $stm->fetchAll(PDO::FETCH_ASSOC); + /** @var list> $res */ break; } - if ($res !== false) { - return $res; - } + return $res; } $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 6); @@ -231,7 +231,7 @@ class Minz_ModelPdo { /** * @param array $values - * @return array>|null + * @return list>|null */ public function fetchAssoc(string $sql, array $values = []): ?array { return $this->fetchAny($sql, $values, PDO::FETCH_ASSOC); @@ -239,7 +239,7 @@ class Minz_ModelPdo { /** * @param array $values - * @return array|null + * @return list|null */ public function fetchColumn(string $sql, int $column, array $values = []): ?array { return $this->fetchAny($sql, $values, PDO::FETCH_COLUMN, $column); @@ -257,6 +257,6 @@ class Minz_ModelPdo { Minz_Log::error('SQL error ' . json_encode($stm->errorInfo()) . ' during ' . $sql); return null; } - return isset($columns[0]) ? (string)$columns[0] : null; + return is_scalar($columns[0] ?? null) ? (string)$columns[0] : null; } } -- cgit v1.2.3