mirror of
https://github.com/nextcloud/server.git
synced 2026-04-15 22:11:17 -04:00
fix(IResult): Use more accurate conditional return type for fetchAll
Signed-off-by: provokateurin <kate@provokateurin.de>
This commit is contained in:
parent
4a9e04962c
commit
83fbc64c99
4 changed files with 17 additions and 29 deletions
|
|
@ -89,13 +89,13 @@ class ProviderUserAssignmentDao {
|
|||
->where($qb2->expr()->eq('uid', $qb2->createNamedParameter($uid)));
|
||||
$deleteQuery->executeStatement();
|
||||
|
||||
return array_values(array_map(function (array $row) {
|
||||
return array_map(function (array $row) {
|
||||
return [
|
||||
'provider_id' => (string)$row['provider_id'],
|
||||
'uid' => (string)$row['uid'],
|
||||
'enabled' => ((int)$row['enabled']) === 1,
|
||||
];
|
||||
}, $rows));
|
||||
}, $rows);
|
||||
}
|
||||
|
||||
public function deleteAll(string $providerId): void {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class ArrayResult implements IResult {
|
|||
protected int $count;
|
||||
|
||||
public function __construct(
|
||||
/** @var array<string, mixed> $rows */
|
||||
/** @var list<array<string, mixed>> $rows */
|
||||
protected array $rows,
|
||||
) {
|
||||
$this->count = count($this->rows);
|
||||
|
|
@ -66,52 +66,39 @@ class ArrayResult implements IResult {
|
|||
$row = $this->fetch();
|
||||
if ($row) {
|
||||
return current($row);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#[Override]
|
||||
public function fetchAssociative(): array|false {
|
||||
$row = $this->fetch();
|
||||
if ($row) {
|
||||
/** @var array<string, mixed> $row */
|
||||
return $row;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#[Override]
|
||||
public function fetchNumeric(): array|false {
|
||||
$row = $this->fetch(PDO::FETCH_NUM);
|
||||
if ($row) {
|
||||
/** @var list<mixed> $row */
|
||||
return $row;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return $this->fetch(PDO::FETCH_NUM);
|
||||
}
|
||||
|
||||
#[Override]
|
||||
public function fetchAllNumeric(): array {
|
||||
/** @var list<list<mixed>> $result */
|
||||
$result = $this->fetchAll(PDO::FETCH_NUM);
|
||||
return $result;
|
||||
return $this->fetchAll(PDO::FETCH_NUM);
|
||||
}
|
||||
|
||||
#[Override]
|
||||
public function fetchAllAssociative(): array {
|
||||
/** @var list<array<string,mixed>> $result */
|
||||
$result = $this->fetchAll();
|
||||
return $result;
|
||||
return $this->fetchAll();
|
||||
}
|
||||
|
||||
#[Override]
|
||||
public function fetchFirstColumn(): array {
|
||||
/** @var list<mixed> $result */
|
||||
$result = $this->fetchAll(PDO::FETCH_COLUMN);
|
||||
return $result;
|
||||
return $this->fetchAll(PDO::FETCH_COLUMN);
|
||||
}
|
||||
|
||||
#[Override]
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class QuerySearchHelper {
|
|||
|
||||
|
||||
/**
|
||||
* @return array<array-key, array{id: int, name: string, visibility: int, editable: int, ref_file_id: int, number_files: int}>
|
||||
* @return list<array{id: int, name: string, visibility: int, editable: int, ref_file_id: int, number_files: int}>
|
||||
*/
|
||||
public function findUsedTagsInCaches(ISearchQuery $searchQuery, array $caches): array {
|
||||
$query = $this->getQueryBuilder();
|
||||
|
|
@ -90,6 +90,7 @@ class QuerySearchHelper {
|
|||
$this->applySearchConstraints($query, $searchQuery, $caches);
|
||||
|
||||
$result = $query->executeQuery();
|
||||
/** @var list<array{id: int, name: string, visibility: int, editable: int, ref_file_id: int, number_files: int}> $tags */
|
||||
$tags = $result->fetchAll();
|
||||
$result->closeCursor();
|
||||
return $tags;
|
||||
|
|
|
|||
|
|
@ -39,9 +39,9 @@ interface IResult {
|
|||
public function closeCursor(): bool;
|
||||
|
||||
/**
|
||||
* @param int $fetchMode
|
||||
* @param PDO::FETCH_* $fetchMode
|
||||
*
|
||||
* @return mixed
|
||||
* @return ($fetchMode is PDO::FETCH_ASSOC ? array<string, mixed> : ($fetchMode is PDO::FETCH_NUM ? list<mixed> : mixed))|false
|
||||
*
|
||||
* @since 21.0.0
|
||||
* @note Since 33.0.0, prefer using fetchAssociative/fetchNumeric/fetchOne or iterateAssociate/iterateNumeric instead.
|
||||
|
|
@ -76,9 +76,9 @@ interface IResult {
|
|||
public function fetchOne();
|
||||
|
||||
/**
|
||||
* @param int $fetchMode (one of PDO::FETCH_ASSOC, PDO::FETCH_NUM or PDO::FETCH_COLUMN (2, 3 or 7)
|
||||
* @param PDO::FETCH_* $fetchMode
|
||||
*
|
||||
* @return mixed[]
|
||||
* @return list<($fetchMode is PDO::FETCH_ASSOC ? array<string, mixed> : ($fetchMode is PDO::FETCH_NUM ? list<mixed> : mixed))>
|
||||
*
|
||||
* @since 21.0.0
|
||||
* @note Since 33.0.0, prefer using fetchAllAssociative/fetchAllNumeric/fetchFirstColumn or iterateAssociate/iterateNumeric instead.
|
||||
|
|
|
|||
Loading…
Reference in a new issue