diff options
author | Morris Jobke <hey@morrisjobke.de> | 2017-08-01 14:28:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-01 14:28:16 +0200 |
commit | 6010c4f267f6b59e0dfd620dc928227f75dae9d1 (patch) | |
tree | e6ee00826da6450dcc12f6346ed2b158f7b8f240 /apps | |
parent | 050fa633800ed6fd922732b8461cf12b380818a1 (diff) | |
parent | f71dc7523f7625da4c47ec9d5b116d20f71dba33 (diff) | |
download | nextcloud-server-6010c4f267f6b59e0dfd620dc928227f75dae9d1.tar.gz nextcloud-server-6010c4f267f6b59e0dfd620dc928227f75dae9d1.zip |
Merge pull request #5877 from nextcloud/typehint_middleware
Prop argument type for Middleware
Diffstat (limited to 'apps')
4 files changed, 20 insertions, 15 deletions
diff --git a/apps/federation/lib/Middleware/AddServerMiddleware.php b/apps/federation/lib/Middleware/AddServerMiddleware.php index 71e517f6b87..5f67ad6b7a5 100644 --- a/apps/federation/lib/Middleware/AddServerMiddleware.php +++ b/apps/federation/lib/Middleware/AddServerMiddleware.php @@ -26,6 +26,7 @@ namespace OCA\Federation\Middleware; use OC\HintException; use OCA\Federation\Controller\SettingsController; +use OCP\AppFramework\Controller; use OCP\AppFramework\Http; use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Middleware; @@ -52,12 +53,13 @@ class AddServerMiddleware extends Middleware { /** * Log error message and return a response which can be displayed to the user * - * @param \OCP\AppFramework\Controller $controller + * @param Controller $controller * @param string $methodName * @param \Exception $exception * @return JSONResponse + * @throws \Exception */ - public function afterException($controller, $methodName, \Exception $exception) { + public function afterException(Controller $controller, $methodName, \Exception $exception) { if (($controller instanceof SettingsController) === false) { throw $exception; } diff --git a/apps/files_sharing/lib/Middleware/OCSShareAPIMiddleware.php b/apps/files_sharing/lib/Middleware/OCSShareAPIMiddleware.php index 5d2c168e876..dd337012507 100644 --- a/apps/files_sharing/lib/Middleware/OCSShareAPIMiddleware.php +++ b/apps/files_sharing/lib/Middleware/OCSShareAPIMiddleware.php @@ -3,6 +3,7 @@ namespace OCA\Files_Sharing\Middleware; use OCA\Files_Sharing\Controller\ShareAPIController; +use OCP\AppFramework\Controller; use OCP\AppFramework\Http\Response; use OCP\AppFramework\Middleware; use OCP\AppFramework\OCS\OCSNotFoundException; @@ -22,12 +23,12 @@ class OCSShareAPIMiddleware extends Middleware { } /** - * @param \OCP\AppFramework\Controller $controller + * @param Controller $controller * @param string $methodName * * @throws OCSNotFoundException */ - public function beforeController($controller, $methodName) { + public function beforeController(Controller $controller, $methodName) { if ($controller instanceof ShareAPIController) { if (!$this->shareManager->shareApiEnabled()) { throw new OCSNotFoundException($this->l->t('Share API is disabled')); @@ -36,12 +37,12 @@ class OCSShareAPIMiddleware extends Middleware { } /** - * @param \OCP\AppFramework\Controller $controller + * @param Controller $controller * @param string $methodName * @param Response $response * @return Response */ - public function afterController($controller, $methodName, Response $response) { + public function afterController(Controller $controller, $methodName, Response $response) { if ($controller instanceof ShareAPIController) { /** @var ShareAPIController $controller */ $controller->cleanup(); diff --git a/apps/files_sharing/lib/Middleware/SharingCheckMiddleware.php b/apps/files_sharing/lib/Middleware/SharingCheckMiddleware.php index 9dd8d2e5ae9..3dd4ad718bb 100644 --- a/apps/files_sharing/lib/Middleware/SharingCheckMiddleware.php +++ b/apps/files_sharing/lib/Middleware/SharingCheckMiddleware.php @@ -28,6 +28,7 @@ namespace OCA\Files_Sharing\Middleware; use OCA\Files_Sharing\Controller\ExternalSharesController; use OCA\Files_Sharing\Controller\ShareController; use OCP\App\IAppManager; +use OCP\AppFramework\Controller; use OCP\AppFramework\Http\NotFoundResponse; use OCP\AppFramework\Middleware; use OCP\Files\NotFoundException; @@ -85,13 +86,13 @@ class SharingCheckMiddleware extends Middleware { /** * Check if sharing is enabled before the controllers is executed * - * @param \OCP\AppFramework\Controller $controller + * @param Controller $controller * @param string $methodName * @throws NotFoundException * @throws S2SException * @throws ShareNotFound */ - public function beforeController($controller, $methodName) { + public function beforeController(Controller $controller, $methodName) { if(!$this->isSharingEnabled()) { throw new NotFoundException('Sharing is disabled.'); } @@ -112,13 +113,13 @@ class SharingCheckMiddleware extends Middleware { /** * Return 404 page in case of a not found exception * - * @param \OCP\AppFramework\Controller $controller + * @param Controller $controller * @param string $methodName * @param \Exception $exception * @return NotFoundResponse * @throws \Exception */ - public function afterException($controller, $methodName, \Exception $exception) { + public function afterException(Controller $controller, $methodName, \Exception $exception) { if(is_a($exception, '\OCP\Files\NotFoundException')) { return new NotFoundResponse(); } diff --git a/apps/provisioning_api/lib/Middleware/ProvisioningApiMiddleware.php b/apps/provisioning_api/lib/Middleware/ProvisioningApiMiddleware.php index d9afe596027..6245d2be907 100644 --- a/apps/provisioning_api/lib/Middleware/ProvisioningApiMiddleware.php +++ b/apps/provisioning_api/lib/Middleware/ProvisioningApiMiddleware.php @@ -3,6 +3,7 @@ namespace OCA\Provisioning_API\Middleware; use OCA\Provisioning_API\Middleware\Exceptions\NotSubAdminException; +use OCP\AppFramework\Controller; use OCP\AppFramework\Http\Response; use OCP\AppFramework\Middleware; use OCP\AppFramework\OCS\OCSException; @@ -36,29 +37,29 @@ class ProvisioningApiMiddleware extends Middleware { } /** - * @param \OCP\AppFramework\Controller $controller + * @param Controller $controller * @param string $methodName * * @throws NotSubAdminException */ - public function beforeController($controller, $methodName) { + public function beforeController(Controller $controller, $methodName) { if (!$this->isAdmin && !$this->reflector->hasAnnotation('NoSubAdminRequired') && !$this->isSubAdmin) { throw new NotSubAdminException(); } } /** - * @param \OCP\AppFramework\Controller $controller + * @param Controller $controller * @param string $methodName * @param \Exception $exception * @throws \Exception * @return Response */ - public function afterException($controller, $methodName, \Exception $exception) { + public function afterException(Controller $controller, $methodName, \Exception $exception) { if ($exception instanceof NotSubAdminException) { throw new OCSException($exception->getMessage(), \OCP\API::RESPOND_UNAUTHORISED); } throw $exception; } -}
\ No newline at end of file +} |