Skip to content

Commit

Permalink
Merge pull request #3184 from nextcloud/feat/psalm/more-less-specific…
Browse files Browse the repository at this point in the history
…-errors
  • Loading branch information
provokateurin authored Sep 9, 2024
2 parents cca16eb + 71a17dc commit 9d6265a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
6 changes: 3 additions & 3 deletions lib/Folder/FolderManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ public function getFoldersForGroup(string $groupId, int $rootStorageId = 0): arr
$this->joinQueryWithFileCache($query, $rootStorageId);

$result = $query->executeQuery()->fetchAll();
return array_map(function ($folder): array {
return array_values(array_map(function ($folder): array {
return [
'folder_id' => (int)$folder['folder_id'],
'mount_point' => (string)$folder['mount_point'],
Expand All @@ -528,7 +528,7 @@ public function getFoldersForGroup(string $groupId, int $rootStorageId = 0): arr
'acl' => (bool)$folder['acl'],
'rootCacheEntry' => (isset($folder['fileid'])) ? Cache::cacheEntryFromData($folder, $this->mimeTypeLoader) : null
];
}, $result);
}, $result));
}

/**
Expand Down Expand Up @@ -877,7 +877,7 @@ public function setFolderACL(int $folderId, bool $acl): void {
/**
* @param IUser $user
* @param int $rootStorageId
* @return array{folder_id: int, mount_point: string, permissions: int, quota: int, acl: bool, rootCacheEntry: ?ICacheEntry}[]
* @return list<array{folder_id: int, mount_point: string, permissions: int, quota: int, acl: bool, rootCacheEntry: ?ICacheEntry}>
* @throws Exception
*/
public function getFoldersForUser(IUser $user, int $rootStorageId = 0): array {
Expand Down
9 changes: 6 additions & 3 deletions lib/Trash/TrashBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,16 +277,19 @@ private function getNodeForTrashItem(IUser $user, ITrashItem $trashItem): ?Node

private function getTrashRoot(): Folder {
try {
return $this->appFolder->get('trash');
/** @var Folder $folder */
$folder = $this->appFolder->get('trash');
return $folder;
} catch (NotFoundException $e) {
return $this->appFolder->newFolder('trash');
;
}
}

private function getTrashFolder(int $folderId): Folder {
try {
return $this->appFolder->get('trash/' . $folderId);
/** @var Folder $folder */
$folder = $this->appFolder->get('trash/' . $folderId);
return $folder;
} catch (NotFoundException $e) {
/** @var Folder $trashRoot */
$trashRoot = $this->appFolder->nodeExists('trash') ? $this->appFolder->get('trash') : $this->appFolder->newFolder('trash');
Expand Down
4 changes: 3 additions & 1 deletion lib/Versions/VersionsBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,9 @@ public function deleteAllVersionsForFile(int $folderId, int $fileId): void {

private function getVersionsFolder(int $folderId): Folder {
try {
return $this->appFolder->get('versions/' . $folderId);
/** @var Folder $folder */
$folder = $this->appFolder->get('versions/' . $folderId);
return $folder;
} catch (NotFoundException $e) {
/** @var Folder $trashRoot */
$trashRoot = $this->appFolder->nodeExists('versions') ? $this->appFolder->get('versions') : $this->appFolder->newFolder('versions');
Expand Down
4 changes: 4 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,9 @@
<referencedClass name="OCA\Settings\Service\AuthorizedGroupService"/>
</errorLevel>
</UndefinedDocblockClass>
<LessSpecificReturnStatement errorLevel="error"/>
<LessSpecificReturnType errorLevel="error"/>
<LessSpecificImplementedReturnType errorLevel="error"/>
<MoreSpecificReturnType errorLevel="error"/>
</issueHandlers>
</psalm>

0 comments on commit 9d6265a

Please sign in to comment.