Fixed static analysis detections.

This commit is contained in:
flash 2023-08-31 17:14:41 +00:00
parent c14195c4c3
commit 9682fa595a
7 changed files with 17 additions and 21 deletions

View file

@ -57,7 +57,7 @@ class Emotes {
$query .= sprintf(' ORDER BY %s', self::EMOTE_ORDER[$orderBy]); $query .= sprintf(' ORDER BY %s', self::EMOTE_ORDER[$orderBy]);
if($hasReverse) if($hasReverse)
$query .= $hasReverse ? ' DESC' : ' ASC'; $query .= $reverse ? ' DESC' : ' ASC';
} }
$stmt = $this->cache->get($query); $stmt = $this->cache->get($query);

View file

@ -55,10 +55,11 @@ class Forum {
ForumCategoryInfo|string|null|false $parentInfo = false, ForumCategoryInfo|string|null|false $parentInfo = false,
string|int|null $type = null, string|int|null $type = null,
?bool $hidden = null ?bool $hidden = null
): array { ): int {
if($parentInfo instanceof ForumCategoryInfo) if($parentInfo instanceof ForumCategoryInfo)
$parentInfo = $parentInfo->getId(); $parentInfo = $parentInfo->getId();
$isRootParent = false;
$hasParentInfo = $parentInfo !== false; $hasParentInfo = $parentInfo !== false;
$hasType = $type !== null; $hasType = $type !== null;
$hasHidden = $hidden !== null; $hasHidden = $hidden !== null;
@ -89,7 +90,7 @@ class Forum {
$args = 0; $args = 0;
$stmt = $this->cache->get($query); $stmt = $this->cache->get($query);
if($hasParentInfo && !$isRootParent) if($hasParentInfo && !$isRootParent)
$stmt->addParameter(++$args, $parentInfo->getId()); $stmt->addParameter(++$args, $parentInfo);
if($hasType) if($hasType)
$stmt->addParameter(++$args, $type); $stmt->addParameter(++$args, $type);
$stmt->execute(); $stmt->execute();
@ -105,6 +106,7 @@ class Forum {
bool $asTree = false, bool $asTree = false,
?Pagination $pagination = null ?Pagination $pagination = null
): array { ): array {
$isRootParent = false;
$hasParentInfo = $parentInfo !== false; $hasParentInfo = $parentInfo !== false;
$hasType = $type !== null; $hasType = $type !== null;
$hasHidden = $hidden !== null; $hasHidden = $hidden !== null;
@ -581,6 +583,7 @@ class Forum {
// remove this hack when search server // remove this hack when search server
$hasSearchQuery = $searchQuery !== null; $hasSearchQuery = $searchQuery !== null;
$hasAfterTopicId = false; $hasAfterTopicId = false;
$afterTopicId = null;
$doSearchOrder = false; $doSearchOrder = false;
if($hasSearchQuery) { if($hasSearchQuery) {
if(!empty($searchQuery['type']) if(!empty($searchQuery['type'])
@ -1193,6 +1196,7 @@ class Forum {
// remove this hack when search server // remove this hack when search server
$hasSearchQuery = $searchQuery !== null; $hasSearchQuery = $searchQuery !== null;
$hasAfterPostId = false; $hasAfterPostId = false;
$afterPostId = null;
$doSearchOrder = false; $doSearchOrder = false;
if($hasSearchQuery) { if($hasSearchQuery) {
if(!empty($searchQuery['type']) if(!empty($searchQuery['type'])

View file

@ -8,7 +8,7 @@ class ForumTopicRedirectInfo {
private string $topicId; private string $topicId;
private ?string $userId; private ?string $userId;
private string $link; private string $link;
private string $created; private int $created;
public function __construct(IDbResult $result) { public function __construct(IDbResult $result) {
$this->topicId = (string)$result->getInteger(0); $this->topicId = (string)$result->getInteger(0);

View file

@ -20,15 +20,6 @@ class News {
$this->cache = new DbStatementCache($dbConn); $this->cache = new DbStatementCache($dbConn);
} }
private function readPosts(IDbResult $result): array {
$posts = [];
while($result->next())
$posts[] = new NewsPostInfo($result);
return $posts;
}
public function countCategories( public function countCategories(
?bool $hidden = null ?bool $hidden = null
): int { ): int {

View file

@ -317,9 +317,10 @@ final class Perm {
$categoryName = $currentCategoryName; $categoryName = $currentCategoryName;
$perm = 0; $perm = 0;
if(is_array($permInfo)) // if(is_array($permInfo))
[$categoryName, $perm] = $permInfo; // [$categoryName, $perm] = $permInfo;
elseif(is_int($permInfo)) // else
if(is_int($permInfo))
$perm = $permInfo; $perm = $permInfo;
$item->perms[] = $permItem = new stdClass; $item->perms[] = $permItem = new stdClass;

View file

@ -15,9 +15,9 @@ class PermissionInfo implements IPermissionResult {
private int $calculated; private int $calculated;
public function __construct(IDbResult $result) { public function __construct(IDbResult $result) {
$this->userId = $result->isNull(0) ? null : $result->getInteger(0); $this->userId = $result->isNull(0) ? null : $result->getString(0);
$this->roleId = $result->isNull(1) ? null : $result->getInteger(1); $this->roleId = $result->isNull(1) ? null : $result->getString(1);
$this->forumCategoryId = $result->isNull(2) ? null : $result->getInteger(2); $this->forumCategoryId = $result->isNull(2) ? null : $result->getString(2);
$this->category = $result->getString(3); $this->category = $result->getString(3);
$this->allow = $result->getInteger(4); $this->allow = $result->getInteger(4);
$this->deny = $result->getInteger(5); $this->deny = $result->getInteger(5);

View file

@ -53,7 +53,7 @@ class AssetsRoutes {
} catch(RuntimeException $ex) { } catch(RuntimeException $ex) {
} catch(InvalidArgumentException $ex) {} } catch(InvalidArgumentException $ex) {}
return $this->serveAsset($response, $request, $assetInfo); $this->serveAsset($response, $request, $assetInfo);
} }
public function getProfileBackground($response, $request, string $fileName = '') { public function getProfileBackground($response, $request, string $fileName = '') {
@ -76,7 +76,7 @@ class AssetsRoutes {
return 404; return 404;
} }
return $this->serveAsset($response, $request, $assetInfo); $this->serveAsset($response, $request, $assetInfo);
} }
public function getUserAssets($response, $request) { public function getUserAssets($response, $request) {