Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(psalm): Enable more/less specific issue handlers #3184

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Loading