From c88c16eb5eafd835d34a949da9b0bf34c8706768 Mon Sep 17 00:00:00 2001 From: provokateurin Date: Sun, 15 Sep 2024 16:57:11 +0200 Subject: [PATCH] fix(psalm): Adjust types to match private classes Signed-off-by: provokateurin --- lib/ACL/ACLCacheWrapper.php | 6 +++--- lib/AppInfo/Application.php | 3 ++- lib/DAV/GroupFoldersHome.php | 2 +- lib/Folder/FolderManager.php | 10 +++++----- lib/Mount/GroupFolderNoEncryptionStorage.php | 5 +++++ lib/Mount/MountProvider.php | 3 ++- 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/lib/ACL/ACLCacheWrapper.php b/lib/ACL/ACLCacheWrapper.php index b844ba35c..5eca89701 100644 --- a/lib/ACL/ACLCacheWrapper.php +++ b/lib/ACL/ACLCacheWrapper.php @@ -64,19 +64,19 @@ public function getFolderContentsById($fileId) { public function search($pattern) { $results = $this->getCache()->search($pattern); $this->preloadEntries($results); - return array_map([$this, 'formatCacheEntry'], $results); + return array_filter(array_map([$this, 'formatCacheEntry'], $results)); } public function searchByMime($mimetype) { $results = $this->getCache()->searchByMime($mimetype); $this->preloadEntries($results); - return array_map([$this, 'formatCacheEntry'], $results); + return array_filter(array_map([$this, 'formatCacheEntry'], $results)); } public function searchQuery(ISearchQuery $query) { $results = $this->getCache()->searchQuery($query); $this->preloadEntries($results); - return array_map([$this, 'formatCacheEntry'], $results); + return array_filter(array_map([$this, 'formatCacheEntry'], $results)); } /** diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 8834fdce1..bafd47ff1 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -7,6 +7,7 @@ namespace OCA\GroupFolders\AppInfo; use OC\Files\Node\LazyFolder; +use OC\Hooks\Emitter; use OCA\Circles\Events\CircleDestroyedEvent; use OCA\DAV\Connector\Sabre\Principal; use OCA\Files\Event\LoadAdditionalScriptsEvent; @@ -228,7 +229,7 @@ public function register(IRegistrationContext $context): void { } public function boot(IBootContext $context): void { - $context->injectFn(function (IMountProviderCollection $mountProviderCollection, CacheListener $cacheListener, IGroupManager $groupManager): void { + $context->injectFn(function (IMountProviderCollection $mountProviderCollection, CacheListener $cacheListener, IGroupManager&Emitter $groupManager): void { $mountProviderCollection->registerProvider($this->getMountProvider()); $groupManager->listen('\OC\Group', 'postDelete', function (IGroup $group) { diff --git a/lib/DAV/GroupFoldersHome.php b/lib/DAV/GroupFoldersHome.php index e72af6387..2e3c39559 100644 --- a/lib/DAV/GroupFoldersHome.php +++ b/lib/DAV/GroupFoldersHome.php @@ -77,7 +77,7 @@ private function getFolder(string $name): ?array { private function getDirectoryForFolder(array $folder): GroupFolderNode { $userHome = '/' . $this->user->getUID() . '/files'; $node = $this->rootFolder->get($userHome . '/' . $folder['mount_point']); - return new GroupFolderNode(Filesystem::getView($userHome), $node, $folder['folder_id']); + return new GroupFolderNode(Filesystem::getView(), $node, $folder['folder_id']); } public function getChild($name) { diff --git a/lib/Folder/FolderManager.php b/lib/Folder/FolderManager.php index a41b42353..7c7a7ab9b 100644 --- a/lib/Folder/FolderManager.php +++ b/lib/Folder/FolderManager.php @@ -7,6 +7,7 @@ namespace OCA\GroupFolders\Folder; use OC\Files\Cache\Cache; +use OC\Files\Cache\CacheEntry; use OC\Files\Node\Node; use OCA\Circles\CirclesManager; use OCA\Circles\CirclesQueryHelper; @@ -18,7 +19,6 @@ use OCP\DB\Exception; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\EventDispatcher\IEventDispatcher; -use OCP\Files\Cache\ICacheEntry; use OCP\Files\IMimeTypeLoader; use OCP\Files\IRootFolder; use OCP\IConfig; @@ -482,7 +482,7 @@ public function searchUsers(int $id, string $search = '', int $limit = 10, int $ /** * @param string $groupId * @param int $rootStorageId - * @return list + * @return list * @throws Exception */ public function getFoldersForGroup(string $groupId, int $rootStorageId = 0): array { @@ -534,7 +534,7 @@ public function getFoldersForGroup(string $groupId, int $rootStorageId = 0): arr /** * @param string[] $groupIds * @param int $rootStorageId - * @return array{folder_id: int, mount_point: string, permissions: int, quota: int, acl: bool, rootCacheEntry: ?ICacheEntry}[] + * @return array{folder_id: int, mount_point: string, permissions: int, quota: int, acl: bool, rootCacheEntry: ?CacheEntry}[] * @throws Exception */ public function getFoldersForGroups(array $groupIds, int $rootStorageId = 0): array { @@ -592,7 +592,7 @@ public function getFoldersForGroups(array $groupIds, int $rootStorageId = 0): ar /** * @param string[] $groupIds * @param int $rootStorageId - * @return array{folder_id: int, mount_point: string, permissions: int, quota: int, acl: bool, rootCacheEntry: ?ICacheEntry}[] + * @return array{folder_id: int, mount_point: string, permissions: int, quota: int, acl: bool, rootCacheEntry: ?CacheEntry}[] * @throws Exception */ public function getFoldersFromCircleMemberships(IUser $user, int $rootStorageId = 0): array { @@ -877,7 +877,7 @@ public function setFolderACL(int $folderId, bool $acl): void { /** * @param IUser $user * @param int $rootStorageId - * @return list + * @return list * @throws Exception */ public function getFoldersForUser(IUser $user, int $rootStorageId = 0): array { diff --git a/lib/Mount/GroupFolderNoEncryptionStorage.php b/lib/Mount/GroupFolderNoEncryptionStorage.php index 9b1dbd18a..3cad1f7e6 100644 --- a/lib/Mount/GroupFolderNoEncryptionStorage.php +++ b/lib/Mount/GroupFolderNoEncryptionStorage.php @@ -10,5 +10,10 @@ use OCP\Files\Storage\IDisableEncryptionStorage; +/** + * @psalm-suppress UnimplementedInterfaceMethod + * Psalm gets confused about missing methods, but those are implemented in OC\Files\Storage\Wrapper\Wrapper, + * so this suppression is fine and necessary as there is nothing wrong. + */ class GroupFolderNoEncryptionStorage extends GroupFolderStorage implements IDisableEncryptionStorage { } diff --git a/lib/Mount/MountProvider.php b/lib/Mount/MountProvider.php index 5d34a1eb2..dff103d83 100644 --- a/lib/Mount/MountProvider.php +++ b/lib/Mount/MountProvider.php @@ -6,6 +6,7 @@ namespace OCA\GroupFolders\Mount; +use OC\Files\Cache\CacheEntry; use OC\Files\Storage\Wrapper\Jail; use OC\Files\Storage\Wrapper\PermissionsMask; use OCA\GroupFolders\ACL\ACLManager; @@ -102,7 +103,7 @@ private function getRootStorageId(): int { } /** - * @return list + * @return list */ public function getFoldersForUser(IUser $user): array { return $this->folderManager->getFoldersForUser($user, $this->getRootStorageId());