diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2021-03-02 20:36:04 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2021-03-02 20:36:04 +0100 |
commit | 5c952e83fcff7960a6e9ec5241a2f0c3fb215151 (patch) | |
tree | ca567d47f20d7a060c359211a19bca75b64b60c2 | |
parent | 04dc321ee732afb95dee8ddc226fd3dc0bd9fd64 (diff) | |
download | nextcloud-server-5c952e83fcff7960a6e9ec5241a2f0c3fb215151.tar.gz nextcloud-server-5c952e83fcff7960a6e9ec5241a2f0c3fb215151.zip |
Pimp sharingcheckmiddleware
Reported by psalm
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
-rw-r--r-- | apps/files_sharing/lib/Middleware/SharingCheckMiddleware.php | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/apps/files_sharing/lib/Middleware/SharingCheckMiddleware.php b/apps/files_sharing/lib/Middleware/SharingCheckMiddleware.php index c58496a46d7..335b0908a98 100644 --- a/apps/files_sharing/lib/Middleware/SharingCheckMiddleware.php +++ b/apps/files_sharing/lib/Middleware/SharingCheckMiddleware.php @@ -1,4 +1,6 @@ <?php + +declare(strict_types=1); /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @@ -33,12 +35,12 @@ use OCP\App\IAppManager; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\NotFoundResponse; +use OCP\AppFramework\Http\Response; use OCP\AppFramework\Middleware; use OCP\AppFramework\Utility\IControllerMethodReflector; use OCP\Files\NotFoundException; use OCP\IConfig; use OCP\IRequest; -use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IManager; /** @@ -61,15 +63,7 @@ class SharingCheckMiddleware extends Middleware { /** @var IRequest */ protected $request; - /*** - * @param string $appName - * @param IConfig $config - * @param IAppManager $appManager - * @param IControllerMethodReflector $reflector - * @param IManager $shareManager - * @param IRequest $request - */ - public function __construct($appName, + public function __construct(string $appName, IConfig $config, IAppManager $appManager, IControllerMethodReflector $reflector, @@ -91,9 +85,8 @@ class SharingCheckMiddleware extends Middleware { * @param string $methodName * @throws NotFoundException * @throws S2SException - * @throws ShareNotFound */ - public function beforeController($controller, $methodName) { + public function beforeController($controller, $methodName): void { if (!$this->isSharingEnabled()) { throw new NotFoundException('Sharing is disabled.'); } @@ -110,10 +103,10 @@ class SharingCheckMiddleware extends Middleware { * @param Controller $controller * @param string $methodName * @param \Exception $exception - * @return NotFoundResponse + * @return Response * @throws \Exception */ - public function afterException($controller, $methodName, \Exception $exception) { + public function afterException($controller, $methodName, \Exception $exception): Response { if (is_a($exception, NotFoundException::class)) { return new NotFoundResponse(); } @@ -129,7 +122,7 @@ class SharingCheckMiddleware extends Middleware { * Checks for externalshares controller * @return bool */ - private function externalSharesChecks() { + private function externalSharesChecks(): bool { if (!$this->reflector->hasAnnotation('NoIncomingFederatedSharingRequired') && $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') !== 'yes') { return false; @@ -147,7 +140,7 @@ class SharingCheckMiddleware extends Middleware { * Check whether sharing is enabled * @return bool */ - private function isSharingEnabled() { + private function isSharingEnabled(): bool { // FIXME: This check is done here since the route is globally defined and not inside the files_sharing app // Check whether the sharing application is enabled if (!$this->appManager->isEnabledForUser($this->appName)) { |