diff --git a/src/ApiException.php b/src/ApiException.php index 3dfee3c..247a5dc 100644 --- a/src/ApiException.php +++ b/src/ApiException.php @@ -13,13 +13,13 @@ abstract class ApiException extends IdException implements Jsonable, \JsonSerial protected $headers = []; /** - * @param int $statusCode - * @param string $id - * @param string $message - * @param \Exception $previous - * @param array $headers + * @param int $statusCode + * @param string $id + * @param string $message + * @param \Throwable|null $previous + * @param array $headers */ - public function __construct($statusCode = 0, $id = '', $message = '', \Exception $previous = null, array $headers = []) + public function __construct($statusCode = 0, $id = '', $message = '', ?\Throwable $previous = null, array $headers = []) { $this->headers = $headers; diff --git a/src/BadRequestApiException.php b/src/BadRequestApiException.php index c3a52b2..90b8550 100644 --- a/src/BadRequestApiException.php +++ b/src/BadRequestApiException.php @@ -2,16 +2,15 @@ namespace Lanin\Laravel\ApiExceptions; -use Exception; use Lanin\Laravel\ApiExceptions\Contracts\DontReport; class BadRequestApiException extends ApiException implements DontReport { /** * @param string $message - * @param Exception $previous + * @param \Throwable|null $previous */ - public function __construct($message = '', Exception $previous = null) + public function __construct($message = '', ?\Throwable $previous = null) { if (empty($message)) { $message = 'The server cannot process the request due to its malformed syntax.'; diff --git a/src/ConflictApiException.php b/src/ConflictApiException.php index 5664b49..42651ed 100644 --- a/src/ConflictApiException.php +++ b/src/ConflictApiException.php @@ -2,16 +2,15 @@ namespace Lanin\Laravel\ApiExceptions; -use Exception; use Lanin\Laravel\ApiExceptions\Contracts\DontReport; class ConflictApiException extends ApiException implements DontReport { /** * @param string $message - * @param Exception $previous + * @param \Throwable $previous */ - public function __construct($message = '', Exception $previous = null) + public function __construct($message = '', ?\Throwable $previous = null) { if (empty($message)) { $message = 'Request could not be processed because of conflict.'; diff --git a/src/ExceptionHandlerTrait.php b/src/ExceptionHandlerTrait.php index 07926bc..db5d3fe 100644 --- a/src/ExceptionHandlerTrait.php +++ b/src/ExceptionHandlerTrait.php @@ -2,7 +2,6 @@ namespace Lanin\Laravel\ApiExceptions; -use Throwable; use Illuminate\Auth\Access\AuthorizationException; use Illuminate\Auth\AuthenticationException; use Illuminate\Database\Eloquent\ModelNotFoundException; @@ -16,11 +15,11 @@ trait ExceptionHandlerTrait * Report or log an exception. * This is a great spot to send exceptions to Sentry, Bugsnag, etc. * - * @param Throwable $e + * @param \Throwable $e * @return void - * @throws Exception + * @throws \Throwable */ - public function report(Throwable $e) + public function report(\Throwable $e) { parent::report($e instanceof ApiException ? $e->toReport() : $e); } @@ -29,10 +28,10 @@ public function report(Throwable $e) * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request - * @param Throwable $e + * @param \Throwable $e * @return \Illuminate\Http\Response */ - public function render($request, Throwable $e) + public function render($request, \Throwable $e) { $e = $this->resolveException($e); @@ -44,10 +43,10 @@ public function render($request, Throwable $e) /** * Define exception. * - * @param Throwable $e + * @param \Throwable $e * @return ApiException */ - protected function resolveException(Throwable $e) + protected function resolveException(\Throwable $e) { switch (true) { case $e instanceof ApiException: diff --git a/src/ForbiddenApiException.php b/src/ForbiddenApiException.php index 765a169..e1d71a8 100644 --- a/src/ForbiddenApiException.php +++ b/src/ForbiddenApiException.php @@ -2,16 +2,15 @@ namespace Lanin\Laravel\ApiExceptions; -use Exception; use Lanin\Laravel\ApiExceptions\Contracts\DontReport; class ForbiddenApiException extends ApiException implements DontReport { /** * @param string $message - * @param Exception $previous + * @param \Throwable|null $previous */ - public function __construct($message = '', Exception $previous = null) + public function __construct($message = '', ?\Throwable $previous = null) { if (empty($message)) { $message = "You don't have permissions to perform this request."; diff --git a/src/IdException.php b/src/IdException.php index 544f6c5..0439c10 100644 --- a/src/IdException.php +++ b/src/IdException.php @@ -9,10 +9,10 @@ class IdException extends \RuntimeException /** * @param string $id * @param string $message - * @param \Exception $previous + * @param \Throwable|null $previous * @param int $code */ - public function __construct($id = '', $message = '', \Exception $previous = null, $code = 0) + public function __construct($id = '', $message = '', ?\Throwable $previous = null, $code = 0) { $this->id = $id; diff --git a/src/InternalServerErrorApiException.php b/src/InternalServerErrorApiException.php index c4dc77b..0fd9dbf 100644 --- a/src/InternalServerErrorApiException.php +++ b/src/InternalServerErrorApiException.php @@ -2,7 +2,6 @@ namespace Lanin\Laravel\ApiExceptions; -use Exception; use Lanin\Laravel\ApiExceptions\Contracts\ShowsPrevious; use Lanin\Laravel\ApiExceptions\Contracts\ShowsTrace; @@ -10,9 +9,9 @@ class InternalServerErrorApiException extends ApiException implements ShowsTrace { /** * @param string $message - * @param Exception $previous + * @param \Throwable|null $previous */ - public function __construct($message = '', Exception $previous = null) + public function __construct($message = '', ?\Throwable $previous = null) { if (empty($message)) { $message = 'The server encountered an internal error or misconfiguration and was unable to complete your request.'; diff --git a/src/MethodNotAllowedApiException.php b/src/MethodNotAllowedApiException.php index 6f154fe..ff81a12 100644 --- a/src/MethodNotAllowedApiException.php +++ b/src/MethodNotAllowedApiException.php @@ -2,16 +2,15 @@ namespace Lanin\Laravel\ApiExceptions; -use Exception; use Lanin\Laravel\ApiExceptions\Contracts\DontReport; class MethodNotAllowedApiException extends ApiException implements DontReport { /** * @param string $message - * @param Exception $previous + * @param \Throwable|null $previous */ - public function __construct($message = '', Exception $previous = null) + public function __construct($message = '', ?\Throwable $previous = null) { if (empty($message)) { $message = 'A request was made of a resource using a request method not supported by that resource.'; diff --git a/src/NotFoundApiException.php b/src/NotFoundApiException.php index c83ae21..16eac1a 100644 --- a/src/NotFoundApiException.php +++ b/src/NotFoundApiException.php @@ -2,16 +2,15 @@ namespace Lanin\Laravel\ApiExceptions; -use Exception; use Lanin\Laravel\ApiExceptions\Contracts\DontReport; class NotFoundApiException extends ApiException implements DontReport { /** * @param string $message - * @param Exception $previous + * @param \Throwable|null $previous */ - public function __construct($message = '', Exception $previous = null) + public function __construct($message = '', ?\Throwable $previous = null) { if (empty($message)) { $message = 'Requested object not found.'; diff --git a/src/TooManyRequestsApiException.php b/src/TooManyRequestsApiException.php index f1ae4f3..4c59eb3 100644 --- a/src/TooManyRequestsApiException.php +++ b/src/TooManyRequestsApiException.php @@ -2,7 +2,6 @@ namespace Lanin\Laravel\ApiExceptions; -use Exception; use Lanin\Laravel\ApiExceptions\Contracts\DontReport; class TooManyRequestsApiException extends ApiException implements DontReport @@ -16,9 +15,9 @@ class TooManyRequestsApiException extends ApiException implements DontReport * @param int|null $retryAfter * @param array $headers * @param string $message - * @param Exception $previous + * @param \Throwable|null $previous */ - public function __construct($retryAfter = null, $headers = [], $message = '', Exception $previous = null) + public function __construct($retryAfter = null, $headers = [], $message = '', ?\Throwable $previous = null) { $this->retryAfter = $retryAfter; diff --git a/src/UnauthorizedApiException.php b/src/UnauthorizedApiException.php index 744997a..1b2daa6 100644 --- a/src/UnauthorizedApiException.php +++ b/src/UnauthorizedApiException.php @@ -2,16 +2,15 @@ namespace Lanin\Laravel\ApiExceptions; -use Exception; use Lanin\Laravel\ApiExceptions\Contracts\DontReport; class UnauthorizedApiException extends ApiException implements DontReport { /** * @param string $message - * @param Exception $previous + * @param \Throwable|null $previous */ - public function __construct($message = '', Exception $previous = null) + public function __construct($message = '', ?\Throwable $previous = null) { if (empty($message)) { $message = 'Sent credentials are invalid.'; diff --git a/src/ValidationFailedApiException.php b/src/ValidationFailedApiException.php index 96b9634..3384330 100644 --- a/src/ValidationFailedApiException.php +++ b/src/ValidationFailedApiException.php @@ -2,7 +2,6 @@ namespace Lanin\Laravel\ApiExceptions; -use Exception; use Lanin\Laravel\ApiExceptions\Contracts\DontReport; class ValidationFailedApiException extends ApiException implements DontReport @@ -17,9 +16,9 @@ class ValidationFailedApiException extends ApiException implements DontReport * * @param array $errors * @param string $message - * @param Exception $previous + * @param \Throwable|null $previous */ - public function __construct(array $errors, $message = '', Exception $previous = null) + public function __construct(array $errors, $message = '', ?\Throwable $previous = null) { $this->errors = $errors;