From 9682fa595a8b737b2cc02b1f3383a8591b3592d5 Mon Sep 17 00:00:00 2001 From: flashwave Date: Thu, 31 Aug 2023 17:14:41 +0000 Subject: [PATCH] Fixed static analysis detections. --- src/Emoticons/Emotes.php | 2 +- src/Forum/Forum.php | 8 ++++++-- src/Forum/ForumTopicRedirectInfo.php | 2 +- src/News/News.php | 9 --------- src/Perm.php | 7 ++++--- src/Perms/PermissionInfo.php | 6 +++--- src/Users/Assets/AssetsRoutes.php | 4 ++-- 7 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/Emoticons/Emotes.php b/src/Emoticons/Emotes.php index f29c74f..6d676d0 100644 --- a/src/Emoticons/Emotes.php +++ b/src/Emoticons/Emotes.php @@ -57,7 +57,7 @@ class Emotes { $query .= sprintf(' ORDER BY %s', self::EMOTE_ORDER[$orderBy]); if($hasReverse) - $query .= $hasReverse ? ' DESC' : ' ASC'; + $query .= $reverse ? ' DESC' : ' ASC'; } $stmt = $this->cache->get($query); diff --git a/src/Forum/Forum.php b/src/Forum/Forum.php index 590c20b..6f16f4f 100644 --- a/src/Forum/Forum.php +++ b/src/Forum/Forum.php @@ -55,10 +55,11 @@ class Forum { ForumCategoryInfo|string|null|false $parentInfo = false, string|int|null $type = null, ?bool $hidden = null - ): array { + ): int { if($parentInfo instanceof ForumCategoryInfo) $parentInfo = $parentInfo->getId(); + $isRootParent = false; $hasParentInfo = $parentInfo !== false; $hasType = $type !== null; $hasHidden = $hidden !== null; @@ -89,7 +90,7 @@ class Forum { $args = 0; $stmt = $this->cache->get($query); if($hasParentInfo && !$isRootParent) - $stmt->addParameter(++$args, $parentInfo->getId()); + $stmt->addParameter(++$args, $parentInfo); if($hasType) $stmt->addParameter(++$args, $type); $stmt->execute(); @@ -105,6 +106,7 @@ class Forum { bool $asTree = false, ?Pagination $pagination = null ): array { + $isRootParent = false; $hasParentInfo = $parentInfo !== false; $hasType = $type !== null; $hasHidden = $hidden !== null; @@ -581,6 +583,7 @@ class Forum { // remove this hack when search server $hasSearchQuery = $searchQuery !== null; $hasAfterTopicId = false; + $afterTopicId = null; $doSearchOrder = false; if($hasSearchQuery) { if(!empty($searchQuery['type']) @@ -1193,6 +1196,7 @@ class Forum { // remove this hack when search server $hasSearchQuery = $searchQuery !== null; $hasAfterPostId = false; + $afterPostId = null; $doSearchOrder = false; if($hasSearchQuery) { if(!empty($searchQuery['type']) diff --git a/src/Forum/ForumTopicRedirectInfo.php b/src/Forum/ForumTopicRedirectInfo.php index b59e868..d16d16d 100644 --- a/src/Forum/ForumTopicRedirectInfo.php +++ b/src/Forum/ForumTopicRedirectInfo.php @@ -8,7 +8,7 @@ class ForumTopicRedirectInfo { private string $topicId; private ?string $userId; private string $link; - private string $created; + private int $created; public function __construct(IDbResult $result) { $this->topicId = (string)$result->getInteger(0); diff --git a/src/News/News.php b/src/News/News.php index dc95539..9350431 100644 --- a/src/News/News.php +++ b/src/News/News.php @@ -20,15 +20,6 @@ class News { $this->cache = new DbStatementCache($dbConn); } - private function readPosts(IDbResult $result): array { - $posts = []; - - while($result->next()) - $posts[] = new NewsPostInfo($result); - - return $posts; - } - public function countCategories( ?bool $hidden = null ): int { diff --git a/src/Perm.php b/src/Perm.php index 1e6058f..1d744c8 100644 --- a/src/Perm.php +++ b/src/Perm.php @@ -317,9 +317,10 @@ final class Perm { $categoryName = $currentCategoryName; $perm = 0; - if(is_array($permInfo)) - [$categoryName, $perm] = $permInfo; - elseif(is_int($permInfo)) + // if(is_array($permInfo)) + // [$categoryName, $perm] = $permInfo; + // else + if(is_int($permInfo)) $perm = $permInfo; $item->perms[] = $permItem = new stdClass; diff --git a/src/Perms/PermissionInfo.php b/src/Perms/PermissionInfo.php index 1a0cc40..d3e0a4b 100644 --- a/src/Perms/PermissionInfo.php +++ b/src/Perms/PermissionInfo.php @@ -15,9 +15,9 @@ class PermissionInfo implements IPermissionResult { private int $calculated; public function __construct(IDbResult $result) { - $this->userId = $result->isNull(0) ? null : $result->getInteger(0); - $this->roleId = $result->isNull(1) ? null : $result->getInteger(1); - $this->forumCategoryId = $result->isNull(2) ? null : $result->getInteger(2); + $this->userId = $result->isNull(0) ? null : $result->getString(0); + $this->roleId = $result->isNull(1) ? null : $result->getString(1); + $this->forumCategoryId = $result->isNull(2) ? null : $result->getString(2); $this->category = $result->getString(3); $this->allow = $result->getInteger(4); $this->deny = $result->getInteger(5); diff --git a/src/Users/Assets/AssetsRoutes.php b/src/Users/Assets/AssetsRoutes.php index e2bfaf9..fa47b60 100644 --- a/src/Users/Assets/AssetsRoutes.php +++ b/src/Users/Assets/AssetsRoutes.php @@ -53,7 +53,7 @@ class AssetsRoutes { } catch(RuntimeException $ex) { } catch(InvalidArgumentException $ex) {} - return $this->serveAsset($response, $request, $assetInfo); + $this->serveAsset($response, $request, $assetInfo); } public function getProfileBackground($response, $request, string $fileName = '') { @@ -76,7 +76,7 @@ class AssetsRoutes { return 404; } - return $this->serveAsset($response, $request, $assetInfo); + $this->serveAsset($response, $request, $assetInfo); } public function getUserAssets($response, $request) {