diff --git a/apps/dav/lib/AppInfo/PluginManager.php b/apps/dav/lib/AppInfo/PluginManager.php index 428547e3f61d0..a740962fb4719 100644 --- a/apps/dav/lib/AppInfo/PluginManager.php +++ b/apps/dav/lib/AppInfo/PluginManager.php @@ -14,7 +14,7 @@ use OCA\DAV\CalDAV\Integration\ICalendarProvider; use OCA\DAV\CardDAV\Integration\IAddressBookProvider; use OCP\App\IAppManager; -use OCP\AppFramework\QueryException; +use Psr\Container\ContainerExceptionInterface; use Sabre\DAV\Collection; use Sabre\DAV\ServerPlugin; use function array_map; @@ -229,7 +229,7 @@ private function extractCalendarPluginList(array $array): array { private function createClass(string $className): object { try { return $this->container->get($className); - } catch (QueryException $e) { + } catch (ContainerExceptionInterface $e) { if (class_exists($className)) { return new $className(); } diff --git a/apps/dav/lib/CalDAV/Reminder/NotificationProviderManager.php b/apps/dav/lib/CalDAV/Reminder/NotificationProviderManager.php index 265db09b0618d..d474017e608e7 100644 --- a/apps/dav/lib/CalDAV/Reminder/NotificationProviderManager.php +++ b/apps/dav/lib/CalDAV/Reminder/NotificationProviderManager.php @@ -9,8 +9,8 @@ namespace OCA\DAV\CalDAV\Reminder; use OCA\DAV\CalDAV\Reminder\NotificationProvider\ProviderNotAvailableException; -use OCP\AppFramework\QueryException; use OCP\Server; +use Psr\Container\ContainerExceptionInterface; /** * Class NotificationProviderManager @@ -55,7 +55,7 @@ public function getProvider(string $type):INotificationProvider { * Registers a new provider * * @param string $providerClassName - * @throws QueryException + * @throws ContainerExceptionInterface */ public function registerProvider(string $providerClassName):void { $provider = Server::get($providerClassName); diff --git a/apps/dav/lib/CardDAV/UserAddressBooks.php b/apps/dav/lib/CardDAV/UserAddressBooks.php index 2175939e709c0..ed18f5da0e180 100644 --- a/apps/dav/lib/CardDAV/UserAddressBooks.php +++ b/apps/dav/lib/CardDAV/UserAddressBooks.php @@ -15,7 +15,6 @@ use OCA\DAV\CardDAV\Integration\IAddressBookProvider; use OCA\DAV\ConfigLexicon; use OCA\Federation\TrustedServers; -use OCP\AppFramework\QueryException; use OCP\IAppConfig; use OCP\IConfig; use OCP\IGroupManager; @@ -83,7 +82,7 @@ public function getChildren() { try { $trustedServers = Server::get(TrustedServers::class); $request = Server::get(IRequest::class); - } catch (QueryException|NotFoundExceptionInterface|ContainerExceptionInterface $e) { + } catch (NotFoundExceptionInterface|ContainerExceptionInterface $e) { // nothing to do, the request / trusted servers don't exist } if ($addressBook['principaluri'] === 'principals/system/system') { diff --git a/apps/dav/lib/Connector/Sabre/Principal.php b/apps/dav/lib/Connector/Sabre/Principal.php index 7f6941d44cdfa..7e00e8bb9bd7d 100644 --- a/apps/dav/lib/Connector/Sabre/Principal.php +++ b/apps/dav/lib/Connector/Sabre/Principal.php @@ -17,7 +17,6 @@ use OCP\Accounts\IAccountProperty; use OCP\Accounts\PropertyDoesNotExistException; use OCP\App\IAppManager; -use OCP\AppFramework\QueryException; use OCP\Constants; use OCP\IConfig; use OCP\IGroup; @@ -27,6 +26,7 @@ use OCP\IUserSession; use OCP\L10N\IFactory; use OCP\Share\IManager as IShareManager; +use Psr\Container\ContainerExceptionInterface; use Sabre\DAV\Exception; use Sabre\DAV\PropPatch; use Sabre\DAVACL\PrincipalBackend\BackendInterface; @@ -539,7 +539,7 @@ protected function circleToPrincipal($circleUniqueId) { try { $circle = Circles::detailsCircle($circleUniqueId, true); - } catch (QueryException $ex) { + } catch (ContainerExceptionInterface $ex) { return null; } catch (CircleNotFoundException $ex) { return null; @@ -563,7 +563,7 @@ protected function circleToPrincipal($circleUniqueId) { * @param string $principal * @return array * @throws Exception - * @throws QueryException + * @throws ContainerExceptionInterface * @suppress PhanUndeclaredClassMethod */ public function getCircleMembership($principal):array { diff --git a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php index 4bea30dbfc975..d717ce3c195ef 100644 --- a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php +++ b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php @@ -14,7 +14,7 @@ use OCA\DAV\CalDAV\Reminder\NotificationProviderManager; use OCA\DAV\CalDAV\Reminder\NotificationTypeDoesNotExistException; use OCA\DAV\Capabilities; -use OCP\AppFramework\QueryException; +use Psr\Container\ContainerExceptionInterface; use Test\TestCase; #[\PHPUnit\Framework\Attributes\Group('DB')] @@ -22,7 +22,7 @@ class NotificationProviderManagerTest extends TestCase { private NotificationProviderManager $providerManager; /** - * @throws QueryException + * @throws ContainerExceptionInterface */ protected function setUp(): void { parent::setUp(); @@ -65,7 +65,7 @@ public function testRegisterProvider(): void { } /** - * @throws QueryException + * @throws ContainerExceptionInterface */ public function testRegisterBadProvider(): void { $this->expectException(\InvalidArgumentException::class); diff --git a/apps/files/lib/Collaboration/Resources/ResourceProvider.php b/apps/files/lib/Collaboration/Resources/ResourceProvider.php index 73883bc4c6acc..9819c8754c3de 100644 --- a/apps/files/lib/Collaboration/Resources/ResourceProvider.php +++ b/apps/files/lib/Collaboration/Resources/ResourceProvider.php @@ -20,8 +20,7 @@ class ResourceProvider implements IProvider { public const RESOURCE_TYPE = 'file'; - /** @var array */ - protected $nodes = []; + protected array $nodes = []; public function __construct( protected IRootFolder $rootFolder, diff --git a/apps/files_external/lib/AppInfo/Application.php b/apps/files_external/lib/AppInfo/Application.php index 12bd3ecca8531..cd2606f19ab23 100644 --- a/apps/files_external/lib/AppInfo/Application.php +++ b/apps/files_external/lib/AppInfo/Application.php @@ -51,7 +51,6 @@ use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; use OCP\AppFramework\Bootstrap\IRegistrationContext; -use OCP\AppFramework\QueryException; use OCP\Files\Config\IMountProviderCollection; use OCP\Group\Events\BeforeGroupDeletedEvent; use OCP\Group\Events\GroupDeletedEvent; @@ -60,6 +59,7 @@ use OCP\User\Events\PostLoginEvent; use OCP\User\Events\UserCreatedEvent; use OCP\User\Events\UserDeletedEvent; +use Psr\Container\ContainerExceptionInterface; /** * @package OCA\Files_External\AppInfo @@ -70,7 +70,7 @@ class Application extends App implements IBackendProvider, IAuthMechanismProvide /** * Application constructor. * - * @throws QueryException + * @throws ContainerExceptionInterface */ public function __construct(array $urlParams = []) { parent::__construct(self::APP_ID, $urlParams); diff --git a/apps/files_external/lib/Config/ConfigAdapter.php b/apps/files_external/lib/Config/ConfigAdapter.php index 042c364bc6718..319e73228e105 100644 --- a/apps/files_external/lib/Config/ConfigAdapter.php +++ b/apps/files_external/lib/Config/ConfigAdapter.php @@ -16,7 +16,6 @@ use OCA\Files_External\MountConfig; use OCA\Files_External\Service\UserGlobalStoragesService; use OCA\Files_External\Service\UserStoragesService; -use OCP\AppFramework\QueryException; use OCP\Files\Config\IAuthoritativeMountProvider; use OCP\Files\Config\IMountProvider; use OCP\Files\Mount\IMountPoint; @@ -28,6 +27,7 @@ use OCP\IUser; use OCP\Server; use Psr\Clock\ClockInterface; +use Psr\Container\ContainerExceptionInterface; use Psr\Log\LoggerInterface; /** @@ -57,7 +57,7 @@ private function validateObjectStoreClassString(string $class): string { /** * Process storage ready for mounting * - * @throws QueryException + * @throws ContainerExceptionInterface */ private function prepareStorageConfig(StorageConfig &$storage, IUser $user): void { foreach ($storage->getBackendOptions() as $option => $value) { diff --git a/apps/files_external/lib/MountConfig.php b/apps/files_external/lib/MountConfig.php index 93ddb45971b3b..3b7d26925e089 100644 --- a/apps/files_external/lib/MountConfig.php +++ b/apps/files_external/lib/MountConfig.php @@ -15,12 +15,12 @@ use OCA\Files_External\Service\GlobalStoragesService; use OCA\Files_External\Service\UserGlobalStoragesService; use OCA\Files_External\Service\UserStoragesService; -use OCP\AppFramework\QueryException; use OCP\Files\StorageNotAvailableException; use OCP\IConfig; use OCP\Security\ISecureRandom; use OCP\Server; use phpseclib\Crypt\AES; +use Psr\Container\ContainerExceptionInterface; use Psr\Log\LoggerInterface; /** @@ -48,7 +48,7 @@ public function __construct( * @param mixed $input * @param string|null $userId * @return mixed - * @throws QueryException + * @throws ContainerExceptionInterface * @since 16.0.0 */ public static function substitutePlaceholdersInConfig($input, ?string $userId = null) { diff --git a/apps/files_sharing/lib/Controller/DeletedShareAPIController.php b/apps/files_sharing/lib/Controller/DeletedShareAPIController.php index 1384b2b0646e4..e7ddab8a40bf2 100644 --- a/apps/files_sharing/lib/Controller/DeletedShareAPIController.php +++ b/apps/files_sharing/lib/Controller/DeletedShareAPIController.php @@ -181,10 +181,10 @@ public function undelete(string $id): DataResponse { * Returns the helper of DeletedShareAPIController for room shares. * * If the Talk application is not enabled or the helper is not available - * a QueryException is thrown instead. + * a ContainerExceptionInterface is thrown instead. * * @psalm-suppress UndefinedClass - * @throws QueryException + * @throws ContainerExceptionInterface */ private function getRoomShareHelper(): \OCA\Talk\Share\Helper\DeletedShareAPIController { if (!$this->appManager->isEnabledForUser('spreed')) { @@ -199,10 +199,10 @@ private function getRoomShareHelper(): \OCA\Talk\Share\Helper\DeletedShareAPICon * Returns the helper of DeletedShareAPIHelper for deck shares. * * If the Deck application is not enabled or the helper is not available - * a QueryException is thrown instead. + * a ContainerExceptionInterface is thrown instead. * * @psalm-suppress UndefinedClass - * @throws QueryException + * @throws ContainerExceptionInterface */ private function getDeckShareHelper(): \OCA\Deck\Sharing\ShareAPIHelper { if (!$this->appManager->isEnabledForUser('deck')) { diff --git a/lib/public/AppFramework/App.php b/lib/public/AppFramework/App.php index c00fde47418d5..6e2366b181392 100644 --- a/lib/public/AppFramework/App.php +++ b/lib/public/AppFramework/App.php @@ -13,6 +13,7 @@ use OC\ServerContainer; use OCP\IConfig; use OCP\Server; +use Psr\Container\ContainerExceptionInterface; use Psr\Log\LoggerInterface; /** @@ -90,7 +91,7 @@ public function __construct(string $appName, array $urlParams = []) { try { $this->container = \OC::$server->getRegisteredAppContainer($appName); - } catch (QueryException $e) { + } catch (ContainerExceptionInterface $e) { $this->container = new \OC\AppFramework\DependencyInjection\DIContainer($appName, $urlParams); } } diff --git a/lib/public/IContainer.php b/lib/public/IContainer.php index 9cf1196ef2e4b..f125fabafe19c 100644 --- a/lib/public/IContainer.php +++ b/lib/public/IContainer.php @@ -11,7 +11,6 @@ namespace OCP; use Closure; -use OCP\AppFramework\QueryException; use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerInterface; use Psr\Container\NotFoundExceptionInterface; @@ -37,7 +36,6 @@ interface IContainer extends ContainerInterface { * @since 8.2.0 * @deprecated 20.0.0 use \Psr\Container\ContainerInterface::get * @throws ContainerExceptionInterface if the class could not be found or instantiated - * @throws QueryException if the class could not be found or instantiated */ public function resolve($name); @@ -53,7 +51,6 @@ public function resolve($name); * @psalm-return ($name is class-string ? T : mixed) * @throws ContainerExceptionInterface if the query could not be resolved * @throws NotFoundExceptionInterface if the name could not be found within the container - * @throws QueryException if the query could not be resolved * @since 6.0.0 * @deprecated 20.0.0 use \Psr\Container\ContainerInterface::get */ diff --git a/lib/public/Log/functions.php b/lib/public/Log/functions.php index 75e07deab34c2..56da6e89ae0f8 100644 --- a/lib/public/Log/functions.php +++ b/lib/public/Log/functions.php @@ -10,7 +10,8 @@ namespace OCP\Log; use OC; -use OCP\AppFramework\QueryException; +use OCP\Server; +use Psr\Container\ContainerExceptionInterface; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; use function class_exists; @@ -45,14 +46,14 @@ function logger(?string $appId = null): LoggerInterface { try { $appContainer = OC::$server->getRegisteredAppContainer($appId); return $appContainer->get(LoggerInterface::class); - } catch (QueryException $e) { + } catch (ContainerExceptionInterface $e) { // Ignore and return the server logger below } } try { - return OC::$server->get(LoggerInterface::class); - } catch (QueryException $e) { + return Server::get(LoggerInterface::class); + } catch (ContainerExceptionInterface $e) { return new NullLogger(); } }