From aeb65d8bc7c75640b077d19a4269a0fc4640e978 Mon Sep 17 00:00:00 2001 From: provokateurin Date: Sat, 21 Sep 2024 10:12:03 +0200 Subject: [PATCH 1/4] test(psalm): Fix types Signed-off-by: provokateurin --- tests/ACL/ACLScannerTest.php | 3 +++ tests/ACL/ACLStorageWrapperTest.php | 1 + tests/ACL/RuleManagerTest.php | 4 +++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/ACL/ACLScannerTest.php b/tests/ACL/ACLScannerTest.php index c6f72b523..622f0632d 100644 --- a/tests/ACL/ACLScannerTest.php +++ b/tests/ACL/ACLScannerTest.php @@ -40,6 +40,7 @@ public function testScanAclStorage(): void { $cache->calculateFolderSize('foo/bar'); $cache->calculateFolderSize('foo'); + /** @psalm-suppress PossiblyFalseReference */ $this->assertEquals(-1, $cache->get('foo/bar')->getSize()); $acls = $this->getAclManager([ @@ -57,8 +58,10 @@ public function testScanAclStorage(): void { $aclCache = $aclStorage->getCache(); $scanner->scan(''); + /** @psalm-suppress PossiblyFalseReference */ $this->assertEquals(0, $cache->get('foo/bar')->getSize()); + /** @psalm-suppress PossiblyFalseReference */ $this->assertEquals(31, $cache->get('foo/bar')->getPermissions()); $this->assertEquals(false, $aclCache->get('foo/bar')); } diff --git a/tests/ACL/ACLStorageWrapperTest.php b/tests/ACL/ACLStorageWrapperTest.php index 6eabafd46..e448d7b17 100644 --- a/tests/ACL/ACLStorageWrapperTest.php +++ b/tests/ACL/ACLStorageWrapperTest.php @@ -59,6 +59,7 @@ public function testOpenDir(): void { $dh = $this->storage->opendir('foo'); $result = []; + /** @psalm-suppress PossiblyFalseArgument */ while ($file = readdir($dh)) { $result[] = $file; } diff --git a/tests/ACL/RuleManagerTest.php b/tests/ACL/RuleManagerTest.php index 6db0cc766..c4272b861 100644 --- a/tests/ACL/RuleManagerTest.php +++ b/tests/ACL/RuleManagerTest.php @@ -40,7 +40,9 @@ protected function setUp(): void { $this->userMappingManager = $this->createMock(IUserMappingManager::class); $this->userMappingManager->expects($this->any()) ->method('mappingFromId') - ->willReturnCallback(fn (string $type, string $id): UserMapping => new UserMapping($type, $id)); + ->willReturnCallback(fn (string $type, string $id): UserMapping => + /** @var 'user'|'group'|'dummy' $type */ + new UserMapping($type, $id)); $this->eventDispatcher = $this->createMock(IEventDispatcher::class); $this->ruleManager = new RuleManager(Server::get(IDBConnection::class), $this->userMappingManager, $this->eventDispatcher); From 88a14b6b1e8de9ec26484321971373cdc83688d3 Mon Sep 17 00:00:00 2001 From: provokateurin Date: Sat, 21 Sep 2024 13:01:07 +0200 Subject: [PATCH 2/4] chore(psalm): Add missing exception stubs Signed-off-by: provokateurin --- psalm.xml | 22 ++ tests/stubs/doctrine_dbal_exception.php | 80 ++++++++ .../doctrine_dbal_schema_schemaexception.php | 188 ++++++++++++++++++ tests/stubs/oc_files_cache_cache.php | 2 +- tests/stubs/oc_server.php | 1 + tests/stubs/oc_user_nouserexception.php | 11 + ...tions_federateditembadrequestexception.php | 35 ++++ ...xceptions_federateditemremoteexception.php | 35 ++++ ...xceptions_federateditemserverexception.php | 35 ++++ ...ons_federateditemunauthorizedexception.php | 35 ++++ ...cles_exceptions_federateduserexception.php | 15 ++ ...eptions_federatedusernotfoundexception.php | 15 ++ ..._exceptions_initiatornotfoundexception.php | 14 ++ ..._circles_exceptions_invalididexception.php | 17 ++ ...les_exceptions_membernotfoundexception.php | 19 ++ ...cles_exceptions_ownernotfoundexception.php | 15 ++ ...les_exceptions_remoteinstanceexception.php | 20 ++ ...les_exceptions_remotenotfoundexception.php | 19 ++ ...ptions_remoteresourcenotfoundexception.php | 14 ++ ...les_exceptions_requestbuilderexception.php | 14 ++ ...ceptions_singlecirclenotfoundexception.php | 20 ++ ...cles_exceptions_unknownremoteexception.php | 15 ++ ...s_exceptions_usertypenotfoundexception.php | 15 ++ ...ole_exception_invalidargumentexception.php | 19 ++ ...onent_console_exception_logicexception.php | 19 ++ 25 files changed, 693 insertions(+), 1 deletion(-) create mode 100644 tests/stubs/doctrine_dbal_exception.php create mode 100644 tests/stubs/doctrine_dbal_schema_schemaexception.php create mode 100644 tests/stubs/oc_user_nouserexception.php create mode 100644 tests/stubs/oca_circles_exceptions_federateditembadrequestexception.php create mode 100644 tests/stubs/oca_circles_exceptions_federateditemremoteexception.php create mode 100644 tests/stubs/oca_circles_exceptions_federateditemserverexception.php create mode 100644 tests/stubs/oca_circles_exceptions_federateditemunauthorizedexception.php create mode 100644 tests/stubs/oca_circles_exceptions_federateduserexception.php create mode 100644 tests/stubs/oca_circles_exceptions_federatedusernotfoundexception.php create mode 100644 tests/stubs/oca_circles_exceptions_initiatornotfoundexception.php create mode 100644 tests/stubs/oca_circles_exceptions_invalididexception.php create mode 100644 tests/stubs/oca_circles_exceptions_membernotfoundexception.php create mode 100644 tests/stubs/oca_circles_exceptions_ownernotfoundexception.php create mode 100644 tests/stubs/oca_circles_exceptions_remoteinstanceexception.php create mode 100644 tests/stubs/oca_circles_exceptions_remotenotfoundexception.php create mode 100644 tests/stubs/oca_circles_exceptions_remoteresourcenotfoundexception.php create mode 100644 tests/stubs/oca_circles_exceptions_requestbuilderexception.php create mode 100644 tests/stubs/oca_circles_exceptions_singlecirclenotfoundexception.php create mode 100644 tests/stubs/oca_circles_exceptions_unknownremoteexception.php create mode 100644 tests/stubs/oca_circles_exceptions_usertypenotfoundexception.php create mode 100644 tests/stubs/symfony_component_console_exception_invalidargumentexception.php create mode 100644 tests/stubs/symfony_component_console_exception_logicexception.php diff --git a/psalm.xml b/psalm.xml index 359397355..4331ef230 100644 --- a/psalm.xml +++ b/psalm.xml @@ -14,9 +14,11 @@ findUnusedCode="false" > + + @@ -56,14 +58,32 @@ + + + + + + + + + + + + + + + + + + @@ -96,6 +116,8 @@ + + diff --git a/tests/stubs/doctrine_dbal_exception.php b/tests/stubs/doctrine_dbal_exception.php new file mode 100644 index 000000000..f7e016673 --- /dev/null +++ b/tests/stubs/doctrine_dbal_exception.php @@ -0,0 +1,80 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Exception; + +/** + * @author Jérôme Tamarelle + */ +class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface +{ +} diff --git a/tests/stubs/symfony_component_console_exception_logicexception.php b/tests/stubs/symfony_component_console_exception_logicexception.php new file mode 100644 index 000000000..fc37b8d8a --- /dev/null +++ b/tests/stubs/symfony_component_console_exception_logicexception.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Exception; + +/** + * @author Jérôme Tamarelle + */ +class LogicException extends \LogicException implements ExceptionInterface +{ +} From 92fa99d7b9b27fa6596df02a3a43ec3153b9c0b8 Mon Sep 17 00:00:00 2001 From: provokateurin Date: Sat, 21 Sep 2024 13:05:12 +0200 Subject: [PATCH 3/4] fix(psalm): Fix all @throws annotations and add missing ones Signed-off-by: provokateurin --- lib/ACL/ACLManager.php | 5 ++ lib/ACL/ACLStorageWrapper.php | 2 + lib/ACL/RuleManager.php | 18 +++++++ lib/AppInfo/Application.php | 6 +++ lib/AppInfo/Capabilities.php | 10 ++++ lib/AuthorizedAdminSettingMiddleware.php | 1 + lib/BackgroundJob/ExpireGroupVersions.php | 2 + lib/Command/Create.php | 13 +++++ lib/Command/ExpireGroup/ExpireGroupBase.php | 8 +++ .../ExpireGroupVersionsPlaceholder.php | 4 ++ lib/Command/FolderCommand.php | 9 +++- lib/Command/ListCommand.php | 14 ++++- lib/Command/Trashbin/Cleanup.php | 18 +++++++ lib/Controller/DelegationController.php | 13 +++++ lib/Controller/FolderController.php | 54 ++++++++++++++++++- lib/DAV/ACLPlugin.php | 10 ++++ lib/DAV/GroupFoldersHome.php | 30 +++++++++++ lib/DAV/PropFindPlugin.php | 6 +++ lib/DAV/RootCollection.php | 2 + lib/Folder/FolderManager.php | 36 ++++++++----- .../CircleDestroyedEventListener.php | 4 ++ lib/Listeners/NodeRenamedListener.php | 6 +++ .../Version1000000Date20210216085047.php | 4 ++ .../Version102020Date20180806161449.php | 4 ++ .../Version103000Date20180806161724.php | 8 +++ .../Version104000Date20180918132853.php | 4 ++ .../Version1401000Date20230426112001.php | 4 ++ .../Version1401000Date20230426112002.php | 4 ++ .../Version16000Date20230821085801.php | 4 ++ .../Version19000Date20240903062631.php | 4 ++ .../Version201000Date20190111132839.php | 4 ++ .../Version201000Date20190212150323.php | 4 ++ .../Version300000Date20240905185515.php | 4 ++ .../Version401001Date20190715092137.php | 4 ++ .../Version501000Date20190927102434.php | 4 ++ .../Version501000Date20191218182434.php | 4 ++ .../Version802000Date20201119112624.php | 7 +++ lib/Migration/WrongDefaultQuotaRepairStep.php | 4 -- lib/Mount/GroupMountPoint.php | 4 ++ lib/Mount/MountProvider.php | 31 ++++++++++- lib/Service/DelegationService.php | 13 +++++ lib/Trash/TrashBackend.php | 7 --- lib/Trash/TrashManager.php | 20 +++++++ lib/Versions/GroupVersionsExpireManager.php | 5 ++ lib/Versions/GroupVersionsMapper.php | 17 ++++++ 45 files changed, 409 insertions(+), 30 deletions(-) diff --git a/lib/ACL/ACLManager.php b/lib/ACL/ACLManager.php index 4e6891568..5151b3133 100644 --- a/lib/ACL/ACLManager.php +++ b/lib/ACL/ACLManager.php @@ -11,6 +11,7 @@ use OCA\GroupFolders\Trash\TrashManager; use OCP\Cache\CappedMemoryCache; use OCP\Constants; +use OCP\DB\Exception; use OCP\Files\IRootFolder; use OCP\IUser; use Psr\Log\LoggerInterface; @@ -206,6 +207,7 @@ private function calculatePermissionsForPath(array $rules): int { /** * Get the combined "lowest" permissions for an entire directory tree + * @throws Exception */ public function getPermissionsForTree(string $path): int { $path = ltrim($path, '/'); @@ -223,6 +225,9 @@ public function getPermissionsForTree(string $path): int { }, Constants::PERMISSION_ALL); } + /** + * @throws Exception + */ public function preloadRulesForFolder(string $path): void { $this->ruleManager->getRulesForFilesByParent($this->user, $this->getRootStorageId(), $path); } diff --git a/lib/ACL/ACLStorageWrapper.php b/lib/ACL/ACLStorageWrapper.php index 5d14a8c1c..af24524d9 100644 --- a/lib/ACL/ACLStorageWrapper.php +++ b/lib/ACL/ACLStorageWrapper.php @@ -12,6 +12,7 @@ use OC\Files\Cache\Scanner; use OC\Files\Storage\Wrapper\Wrapper; use OCP\Constants; +use OCP\DB\Exception; use OCP\Files\Cache\ICache; use OCP\Files\Storage\IStorage; @@ -148,6 +149,7 @@ public function unlink($path): bool { /** * When deleting we need to ensure that there is no file inside the folder being deleted that misses delete permissions * This check is fairly expensive so we only do it for the actual delete and not metadata operations + * @throws Exception */ private function canDeleteTree(string $path): int { return $this->aclManager->getPermissionsForTree($path) & Constants::PERMISSION_DELETE; diff --git a/lib/ACL/RuleManager.php b/lib/ACL/RuleManager.php index 19b08179a..67b6ed63e 100644 --- a/lib/ACL/RuleManager.php +++ b/lib/ACL/RuleManager.php @@ -10,6 +10,7 @@ use OCA\GroupFolders\ACL\UserMapping\IUserMapping; use OCA\GroupFolders\ACL\UserMapping\IUserMappingManager; +use OCP\DB\Exception; use OCP\DB\QueryBuilder\ICompositeExpression; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\EventDispatcher\IEventDispatcher; @@ -42,6 +43,7 @@ private function createRule(array $data): ?Rule { /** * @param int[] $fileIds * @return array + * @throws Exception */ public function getRulesForFilesById(IUser $user, array $fileIds): array { $userMappings = $this->userMappingManager->getMappingsForUser($user); @@ -107,6 +109,7 @@ public function getRulesForFilesByPath(IUser $user, int $storageId, array $fileP /** * @return array + * @throws Exception */ public function getRulesForFilesByParent(IUser $user, int $storageId, string $parent): array { $userMappings = $this->userMappingManager->getMappingsForUser($user); @@ -153,6 +156,9 @@ public function getRulesForFilesByParent(IUser $user, int $storageId, string $pa return $result; } + /** + * @throws Exception + */ private function getId(int $storageId, string $path): int { $query = $this->connection->getQueryBuilder(); $query->select(['fileid']) @@ -166,6 +172,7 @@ private function getId(int $storageId, string $path): int { /** * @param string[] $filePaths * @return array + * @throws Exception */ public function getAllRulesForPaths(int $storageId, array $filePaths): array { $hashes = array_map(fn (string $path): string => md5(trim($path, '/')), $filePaths); @@ -198,6 +205,7 @@ private function rulesByPath(array $rows, array $result = []): array { /** * @return array + * @throws Exception */ public function getAllRulesForPrefix(int $storageId, string $prefix): array { $query = $this->connection->getQueryBuilder(); @@ -217,6 +225,7 @@ public function getAllRulesForPrefix(int $storageId, string $prefix): array { /** * @return array + * @throws Exception */ public function getRulesForPrefix(IUser $user, int $storageId, string $prefix): array { $userMappings = $this->userMappingManager->getMappingsForUser($user); @@ -240,6 +249,9 @@ public function getRulesForPrefix(IUser $user, int $storageId, string $prefix): return $this->rulesByPath($rows); } + /** + * @throws Exception + */ private function hasRule(IUserMapping $mapping, int $fileId): bool { $query = $this->connection->getQueryBuilder(); $query->select('fileid') @@ -251,6 +263,9 @@ private function hasRule(IUserMapping $mapping, int $fileId): bool { return (bool)$query->executeQuery()->fetch(); } + /** + * @throws Exception + */ public function saveRule(Rule $rule): void { if ($this->hasRule($rule->getUserMapping(), $rule->getFileId())) { $query = $this->connection->getQueryBuilder(); @@ -315,6 +330,9 @@ public function saveRule(Rule $rule): void { } } + /** + * @throws Exception + */ public function deleteRule(Rule $rule): void { $query = $this->connection->getQueryBuilder(); $query->delete('group_folders_acl') diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 5ca54e458..025060a17 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -56,8 +56,10 @@ use OCP\IUserManager; use OCP\IUserSession; use OCP\Server; +use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerInterface; use Psr\Log\LoggerInterface; +use Throwable; class Application extends App implements IBootstrap { public const APP_ID = 'groupfolders'; @@ -227,6 +229,10 @@ public function register(IRegistrationContext $context): void { $context->registerMiddleware(AuthorizedAdminSettingMiddleware::class); } + /** + * @throws ContainerExceptionInterface + * @throws Throwable + */ public function boot(IBootContext $context): void { $context->injectFn(function (IMountProviderCollection $mountProviderCollection, CacheListener $cacheListener, IEventDispatcher $eventDispatcher): void { $mountProviderCollection->registerProvider(Server::get(MountProvider::class)); diff --git a/lib/AppInfo/Capabilities.php b/lib/AppInfo/Capabilities.php index bed591df2..4523b4400 100644 --- a/lib/AppInfo/Capabilities.php +++ b/lib/AppInfo/Capabilities.php @@ -7,9 +7,11 @@ */ namespace OCA\GroupFolders\AppInfo; +use OCA\Circles\Exceptions\RequestBuilderException; use OCA\GroupFolders\Folder\FolderManager; use OCP\App\IAppManager; use OCP\Capabilities\ICapability; +use OCP\DB\Exception; use OCP\IUser; use OCP\IUserSession; @@ -21,6 +23,10 @@ public function __construct( ) { } + /** + * @throws Exception + * @throws RequestBuilderException + */ public function getCapabilities(): array { $user = $this->userSession->getUser(); if (!$user) { @@ -35,6 +41,10 @@ public function getCapabilities(): array { ]; } + /** + * @throws RequestBuilderException + * @throws Exception + */ private function hasFolders(IUser $user): bool { $folders = $this->folderManager->getFoldersForUser($user); return count($folders) > 0; diff --git a/lib/AuthorizedAdminSettingMiddleware.php b/lib/AuthorizedAdminSettingMiddleware.php index 524ba0b3f..86d98319f 100644 --- a/lib/AuthorizedAdminSettingMiddleware.php +++ b/lib/AuthorizedAdminSettingMiddleware.php @@ -27,6 +27,7 @@ public function __construct( /** * Throws an error when the user is not allowed to use the app's APIs + * @throws Exception */ public function beforeController(Controller $controller, string $methodName): void { $method = new ReflectionMethod($controller, $methodName); diff --git a/lib/BackgroundJob/ExpireGroupVersions.php b/lib/BackgroundJob/ExpireGroupVersions.php index 96c7461f1..92fbbd205 100644 --- a/lib/BackgroundJob/ExpireGroupVersions.php +++ b/lib/BackgroundJob/ExpireGroupVersions.php @@ -13,6 +13,7 @@ use OCA\GroupFolders\Versions\GroupVersionsExpireManager; use OCP\AppFramework\Utility\ITimeFactory; use OCP\BackgroundJob\TimedJob; +use OCP\DB\Exception; use OCP\IAppConfig; use Psr\Log\LoggerInterface; @@ -36,6 +37,7 @@ public function __construct( * @inheritDoc * Expiring groupfolder versions can be quite expensive. * We need to limit the amount of folders we expire per run. + * @throws Exception */ protected function run(mixed $argument): void { $lastFolder = $this->appConfig->getValueInt(Application::APP_ID, 'cron_last_folder_index', 0); diff --git a/lib/Command/Create.php b/lib/Command/Create.php index 0020afa27..2f43f1adb 100644 --- a/lib/Command/Create.php +++ b/lib/Command/Create.php @@ -10,17 +10,26 @@ use OC\Core\Command\Base; use OCA\GroupFolders\Folder\FolderManager; +use OCP\DB\Exception; +use Symfony\Component\Console\Exception\InvalidArgumentException; +use Symfony\Component\Console\Exception\LogicException; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class Create extends Base { + /** + * @throws LogicException + */ public function __construct( private FolderManager $folderManager, ) { parent::__construct(); } + /** + * @throws InvalidArgumentException + */ protected function configure(): void { $this ->setName('groupfolders:create') @@ -29,6 +38,10 @@ protected function configure(): void { parent::configure(); } + /** + * @throws Exception + * @throws InvalidArgumentException + */ protected function execute(InputInterface $input, OutputInterface $output): int { $id = $this->folderManager->createFolder($input->getArgument('name')); $output->writeln((string)$id); diff --git a/lib/Command/ExpireGroup/ExpireGroupBase.php b/lib/Command/ExpireGroup/ExpireGroupBase.php index caad5f2bf..ea11164c4 100644 --- a/lib/Command/ExpireGroup/ExpireGroupBase.php +++ b/lib/Command/ExpireGroup/ExpireGroupBase.php @@ -9,6 +9,8 @@ namespace OCA\GroupFolders\Command\ExpireGroup; use OC\Core\Command\Base; +use Symfony\Component\Console\Exception\InvalidArgumentException; +use Symfony\Component\Console\Exception\LogicException; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -16,10 +18,16 @@ * Base class for the group folder expiration commands. */ class ExpireGroupBase extends Base { + /** + * @throws LogicException + */ public function __construct() { parent::__construct(); } + /** + * @throws InvalidArgumentException + */ protected function configure(): void { $this ->setName('groupfolders:expire') diff --git a/lib/Command/ExpireGroupVersionsPlaceholder.php b/lib/Command/ExpireGroupVersionsPlaceholder.php index cb3a8be52..448eac8b0 100644 --- a/lib/Command/ExpireGroupVersionsPlaceholder.php +++ b/lib/Command/ExpireGroupVersionsPlaceholder.php @@ -9,10 +9,14 @@ namespace OCA\GroupFolders\Command; use OC\Core\Command\Base; +use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class ExpireGroupVersionsPlaceholder extends Base { + /** + * @throws InvalidArgumentException + */ protected function configure(): void { $this ->setName('groupfolders:expire') diff --git a/lib/Command/FolderCommand.php b/lib/Command/FolderCommand.php index 05cde733d..a39fab112 100644 --- a/lib/Command/FolderCommand.php +++ b/lib/Command/FolderCommand.php @@ -11,7 +11,10 @@ use OC\Core\Command\Base; use OCA\GroupFolders\Folder\FolderManager; use OCA\GroupFolders\Mount\MountProvider; +use OCP\DB\Exception; use OCP\Files\IRootFolder; +use Symfony\Component\Console\Exception\InvalidArgumentException; +use Symfony\Component\Console\Exception\LogicException; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -19,7 +22,9 @@ * Base command for commands asking the user for a folder id. */ abstract class FolderCommand extends Base { - + /** + * @throws LogicException + */ public function __construct( protected FolderManager $folderManager, protected IRootFolder $rootFolder, @@ -30,6 +35,8 @@ public function __construct( /** * @psalm-return ?array{id: mixed, mount_point: string, groups: array|mixed, quota: int, size: int|mixed, acl: bool} + * @throws Exception + * @throws InvalidArgumentException */ protected function getFolder(InputInterface $input, OutputInterface $output): ?array { $folderId = (int)$input->getArgument('folder_id'); diff --git a/lib/Command/ListCommand.php b/lib/Command/ListCommand.php index e1473e21b..fb00628db 100644 --- a/lib/Command/ListCommand.php +++ b/lib/Command/ListCommand.php @@ -11,9 +11,12 @@ use OC\Core\Command\Base; use OCA\GroupFolders\Folder\FolderManager; use OCP\Constants; +use OCP\DB\Exception; use OCP\Files\IRootFolder; use OCP\IGroupManager; use OCP\IUserManager; +use Symfony\Component\Console\Exception\InvalidArgumentException; +use Symfony\Component\Console\Exception\LogicException; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -28,7 +31,9 @@ class ListCommand extends Base { Constants::PERMISSION_DELETE => 'delete' ]; - + /** + * @throws LogicException + */ public function __construct( private FolderManager $folderManager, private IRootFolder $rootFolder, @@ -38,6 +43,9 @@ public function __construct( parent::__construct(); } + /** + * @throws InvalidArgumentException + */ protected function configure(): void { $this ->setName('groupfolders:list') @@ -46,6 +54,10 @@ protected function configure(): void { parent::configure(); } + /** + * @throws Exception + * @throws InvalidArgumentException + */ protected function execute(InputInterface $input, OutputInterface $output): int { $userId = $input->getOption('user'); $groups = $this->groupManager->search(''); diff --git a/lib/Command/Trashbin/Cleanup.php b/lib/Command/Trashbin/Cleanup.php index 71e71f3f3..eb6c4af5d 100644 --- a/lib/Command/Trashbin/Cleanup.php +++ b/lib/Command/Trashbin/Cleanup.php @@ -12,7 +12,12 @@ use OCA\GroupFolders\Folder\FolderManager; use OCA\GroupFolders\Trash\TrashBackend; use OCP\App\IAppManager; +use OCP\DB\Exception; use OCP\Server; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; +use Symfony\Component\Console\Exception\InvalidArgumentException; +use Symfony\Component\Console\Exception\LogicException; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -22,6 +27,11 @@ class Cleanup extends Base { private ?TrashBackend $trashBackend = null; + /** + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @throws LogicException + */ public function __construct( private FolderManager $folderManager, ) { @@ -31,6 +41,9 @@ public function __construct( } } + /** + * @throws InvalidArgumentException + */ protected function configure(): void { $this ->setName('groupfolders:trashbin:cleanup') @@ -40,6 +53,11 @@ protected function configure(): void { parent::configure(); } + /** + * @throws Exception + * @throws InvalidArgumentException + * @throws LogicException + */ protected function execute(InputInterface $input, OutputInterface $output): int { if (!$this->trashBackend) { $output->writeln('files_trashbin is disabled: group folders trashbin is not available'); diff --git a/lib/Controller/DelegationController.php b/lib/Controller/DelegationController.php index ead39573e..a13203732 100644 --- a/lib/Controller/DelegationController.php +++ b/lib/Controller/DelegationController.php @@ -8,6 +8,12 @@ namespace OCA\GroupFolders\Controller; use OCA\Circles\CirclesManager; +use OCA\Circles\Exceptions\FederatedUserException; +use OCA\Circles\Exceptions\FederatedUserNotFoundException; +use OCA\Circles\Exceptions\InitiatorNotFoundException; +use OCA\Circles\Exceptions\InvalidIdException; +use OCA\Circles\Exceptions\RequestBuilderException; +use OCA\Circles\Exceptions\SingleCircleNotFoundException; use OCA\GroupFolders\Attribute\RequireGroupFolderAdmin; use OCA\GroupFolders\Service\DelegationService; use OCA\Settings\Service\AuthorizedGroupService; @@ -61,6 +67,13 @@ public function getAllGroups(): DataResponse { /** * Returns the list of all visible circles + * + * @throws FederatedUserException + * @throws InitiatorNotFoundException + * @throws RequestBuilderException + * @throws FederatedUserNotFoundException + * @throws InvalidIdException + * @throws SingleCircleNotFoundException */ #[RequireGroupFolderAdmin] #[NoAdminRequired] diff --git a/lib/Controller/FolderController.php b/lib/Controller/FolderController.php index 8e3d5b648..7c816d5e5 100644 --- a/lib/Controller/FolderController.php +++ b/lib/Controller/FolderController.php @@ -8,6 +8,8 @@ namespace OCA\GroupFolders\Controller; use OC\AppFramework\OCS\V1Response; +use OCA\Circles\Exceptions\InitiatorNotFoundException; +use OCA\Circles\Exceptions\RequestBuilderException; use OCA\GroupFolders\Attribute\RequireGroupFolderAdmin; use OCA\GroupFolders\Folder\FolderManager; use OCA\GroupFolders\Mount\MountProvider; @@ -20,7 +22,11 @@ use OCP\AppFramework\OCS\OCSForbiddenException; use OCP\AppFramework\OCS\OCSNotFoundException; use OCP\AppFramework\OCSController; +use OCP\DB\Exception; +use OCP\Files\InvalidPathException; use OCP\Files\IRootFolder; +use OCP\Files\NotFoundException; +use OCP\Files\NotPermittedException; use OCP\IGroupManager; use OCP\IRequest; use OCP\IUser; @@ -75,6 +81,10 @@ private function formatFolder(array $folder): array { return $folder; } + /** + * @throws OCSNotFoundException + * @throws Exception + */ #[NoAdminRequired] #[ApiRoute(verb: 'GET', url: '/folders')] public function getFolders(bool $applicable = false): DataResponse { @@ -102,6 +112,10 @@ public function getFolders(bool $applicable = false): DataResponse { return new DataResponse($folders); } + /** + * @throws OCSNotFoundException + * @throws Exception + */ #[NoAdminRequired] #[ApiRoute(verb: 'GET', url: '/folders/{id}')] public function getFolder(int $id): DataResponse { @@ -130,6 +144,9 @@ public function getFolder(int $id): DataResponse { return new DataResponse($this->formatFolder($folder)); } + /** + * @throws Exception + */ private function checkFolderExists(int $id): ?DataResponse { $storageId = $this->getRootFolderStorageId(); if ($storageId === null) { @@ -150,6 +167,7 @@ private function getRootFolderStorageId(): ?int { /** * @throws OCSNotFoundException + * @throws Exception */ #[RequireGroupFolderAdmin] #[NoAdminRequired] @@ -170,6 +188,13 @@ public function addFolder(string $mountpoint): DataResponse { return new DataResponse($folder); } + /** + * @throws NotPermittedException + * @throws OCSNotFoundException + * @throws InvalidPathException + * @throws NotFoundException + * @throws Exception + */ #[RequireGroupFolderAdmin] #[NoAdminRequired] #[ApiRoute(verb: 'DELETE', url: '/folders/{id}')] @@ -190,6 +215,9 @@ public function removeFolder(int $id): DataResponse { return new DataResponse(['success' => true]); } + /** + * @throws Exception + */ #[RequireGroupFolderAdmin] #[NoAdminRequired] #[ApiRoute(verb: 'PUT', url: '/folders/{id}')] @@ -198,6 +226,11 @@ public function setMountPoint(int $id, string $mountPoint): DataResponse { return new DataResponse(['success' => true]); } + /** + * @throws RequestBuilderException + * @throws Exception + * @throws InitiatorNotFoundException + */ #[RequireGroupFolderAdmin] #[NoAdminRequired] #[ApiRoute(verb: 'POST', url: '/folders/{id}/groups')] @@ -212,6 +245,9 @@ public function addGroup(int $id, string $group): DataResponse { return new DataResponse(['success' => true]); } + /** + * @throws Exception + */ #[RequireGroupFolderAdmin] #[NoAdminRequired] #[ApiRoute(verb: 'DELETE', url: '/folders/{id}/groups/{group}', requirements: ['group' => '.+'])] @@ -226,6 +262,9 @@ public function removeGroup(int $id, string $group): DataResponse { return new DataResponse(['success' => true]); } + /** + * @throws Exception + */ #[RequireGroupFolderAdmin] #[NoAdminRequired] #[ApiRoute(verb: 'POST', url: '/folders/{id}/groups/{group}', requirements: ['group' => '.+'])] @@ -241,7 +280,7 @@ public function setPermissions(int $id, string $group, int $permissions): DataRe } /** - * @throws \OCP\DB\Exception + * @throws Exception */ #[RequireGroupFolderAdmin] #[NoAdminRequired] @@ -257,6 +296,9 @@ public function setManageACL(int $id, string $mappingType, string $mappingId, bo return new DataResponse(['success' => true]); } + /** + * @throws Exception + */ #[RequireGroupFolderAdmin] #[NoAdminRequired] #[ApiRoute(verb: 'POST', url: '/folders/{id}/quota')] @@ -271,6 +313,9 @@ public function setQuota(int $id, int $quota): DataResponse { return new DataResponse(['success' => true]); } + /** + * @throws Exception + */ #[RequireGroupFolderAdmin] #[NoAdminRequired] #[ApiRoute(verb: 'POST', url: '/folders/{id}/acl')] @@ -285,6 +330,9 @@ public function setACL(int $id, bool $acl): DataResponse { return new DataResponse(['success' => true]); } + /** + * @throws Exception + */ #[RequireGroupFolderAdmin] #[NoAdminRequired] #[ApiRoute(verb: 'POST', url: '/folders/{id}/mountpoint')] @@ -334,6 +382,10 @@ private function folderDataForXML(array $data): array { return $data; } + /** + * @throws OCSForbiddenException + * @throws Exception + */ #[NoAdminRequired] #[ApiRoute(verb: 'GET', url: '/folders/{id}/search')] public function aclMappingSearch(int $id, ?int $fileId, string $search = ''): DataResponse { diff --git a/lib/DAV/ACLPlugin.php b/lib/DAV/ACLPlugin.php index caa99880a..e1667c3b4 100644 --- a/lib/DAV/ACLPlugin.php +++ b/lib/DAV/ACLPlugin.php @@ -15,10 +15,14 @@ use OCA\GroupFolders\Folder\FolderManager; use OCA\GroupFolders\Mount\GroupMountPoint; use OCP\Constants; +use OCP\DB\Exception; use OCP\EventDispatcher\IEventDispatcher; +use OCP\Files\NotFoundException; use OCP\IUser; use OCP\IUserSession; use OCP\Log\Audit\CriticalActionPerformedEvent; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use Sabre\DAV\INode; use Sabre\DAV\PropFind; use Sabre\DAV\PropPatch; @@ -44,6 +48,12 @@ public function __construct( ) { } + /** + * @throws NotFoundExceptionInterface + * @throws ContainerExceptionInterface + * @throws NotFoundException + * @throws Exception + */ private function isAdmin(string $path): bool { $folderId = $this->folderManager->getFolderByPath($path); if ($this->user === null) { diff --git a/lib/DAV/GroupFoldersHome.php b/lib/DAV/GroupFoldersHome.php index d7c894d8a..4c2b0f3b3 100644 --- a/lib/DAV/GroupFoldersHome.php +++ b/lib/DAV/GroupFoldersHome.php @@ -9,9 +9,12 @@ namespace OCA\GroupFolders\DAV; use OC\Files\Filesystem; +use OCA\Circles\Exceptions\RequestBuilderException; use OCA\GroupFolders\Folder\FolderManager; +use OCP\DB\Exception; use OCP\Files\Cache\ICacheEntry; use OCP\Files\IRootFolder; +use OCP\Files\NotFoundException; use OCP\IUser; use RuntimeException; use Sabre\DAV\Exception\Forbidden; @@ -27,6 +30,9 @@ public function __construct( ) { } + /** + * @throws Forbidden + */ public function delete(): never { throw new Forbidden(); } @@ -36,20 +42,31 @@ public function getName(): string { return $name; } + /** + * @throws Forbidden + */ public function setName($name): never { throw new Forbidden('Permission denied to rename this folder'); } + /** + * @throws Forbidden + */ public function createFile($name, $data = null): never { throw new Forbidden('Not allowed to create files in this folder'); } + /** + * @throws Forbidden + */ public function createDirectory($name): never { throw new Forbidden('Permission denied to create folders in this folder'); } /** * @return array{folder_id: int, mount_point: string, permissions: int, quota: int, acl: bool, rootCacheEntry: ?ICacheEntry}|null + * @throws Exception + * @throws RequestBuilderException */ private function getFolder(string $name): ?array { $storageId = $this->rootFolder->getMountPoint()->getNumericStorageId(); @@ -69,6 +86,7 @@ private function getFolder(string $name): ?array { /** * @param array{folder_id: int, mount_point: string, permissions: int, quota: int, acl: bool, rootCacheEntry: ?ICacheEntry} $folder + * @throws NotFoundException */ private function getDirectoryForFolder(array $folder): GroupFolderNode { $userHome = '/' . $this->user->getUID() . '/files'; @@ -82,6 +100,12 @@ private function getDirectoryForFolder(array $folder): GroupFolderNode { return new GroupFolderNode($view, $node, $folder['folder_id']); } + /** + * @throws NotFound + * @throws NotFoundException + * @throws RequestBuilderException + * @throws Exception + */ public function getChild($name): GroupFolderNode { $folder = $this->getFolder($name); if ($folder) { @@ -93,6 +117,8 @@ public function getChild($name): GroupFolderNode { /** * @return GroupFolderNode[] + * @throws RequestBuilderException + * @throws Exception */ public function getChildren(): array { $storageId = $this->rootFolder->getMountPoint()->getNumericStorageId(); @@ -104,6 +130,10 @@ public function getChildren(): array { return array_map($this->getDirectoryForFolder(...), $folders); } + /** + * @throws Exception + * @throws RequestBuilderException + */ public function childExists($name): bool { return $this->getFolder($name) !== null; } diff --git a/lib/DAV/PropFindPlugin.php b/lib/DAV/PropFindPlugin.php index 630a848ac..3d6e89eca 100644 --- a/lib/DAV/PropFindPlugin.php +++ b/lib/DAV/PropFindPlugin.php @@ -8,8 +8,10 @@ namespace OCA\GroupFolders\DAV; +use OC\User\NoUserException; use OCP\Files\Folder; use OCP\Files\IRootFolder; +use OCP\Files\NotPermittedException; use OCP\IUserSession; use Sabre\DAV\INode; use Sabre\DAV\PropFind; @@ -22,6 +24,10 @@ class PropFindPlugin extends ServerPlugin { public const MOUNT_POINT_PROPERTYNAME = '{http://nextcloud.org/ns}mount-point'; public const GROUP_FOLDER_ID_PROPERTYNAME = '{http://nextcloud.org/ns}group-folder-id'; + /** + * @throws NotPermittedException + * @throws NoUserException + */ public function __construct(IRootFolder $rootFolder, IUserSession $userSession) { $user = $userSession->getUser(); if ($user === null) { diff --git a/lib/DAV/RootCollection.php b/lib/DAV/RootCollection.php index e1d162af7..b88115fef 100644 --- a/lib/DAV/RootCollection.php +++ b/lib/DAV/RootCollection.php @@ -11,6 +11,7 @@ use OCA\GroupFolders\Folder\FolderManager; use OCP\Files\IRootFolder; use OCP\IUserSession; +use Sabre\DAV\Exception\Forbidden; use Sabre\DAVACL\AbstractPrincipalCollection; use Sabre\DAVACL\PrincipalBackend; @@ -30,6 +31,7 @@ public function __construct( * The passed array contains principal information, and is guaranteed to * at least contain a uri item. Other properties may or may not be * supplied by the authentication backend. + * @throws Forbidden */ public function getChildForPrincipal(array $principalInfo): GroupFoldersHome { [, $name] = \Sabre\Uri\split($principalInfo['uri']); diff --git a/lib/Folder/FolderManager.php b/lib/Folder/FolderManager.php index 8dcd615de..d3bde89b5 100644 --- a/lib/Folder/FolderManager.php +++ b/lib/Folder/FolderManager.php @@ -11,6 +11,8 @@ use OC\Files\Node\Node; use OCA\Circles\CirclesManager; use OCA\Circles\Exceptions\CircleNotFoundException; +use OCA\Circles\Exceptions\InitiatorNotFoundException; +use OCA\Circles\Exceptions\RequestBuilderException; use OCA\Circles\Model\Probes\CircleProbe; use OCA\GroupFolders\Mount\GroupMountPoint; use OCP\AutoloadNotAllowedException; @@ -20,6 +22,7 @@ use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\IMimeTypeLoader; use OCP\Files\IRootFolder; +use OCP\Files\NotFoundException; use OCP\IConfig; use OCP\IDBConnection; use OCP\IGroup; @@ -29,6 +32,7 @@ use OCP\Log\Audit\CriticalActionPerformedEvent; use OCP\Server; use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use Psr\Log\LoggerInterface; class FolderManager { @@ -86,6 +90,9 @@ private function getGroupFolderRootId(int $rootStorageId): int { return (int)$query->executeQuery()->fetchOne(); } + /** + * @throws Exception + */ private function joinQueryWithFileCache(IQueryBuilder $query, int $rootStorageId): void { $query->leftJoin('f', 'filecache', 'c', $query->expr()->andX( // concat with empty string to work around missing cast to string @@ -278,7 +285,6 @@ public function getFolder(int $id, int $rootStorageId): ?array { /** * Return just the ACL for the folder. - * * @throws Exception */ public function getFolderAclEnabled(int $id): bool { @@ -293,6 +299,11 @@ public function getFolderAclEnabled(int $id): bool { return (bool)($row['acl'] ?? false); } + /** + * @throws ContainerExceptionInterface + * @throws NotFoundException + * @throws NotFoundExceptionInterface + */ public function getFolderByPath(string $path): int { /** @var Node $node */ $node = Server::get(IRootFolder::class)->get($path); @@ -352,9 +363,6 @@ private function getAllApplicable(): array { return $applicableMap; } - /** - * @throws Exception - */ private function getGroups(int $id): array { $groups = $this->getAllApplicable()[$id] ?? []; $groups = array_map(fn (string $gid): ?IGroup => $this->groupManager->get($gid), array_keys($groups)); @@ -378,12 +386,13 @@ public function canManageACL(int $folderId, IUser $user): bool { } // Call private server api - if (class_exists(\OC\Settings\AuthorizedGroupMapper::class)) { + try { $authorizedGroupMapper = Server::get(\OC\Settings\AuthorizedGroupMapper::class); $settingClasses = $authorizedGroupMapper->findAllClassesForUser($user); if (in_array(\OCA\GroupFolders\Settings\Admin::class, $settingClasses, true)) { return true; } + } catch (ContainerExceptionInterface|NotFoundExceptionInterface) { } $query = $this->connection->getQueryBuilder(); @@ -411,9 +420,6 @@ public function canManageACL(int $folderId, IUser $user): bool { return false; } - /** - * @throws Exception - */ public function searchGroups(int $id, string $search = ''): array { $groups = $this->getGroups($id); if ($search === '') { @@ -423,9 +429,6 @@ public function searchGroups(int $id, string $search = ''): array { return array_filter($groups, fn (array $group): bool => (stripos($group['gid'], $search) !== false) || (stripos($group['displayname'], $search) !== false)); } - /** - * @throws Exception - */ public function searchUsers(int $id, string $search = '', int $limit = 10, int $offset = 0): array { $groups = $this->getGroups($id); $users = []; @@ -554,6 +557,7 @@ public function getFoldersForGroups(array $groupIds, int $rootStorageId = 0): ar /** * @return array{folder_id: int, mount_point: string, permissions: int, quota: int, acl: bool, rootCacheEntry: ?CacheEntry}[] * @throws Exception + * @throws RequestBuilderException */ public function getFoldersFromCircleMemberships(IUser $user, int $rootStorageId = 0): array { $circlesManager = $this->getCirclesManager(); @@ -611,7 +615,6 @@ public function getFoldersFromCircleMemberships(IUser $user, int $rootStorageId ], $query->executeQuery()->fetchAll()); } - /** * @throws Exception */ @@ -635,6 +638,8 @@ public function createFolder(string $mountPoint): int { /** * @throws Exception + * @throws RequestBuilderException + * @throws InitiatorNotFoundException */ public function addApplicableGroup(int $folderId, string $groupId): void { $query = $this->connection->getQueryBuilder(); @@ -679,7 +684,6 @@ public function removeApplicableGroup(int $folderId, string $groupId): void { $this->eventDispatcher->dispatchTyped(new CriticalActionPerformedEvent('The group "%s" was revoked access to the groupfolder with id %d', [$groupId, $folderId])); } - /** * @throws Exception */ @@ -811,7 +815,6 @@ public function deleteCircle(string $circleId): void { $query->executeStatement(); } - /** * @throws Exception */ @@ -837,6 +840,7 @@ public function setFolderACL(int $folderId, bool $acl): void { /** * @return list * @throws Exception + * @throws RequestBuilderException */ public function getFoldersForUser(IUser $user, int $rootStorageId = 0): array { $groups = $this->groupManager->getUserGroupIds($user); @@ -858,8 +862,10 @@ public function getFoldersForUser(IUser $user, int $rootStorageId = 0): array { return array_values($mergedFolders); } + /** * @throws Exception + * @throws RequestBuilderException */ public function getFolderPermissionsForUser(IUser $user, int $folderId): int { $groups = $this->groupManager->getUserGroupIds($user); @@ -880,6 +886,8 @@ public function getFolderPermissionsForUser(IUser $user, int $folderId): int { /** * returns if the groupId is in fact the singleId of an existing Circle + * @throws RequestBuilderException + * @throws InitiatorNotFoundException */ public function isACircle(string $groupId): bool { $circlesManager = $this->getCirclesManager(); diff --git a/lib/Listeners/CircleDestroyedEventListener.php b/lib/Listeners/CircleDestroyedEventListener.php index aeb3f00a7..d3b2189c5 100644 --- a/lib/Listeners/CircleDestroyedEventListener.php +++ b/lib/Listeners/CircleDestroyedEventListener.php @@ -11,6 +11,7 @@ use OCA\Circles\Events\CircleDestroyedEvent; use OCA\GroupFolders\Folder\FolderManager; +use OCP\DB\Exception; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; @@ -24,6 +25,9 @@ public function __construct( } + /** + * @throws Exception + */ public function handle(Event $event): void { if (!$event instanceof CircleDestroyedEvent) { return; diff --git a/lib/Listeners/NodeRenamedListener.php b/lib/Listeners/NodeRenamedListener.php index 84b12c135..df6263822 100644 --- a/lib/Listeners/NodeRenamedListener.php +++ b/lib/Listeners/NodeRenamedListener.php @@ -11,10 +11,12 @@ use OCA\GroupFolders\Mount\GroupFolderStorage; use OCA\GroupFolders\Trash\TrashManager; +use OCP\DB\Exception; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; use OCP\Files\Events\Node\NodeRenamedEvent; use OCP\Files\Folder; +use OCP\Files\NotFoundException; /** * @template-implements IEventListener @@ -25,6 +27,10 @@ public function __construct( ) { } + /** + * @throws NotFoundException + * @throws Exception + */ public function handle(Event $event): void { $source = $event->getSource(); $target = $event->getTarget(); diff --git a/lib/Migration/Version1000000Date20210216085047.php b/lib/Migration/Version1000000Date20210216085047.php index a919c07d9..5ae24c0e5 100644 --- a/lib/Migration/Version1000000Date20210216085047.php +++ b/lib/Migration/Version1000000Date20210216085047.php @@ -8,11 +8,15 @@ namespace OCA\GroupFolders\Migration; use Closure; +use Doctrine\DBAL\Schema\SchemaException; use OCP\DB\ISchemaWrapper; use OCP\Migration\IOutput; use OCP\Migration\SimpleMigrationStep; class Version1000000Date20210216085047 extends SimpleMigrationStep { + /** + * @throws SchemaException + */ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); diff --git a/lib/Migration/Version102020Date20180806161449.php b/lib/Migration/Version102020Date20180806161449.php index 777c7fcf5..102730513 100644 --- a/lib/Migration/Version102020Date20180806161449.php +++ b/lib/Migration/Version102020Date20180806161449.php @@ -7,11 +7,15 @@ namespace OCA\GroupFolders\Migration; +use Doctrine\DBAL\Schema\SchemaException; use OCP\DB\ISchemaWrapper; use OCP\Migration\IOutput; use OCP\Migration\SimpleMigrationStep; class Version102020Date20180806161449 extends SimpleMigrationStep { + /** + * @throws SchemaException + */ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options): ?ISchemaWrapper { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); diff --git a/lib/Migration/Version103000Date20180806161724.php b/lib/Migration/Version103000Date20180806161724.php index d6fc5e7a6..e96f2c0bc 100644 --- a/lib/Migration/Version103000Date20180806161724.php +++ b/lib/Migration/Version103000Date20180806161724.php @@ -7,6 +7,8 @@ namespace OCA\GroupFolders\Migration; +use Doctrine\DBAL\Schema\SchemaException; +use OCP\DB\Exception; use OCP\DB\ISchemaWrapper; use OCP\IDBConnection; use OCP\Migration\IOutput; @@ -20,6 +22,9 @@ public function __construct( ) { } + /** + * @throws Exception + */ public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); @@ -34,6 +39,9 @@ public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array } } + /** + * @throws SchemaException + */ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options): ?ISchemaWrapper { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); diff --git a/lib/Migration/Version104000Date20180918132853.php b/lib/Migration/Version104000Date20180918132853.php index 0e3612599..6bb3cb604 100644 --- a/lib/Migration/Version104000Date20180918132853.php +++ b/lib/Migration/Version104000Date20180918132853.php @@ -8,6 +8,7 @@ namespace OCA\GroupFolders\Migration; use Closure; +use Doctrine\DBAL\Schema\SchemaException; use OCP\DB\ISchemaWrapper; use OCP\Migration\IOutput; use OCP\Migration\SimpleMigrationStep; @@ -21,6 +22,9 @@ public function description(): string { return 'Adds table to store trashbin information for group folders'; } + /** + * @throws SchemaException + */ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); diff --git a/lib/Migration/Version1401000Date20230426112001.php b/lib/Migration/Version1401000Date20230426112001.php index dfd3bb574..d3075b322 100644 --- a/lib/Migration/Version1401000Date20230426112001.php +++ b/lib/Migration/Version1401000Date20230426112001.php @@ -8,12 +8,16 @@ namespace OCA\GroupFolders\Migration; use Closure; +use Doctrine\DBAL\Schema\SchemaException; use OCP\DB\ISchemaWrapper; use OCP\DB\Types; use OCP\Migration\IOutput; use OCP\Migration\SimpleMigrationStep; class Version1401000Date20230426112001 extends SimpleMigrationStep { + /** + * @throws SchemaException + */ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); diff --git a/lib/Migration/Version1401000Date20230426112002.php b/lib/Migration/Version1401000Date20230426112002.php index cac09b4f0..4bbfb03c1 100644 --- a/lib/Migration/Version1401000Date20230426112002.php +++ b/lib/Migration/Version1401000Date20230426112002.php @@ -8,11 +8,15 @@ namespace OCA\GroupFolders\Migration; use Closure; +use Doctrine\DBAL\Schema\SchemaException; use OCP\DB\ISchemaWrapper; use OCP\Migration\IOutput; use OCP\Migration\SimpleMigrationStep; class Version1401000Date20230426112002 extends SimpleMigrationStep { + /** + * @throws SchemaException + */ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); diff --git a/lib/Migration/Version16000Date20230821085801.php b/lib/Migration/Version16000Date20230821085801.php index 9af0e940c..8a42861c9 100644 --- a/lib/Migration/Version16000Date20230821085801.php +++ b/lib/Migration/Version16000Date20230821085801.php @@ -10,12 +10,16 @@ namespace OCA\GroupFolders\Migration; use Closure; +use Doctrine\DBAL\Schema\SchemaException; use OCP\DB\ISchemaWrapper; use OCP\DB\Types; use OCP\Migration\IOutput; use OCP\Migration\SimpleMigrationStep; class Version16000Date20230821085801 extends SimpleMigrationStep { + /** + * @throws SchemaException + */ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); diff --git a/lib/Migration/Version19000Date20240903062631.php b/lib/Migration/Version19000Date20240903062631.php index 0e397385d..878887985 100644 --- a/lib/Migration/Version19000Date20240903062631.php +++ b/lib/Migration/Version19000Date20240903062631.php @@ -10,11 +10,15 @@ namespace OCA\GroupFolders\Migration; use Closure; +use Doctrine\DBAL\Schema\SchemaException; use OCP\DB\ISchemaWrapper; use OCP\Migration\IOutput; use OCP\Migration\SimpleMigrationStep; class Version19000Date20240903062631 extends SimpleMigrationStep { + /** + * @throws SchemaException + */ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); diff --git a/lib/Migration/Version201000Date20190111132839.php b/lib/Migration/Version201000Date20190111132839.php index caaad04c6..d367f10b5 100644 --- a/lib/Migration/Version201000Date20190111132839.php +++ b/lib/Migration/Version201000Date20190111132839.php @@ -8,6 +8,7 @@ namespace OCA\GroupFolders\Migration; use Closure; +use Doctrine\DBAL\Schema\SchemaException; use OCP\DB\ISchemaWrapper; use OCP\Migration\IOutput; use OCP\Migration\SimpleMigrationStep; @@ -21,6 +22,9 @@ public function description(): string { return 'Adds table to store ACL information for group folders'; } + /** + * @throws SchemaException + */ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); diff --git a/lib/Migration/Version201000Date20190212150323.php b/lib/Migration/Version201000Date20190212150323.php index 41fdb7e3e..bf180d7b7 100644 --- a/lib/Migration/Version201000Date20190212150323.php +++ b/lib/Migration/Version201000Date20190212150323.php @@ -8,11 +8,15 @@ namespace OCA\GroupFolders\Migration; use Closure; +use Doctrine\DBAL\Schema\SchemaException; use OCP\DB\ISchemaWrapper; use OCP\Migration\IOutput; use OCP\Migration\SimpleMigrationStep; class Version201000Date20190212150323 extends SimpleMigrationStep { + /** + * @throws SchemaException + */ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); diff --git a/lib/Migration/Version300000Date20240905185515.php b/lib/Migration/Version300000Date20240905185515.php index e1cb6e42d..b243702ef 100644 --- a/lib/Migration/Version300000Date20240905185515.php +++ b/lib/Migration/Version300000Date20240905185515.php @@ -10,6 +10,7 @@ namespace OCA\GroupFolders\Migration; use Closure; +use Doctrine\DBAL\Schema\SchemaException; use OCP\DB\ISchemaWrapper; use OCP\DB\Types; use OCP\Migration\IOutput; @@ -19,6 +20,9 @@ * Adds the delete_by column to the group_folders_trash table */ class Version300000Date20240905185515 extends SimpleMigrationStep { + /** + * @throws SchemaException + */ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); diff --git a/lib/Migration/Version401001Date20190715092137.php b/lib/Migration/Version401001Date20190715092137.php index 7d5ee7166..9097b3f02 100644 --- a/lib/Migration/Version401001Date20190715092137.php +++ b/lib/Migration/Version401001Date20190715092137.php @@ -8,11 +8,15 @@ namespace OCA\GroupFolders\Migration; use Closure; +use Doctrine\DBAL\Schema\SchemaException; use OCP\DB\ISchemaWrapper; use OCP\Migration\IOutput; use OCP\Migration\SimpleMigrationStep; class Version401001Date20190715092137 extends SimpleMigrationStep { + /** + * @throws SchemaException + */ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); diff --git a/lib/Migration/Version501000Date20190927102434.php b/lib/Migration/Version501000Date20190927102434.php index a5c09cefe..21e1a8a18 100644 --- a/lib/Migration/Version501000Date20190927102434.php +++ b/lib/Migration/Version501000Date20190927102434.php @@ -8,11 +8,15 @@ namespace OCA\GroupFolders\Migration; use Closure; +use Doctrine\DBAL\Schema\SchemaException; use OCP\DB\ISchemaWrapper; use OCP\Migration\IOutput; use OCP\Migration\SimpleMigrationStep; class Version501000Date20190927102434 extends SimpleMigrationStep { + /** + * @throws SchemaException + */ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); diff --git a/lib/Migration/Version501000Date20191218182434.php b/lib/Migration/Version501000Date20191218182434.php index 0fbe3a33b..3a0675862 100644 --- a/lib/Migration/Version501000Date20191218182434.php +++ b/lib/Migration/Version501000Date20191218182434.php @@ -8,11 +8,15 @@ namespace OCA\GroupFolders\Migration; use Closure; +use Doctrine\DBAL\Schema\SchemaException; use OCP\DB\ISchemaWrapper; use OCP\Migration\IOutput; use OCP\Migration\SimpleMigrationStep; class Version501000Date20191218182434 extends SimpleMigrationStep { + /** + * @throws SchemaException + */ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); diff --git a/lib/Migration/Version802000Date20201119112624.php b/lib/Migration/Version802000Date20201119112624.php index 95105b54f..ffe92bcd7 100644 --- a/lib/Migration/Version802000Date20201119112624.php +++ b/lib/Migration/Version802000Date20201119112624.php @@ -8,11 +8,15 @@ namespace OCA\GroupFolders\Migration; use Closure; +use Doctrine\DBAL\Schema\SchemaException; use OCP\DB\ISchemaWrapper; use OCP\Migration\IOutput; use OCP\Migration\SimpleMigrationStep; class Version802000Date20201119112624 extends SimpleMigrationStep { + /** + * @throws SchemaException + */ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); @@ -29,6 +33,9 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt return $result ? $schema : null; } + /** + * @throws SchemaException + */ protected function ensureColumnIsNullable(ISchemaWrapper $schema, string $tableName, string $columnName): bool { $table = $schema->getTable($tableName); $column = $table->getColumn($columnName); diff --git a/lib/Migration/WrongDefaultQuotaRepairStep.php b/lib/Migration/WrongDefaultQuotaRepairStep.php index 3d3a367bb..c05d5492d 100644 --- a/lib/Migration/WrongDefaultQuotaRepairStep.php +++ b/lib/Migration/WrongDefaultQuotaRepairStep.php @@ -10,7 +10,6 @@ namespace OCA\GroupFolders\Migration; use OCA\GroupFolders\Folder\FolderManager; -use OCP\DB\Exception; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; @@ -25,9 +24,6 @@ public function getName(): string { return 'Adjust Groupfolders with wrong default quotas'; } - /** - * @throws Exception - */ public function run(IOutput $output): void { foreach ($this->manager->getAllFolders() as $id => $folder) { $quota = $folder['quota']; diff --git a/lib/Mount/GroupMountPoint.php b/lib/Mount/GroupMountPoint.php index fa72e71f3..653f308b7 100644 --- a/lib/Mount/GroupMountPoint.php +++ b/lib/Mount/GroupMountPoint.php @@ -6,6 +6,7 @@ namespace OCA\GroupFolders\Mount; +use Exception; use OC\Files\Mount\MountPoint; use OC\Files\Storage\Storage; use OCP\Files\Mount\ISystemMountPoint; @@ -13,6 +14,9 @@ use OCP\Files\Storage\IStorageFactory; class GroupMountPoint extends MountPoint implements ISystemMountPoint { + /** + * @throws Exception + */ public function __construct( private int $folderId, IStorage $storage, diff --git a/lib/Mount/MountProvider.php b/lib/Mount/MountProvider.php index 5d966caa9..bf4bc7ea5 100644 --- a/lib/Mount/MountProvider.php +++ b/lib/Mount/MountProvider.php @@ -6,9 +6,11 @@ namespace OCA\GroupFolders\Mount; +use Exception; use OC\Files\Cache\CacheEntry; use OC\Files\Storage\Wrapper\Jail; use OC\Files\Storage\Wrapper\PermissionsMask; +use OCA\Circles\Exceptions\RequestBuilderException; use OCA\GroupFolders\ACL\ACLManager; use OCA\GroupFolders\ACL\ACLManagerFactory; use OCA\GroupFolders\ACL\ACLStorageWrapper; @@ -19,9 +21,11 @@ use OCP\Files\Config\IMountProvider; use OCP\Files\Config\IMountProviderCollection; use OCP\Files\Folder; +use OCP\Files\InvalidPathException; use OCP\Files\Mount\IMountPoint; use OCP\Files\Node; use OCP\Files\NotFoundException; +use OCP\Files\NotPermittedException; use OCP\Files\Storage\IStorage; use OCP\Files\Storage\IStorageFactory; use OCP\ICache; @@ -29,6 +33,7 @@ use OCP\IRequest; use OCP\IUser; use OCP\IUserSession; +use Psr\Container\ContainerExceptionInterface; class MountProvider implements IMountProvider { private ?Folder $root = null; @@ -48,6 +53,9 @@ public function __construct( ) { } + /** + * @throws NotFoundException + */ private function getRootStorageId(): int { if ($this->rootStorageId === null) { $cached = $this->cache->get('root_storage_id'); @@ -65,11 +73,21 @@ private function getRootStorageId(): int { /** * @return list + * @throws \OCP\DB\Exception + * @throws NotFoundException + * @throws RequestBuilderException */ public function getFoldersForUser(IUser $user): array { return $this->folderManager->getFoldersForUser($user, $this->getRootStorageId()); } + /** + * @throws \OCP\DB\Exception + * @throws NotPermittedException + * @throws NotFoundException + * @throws InvalidPathException + * @throws RequestBuilderException + */ public function getMountsForUser(IUser $user, IStorageFactory $loader): array { $folders = $this->getFoldersForUser($user); @@ -118,7 +136,7 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader): array { private function getCurrentUID(): ?string { try { // wopi requests are not logged in, instead we need to get the editor user from the access token - if (strpos($this->request->getRawPathInfo(), 'apps/richdocuments/wopi') && class_exists('OCA\Richdocuments\Db\WopiMapper')) { + if (strpos($this->request->getRawPathInfo(), 'apps/richdocuments/wopi')) { $wopiMapper = \OCP\Server::get('OCA\Richdocuments\Db\WopiMapper'); $token = $this->request->getParam('access_token'); if ($token) { @@ -126,7 +144,7 @@ private function getCurrentUID(): ?string { return $wopi->getEditorUid(); } } - } catch (\Exception) { + } catch (Exception|ContainerExceptionInterface) { } $user = $this->userSession->getUser(); @@ -134,6 +152,12 @@ private function getCurrentUID(): ?string { return $user ? $user->getUID() : null; } + /** + * @throws NotPermittedException + * @throws InvalidPathException + * @throws NotFoundException + * @throws Exception + */ public function getMount( int $id, string $mountPoint, @@ -240,6 +264,9 @@ private function getRootFolder(): Folder { return $this->root; } + /** + * @throws NotPermittedException + */ public function getFolder(int $id, bool $create = true): ?Node { try { return $this->getRootFolder()->get((string)$id); diff --git a/lib/Service/DelegationService.php b/lib/Service/DelegationService.php index 3d642aa62..8d88e31d5 100644 --- a/lib/Service/DelegationService.php +++ b/lib/Service/DelegationService.php @@ -10,6 +10,7 @@ use OC\Settings\AuthorizedGroupMapper; use OCA\GroupFolders\Controller\DelegationController; use OCA\GroupFolders\Settings\Admin; +use OCP\DB\Exception; use OCP\IGroupManager; use OCP\IUserSession; @@ -41,12 +42,18 @@ public function isAdminNextcloud(): bool { return $this->groupManager->isAdmin($user->getUID()); } + /** + * @throws Exception + */ public function isDelegatedAdmin(): bool { return $this->getAccessLevel([ self::CLASS_NAME_ADMIN_DELEGATION, ]); } + /** + * @throws Exception + */ public function hasApiAccess(): bool { if ($this->isAdminNextcloud()) { return true; @@ -58,12 +65,18 @@ public function hasApiAccess(): bool { ]); } + /** + * @throws Exception + */ public function hasOnlyApiAccess(): bool { return $this->getAccessLevel([ self::CLASS_API_ACCESS, ]); } + /** + * @throws Exception + */ private function getAccessLevel(array $settingClasses): bool { $user = $this->userSession->getUser(); if ($user === null) { diff --git a/lib/Trash/TrashBackend.php b/lib/Trash/TrashBackend.php index cf847253d..7ba64d48e 100644 --- a/lib/Trash/TrashBackend.php +++ b/lib/Trash/TrashBackend.php @@ -91,9 +91,6 @@ public function listTrashFolder(ITrashItem $folder): array { }, $content))); } - /** - * @throws NotPermittedException - */ public function restoreItem(ITrashItem $item): void { if (!($item instanceof GroupTrashItem)) { throw new \LogicException('Trying to restore normal trash item in group folder trash backend'); @@ -168,10 +165,6 @@ public function restoreItem(ITrashItem $item): void { ); } - /** - * @throws \LogicException - * @throws \Exception - */ public function removeItem(ITrashItem $item): void { if (!($item instanceof GroupTrashItem)) { throw new \LogicException('Trying to remove normal trash item in group folder trash backend'); diff --git a/lib/Trash/TrashManager.php b/lib/Trash/TrashManager.php index a88f4e225..3255a1356 100644 --- a/lib/Trash/TrashManager.php +++ b/lib/Trash/TrashManager.php @@ -6,6 +6,7 @@ namespace OCA\GroupFolders\Trash; +use OCP\DB\Exception; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; @@ -17,6 +18,7 @@ public function __construct( /** * @param int[] $folderIds + * @throws Exception */ public function listTrashForFolders(array $folderIds): array { $query = $this->connection->getQueryBuilder(); @@ -28,6 +30,9 @@ public function listTrashForFolders(array $folderIds): array { return $query->executeQuery()->fetchAll(); } + /** + * @throws Exception + */ public function addTrashItem(int $folderId, string $name, int $deletedTime, string $originalLocation, int $fileId, string $deletedBy): void { $query = $this->connection->getQueryBuilder(); $query->insert('group_folders_trash') @@ -42,6 +47,9 @@ public function addTrashItem(int $folderId, string $name, int $deletedTime, stri $query->executeStatement(); } + /** + * @throws Exception + */ public function getTrashItemByFileId(int $fileId): ?array { $query = $this->connection->getQueryBuilder(); $query->select(['trash_id', 'name', 'deleted_time', 'original_location', 'folder_id', 'deleted_by']) @@ -51,6 +59,9 @@ public function getTrashItemByFileId(int $fileId): ?array { return $query->executeQuery()->fetch() ?: null; } + /** + * @throws Exception + */ public function getTrashItemByFileName(int $folderId, string $name, int $deletedTime): ?array { $query = $this->connection->getQueryBuilder(); $query->select(['trash_id', 'name', 'deleted_time', 'original_location', 'folder_id', 'deleted_by']) @@ -62,6 +73,9 @@ public function getTrashItemByFileName(int $folderId, string $name, int $deleted return $query->executeQuery()->fetch() ?: null; } + /** + * @throws Exception + */ public function removeItem(int $folderId, string $name, int $deletedTime): void { $query = $this->connection->getQueryBuilder(); $query->delete('group_folders_trash') @@ -71,6 +85,9 @@ public function removeItem(int $folderId, string $name, int $deletedTime): void $query->executeStatement(); } + /** + * @throws Exception + */ public function emptyTrashbin(int $folderId): void { $query = $this->connection->getQueryBuilder(); $query->delete('group_folders_trash') @@ -78,6 +95,9 @@ public function emptyTrashbin(int $folderId): void { $query->executeStatement(); } + /** + * @throws Exception + */ public function updateTrashedChildren(int $fromFolderId, int $toFolderId, string $fromLocation, string $toLocation): void { // Update deep children $query = $this->connection->getQueryBuilder(); diff --git a/lib/Versions/GroupVersionsExpireManager.php b/lib/Versions/GroupVersionsExpireManager.php index 6ba1a35bf..53f8a604c 100644 --- a/lib/Versions/GroupVersionsExpireManager.php +++ b/lib/Versions/GroupVersionsExpireManager.php @@ -15,6 +15,7 @@ use OCA\GroupFolders\Event\GroupVersionsExpireEnterFolderEvent; use OCA\GroupFolders\Folder\FolderManager; use OCP\AppFramework\Utility\ITimeFactory; +use OCP\DB\Exception; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\FileInfo; use OCP\IUser; @@ -29,6 +30,9 @@ public function __construct( ) { } + /** + * @throws Exception + */ public function expireAll(): void { $folders = $this->folderManager->getAllFolders(); foreach ($folders as $folder) { @@ -46,6 +50,7 @@ public function expireFolders(array $folders): void { /** * @param array{acl: bool, groups: array>, id: int, mount_point: mixed, quota: int, size: 0} $folder + * @throws \Exception */ public function expireFolder(array $folder): void { $view = new View('/__groupfolders/versions/' . $folder['id']); diff --git a/lib/Versions/GroupVersionsMapper.php b/lib/Versions/GroupVersionsMapper.php index 101f67754..4ee03b1ef 100644 --- a/lib/Versions/GroupVersionsMapper.php +++ b/lib/Versions/GroupVersionsMapper.php @@ -9,7 +9,10 @@ namespace OCA\GroupFolders\Versions; +use OCP\AppFramework\Db\DoesNotExistException; +use OCP\AppFramework\Db\MultipleObjectsReturnedException; use OCP\AppFramework\Db\QBMapper; +use OCP\DB\Exception; use OCP\IDBConnection; /** @@ -22,6 +25,7 @@ public function __construct(IDBConnection $db) { /** * @return GroupVersionEntity[] + * @throws Exception */ public function findAllVersionsForFileId(int $fileId): array { $qb = $this->db->getQueryBuilder(); @@ -33,6 +37,11 @@ public function findAllVersionsForFileId(int $fileId): array { return $this->findEntities($qb); } + /** + * @throws DoesNotExistException + * @throws MultipleObjectsReturnedException + * @throws Exception + */ public function findCurrentVersionForFileId(int $fileId): GroupVersionEntity { $qb = $this->db->getQueryBuilder(); @@ -45,6 +54,11 @@ public function findCurrentVersionForFileId(int $fileId): GroupVersionEntity { return $this->findEntity($qb); } + /** + * @throws DoesNotExistException + * @throws MultipleObjectsReturnedException + * @throws Exception + */ public function findVersionForFileId(int $fileId, int $timestamp): GroupVersionEntity { $qb = $this->db->getQueryBuilder(); @@ -56,6 +70,9 @@ public function findVersionForFileId(int $fileId, int $timestamp): GroupVersionE return $this->findEntity($qb); } + /** + * @throws Exception + */ public function deleteAllVersionsForFileId(int $fileId): int { $qb = $this->db->getQueryBuilder(); From 111f1de1b1b012f2528498f4c9511e03fa7d6cc0 Mon Sep 17 00:00:00 2001 From: provokateurin Date: Sat, 21 Sep 2024 13:05:35 +0200 Subject: [PATCH 4/4] feat(psalm): Enforce documenting all thrown exceptions Signed-off-by: provokateurin --- psalm.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/psalm.xml b/psalm.xml index 4331ef230..0e10a3c59 100644 --- a/psalm.xml +++ b/psalm.xml @@ -12,6 +12,7 @@ errorBaseline="tests/psalm-baseline.xml" findUnusedBaselineEntry="true" findUnusedCode="false" + checkForThrowsDocblock="true" > @@ -173,5 +174,17 @@ + + + + + + + + + + + +