From 117b44acff9fd4f4960bd75f7978957a343d6660 Mon Sep 17 00:00:00 2001 From: Ashley Coles Date: Wed, 4 May 2022 18:34:29 +0100 Subject: [PATCH] Adding prop types for Exception classes --- Slim/Exception/HttpBadRequestException.php | 5 +++-- Slim/Exception/HttpException.php | 15 +++------------ Slim/Exception/HttpForbiddenException.php | 4 ++-- Slim/Exception/HttpGoneException.php | 4 ++-- .../HttpInternalServerErrorException.php | 4 ++-- Slim/Exception/HttpMethodNotAllowedException.php | 4 ++-- Slim/Exception/HttpNotFoundException.php | 4 ++-- Slim/Exception/HttpNotImplementedException.php | 4 ++-- Slim/Exception/HttpUnauthorizedException.php | 4 ++-- 9 files changed, 20 insertions(+), 28 deletions(-) diff --git a/Slim/Exception/HttpBadRequestException.php b/Slim/Exception/HttpBadRequestException.php index 9bf60e647..caea20fc0 100644 --- a/Slim/Exception/HttpBadRequestException.php +++ b/Slim/Exception/HttpBadRequestException.php @@ -22,6 +22,7 @@ class HttpBadRequestException extends HttpSpecializedException */ protected $message = 'Bad request.'; - protected $title = '400 Bad Request'; - protected $description = 'The server cannot or will not process the request due to an apparent client error.'; + protected string $title = '400 Bad Request'; + protected string $description = 'The server cannot or will not process' . + 'the request due to an apparent client error.'; } diff --git a/Slim/Exception/HttpException.php b/Slim/Exception/HttpException.php index a49f4cef7..ad43dcffe 100644 --- a/Slim/Exception/HttpException.php +++ b/Slim/Exception/HttpException.php @@ -19,20 +19,11 @@ */ class HttpException extends RuntimeException { - /** - * @var ServerRequestInterface - */ - protected $request; + protected ServerRequestInterface $request; - /** - * @var string - */ - protected $title = ''; + protected string $title = ''; - /** - * @var string - */ - protected $description = ''; + protected string $description = ''; /** * @param ServerRequestInterface $request diff --git a/Slim/Exception/HttpForbiddenException.php b/Slim/Exception/HttpForbiddenException.php index 222273950..dd3bb230a 100644 --- a/Slim/Exception/HttpForbiddenException.php +++ b/Slim/Exception/HttpForbiddenException.php @@ -22,6 +22,6 @@ class HttpForbiddenException extends HttpSpecializedException */ protected $message = 'Forbidden.'; - protected $title = '403 Forbidden'; - protected $description = 'You are not permitted to perform the requested operation.'; + protected string $title = '403 Forbidden'; + protected string $description = 'You are not permitted to perform the requested operation.'; } diff --git a/Slim/Exception/HttpGoneException.php b/Slim/Exception/HttpGoneException.php index 283d73794..42899e1e6 100755 --- a/Slim/Exception/HttpGoneException.php +++ b/Slim/Exception/HttpGoneException.php @@ -22,6 +22,6 @@ class HttpGoneException extends HttpSpecializedException */ protected $message = 'Gone.'; - protected $title = '410 Gone'; - protected $description = 'The target resource is no longer available at the origin server.'; + protected string $title = '410 Gone'; + protected string $description = 'The target resource is no longer available at the origin server.'; } diff --git a/Slim/Exception/HttpInternalServerErrorException.php b/Slim/Exception/HttpInternalServerErrorException.php index 1985a2e37..b43226190 100644 --- a/Slim/Exception/HttpInternalServerErrorException.php +++ b/Slim/Exception/HttpInternalServerErrorException.php @@ -22,6 +22,6 @@ class HttpInternalServerErrorException extends HttpSpecializedException */ protected $message = 'Internal server error.'; - protected $title = '500 Internal Server Error'; - protected $description = 'Unexpected condition encountered preventing server from fulfilling request.'; + protected string $title = '500 Internal Server Error'; + protected string $description = 'Unexpected condition encountered preventing server from fulfilling request.'; } diff --git a/Slim/Exception/HttpMethodNotAllowedException.php b/Slim/Exception/HttpMethodNotAllowedException.php index 44a847f02..a4620ec00 100644 --- a/Slim/Exception/HttpMethodNotAllowedException.php +++ b/Slim/Exception/HttpMethodNotAllowedException.php @@ -29,8 +29,8 @@ class HttpMethodNotAllowedException extends HttpSpecializedException */ protected $message = 'Method not allowed.'; - protected $title = '405 Method Not Allowed'; - protected $description = 'The request method is not supported for the requested resource.'; + protected string $title = '405 Method Not Allowed'; + protected string $description = 'The request method is not supported for the requested resource.'; /** * @return string[] diff --git a/Slim/Exception/HttpNotFoundException.php b/Slim/Exception/HttpNotFoundException.php index 2cc61ba5f..865146d68 100644 --- a/Slim/Exception/HttpNotFoundException.php +++ b/Slim/Exception/HttpNotFoundException.php @@ -22,6 +22,6 @@ class HttpNotFoundException extends HttpSpecializedException */ protected $message = 'Not found.'; - protected $title = '404 Not Found'; - protected $description = 'The requested resource could not be found. Please verify the URI and try again.'; + protected string $title = '404 Not Found'; + protected string $description = 'The requested resource could not be found. Please verify the URI and try again.'; } diff --git a/Slim/Exception/HttpNotImplementedException.php b/Slim/Exception/HttpNotImplementedException.php index cd9bf5f8f..607a6f49a 100644 --- a/Slim/Exception/HttpNotImplementedException.php +++ b/Slim/Exception/HttpNotImplementedException.php @@ -22,6 +22,6 @@ class HttpNotImplementedException extends HttpSpecializedException */ protected $message = 'Not implemented.'; - protected $title = '501 Not Implemented'; - protected $description = 'The server does not support the functionality required to fulfill the request.'; + protected string $title = '501 Not Implemented'; + protected string $description = 'The server does not support the functionality required to fulfill the request.'; } diff --git a/Slim/Exception/HttpUnauthorizedException.php b/Slim/Exception/HttpUnauthorizedException.php index 41d59d978..07bd70d01 100644 --- a/Slim/Exception/HttpUnauthorizedException.php +++ b/Slim/Exception/HttpUnauthorizedException.php @@ -22,6 +22,6 @@ class HttpUnauthorizedException extends HttpSpecializedException */ protected $message = 'Unauthorized.'; - protected $title = '401 Unauthorized'; - protected $description = 'The request requires valid user authentication.'; + protected string $title = '401 Unauthorized'; + protected string $description = 'The request requires valid user authentication.'; }