Skip to content

Commit

Permalink
Merge pull request #3195 from ashleycoles/exceptionTypes
Browse files Browse the repository at this point in the history
Adding prop types for Exception classes
  • Loading branch information
l0gicgate authored May 5, 2022
2 parents 1eab45e + bcde908 commit f3fd487
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 28 deletions.
5 changes: 3 additions & 2 deletions Slim/Exception/HttpBadRequestException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
}
15 changes: 3 additions & 12 deletions Slim/Exception/HttpException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Slim/Exception/HttpForbiddenException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
}
4 changes: 2 additions & 2 deletions Slim/Exception/HttpGoneException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
}
4 changes: 2 additions & 2 deletions Slim/Exception/HttpInternalServerErrorException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
}
4 changes: 2 additions & 2 deletions Slim/Exception/HttpMethodNotAllowedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand Down
4 changes: 2 additions & 2 deletions Slim/Exception/HttpNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
}
4 changes: 2 additions & 2 deletions Slim/Exception/HttpNotImplementedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
}
4 changes: 2 additions & 2 deletions Slim/Exception/HttpUnauthorizedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
}

0 comments on commit f3fd487

Please # to comment.