From ad139f752b40247461af5c1f37f0de55147d1ab5 Mon Sep 17 00:00:00 2001 From: Toon Verwerft Date: Thu, 7 Nov 2024 11:53:51 +0100 Subject: [PATCH] Add psalm docs --- src/Transformer/ApiProblemExceptionTransformer.php | 3 +++ src/Transformer/Chain.php | 3 +++ src/Transformer/ExceptionTransformerInterface.php | 9 +++++++++ src/Transformer/HttpExceptionTransformer.php | 3 +++ src/Transformer/SecurityExceptionTransformer.php | 3 +++ 5 files changed, 21 insertions(+) diff --git a/src/Transformer/ApiProblemExceptionTransformer.php b/src/Transformer/ApiProblemExceptionTransformer.php index 9315f9c..4dab312 100644 --- a/src/Transformer/ApiProblemExceptionTransformer.php +++ b/src/Transformer/ApiProblemExceptionTransformer.php @@ -9,6 +9,9 @@ use Phpro\ApiProblemBundle\Exception\ApiProblemHttpException; use Throwable; +/** + * @template-implements ExceptionTransformerInterface + */ class ApiProblemExceptionTransformer implements ExceptionTransformerInterface { /** diff --git a/src/Transformer/Chain.php b/src/Transformer/Chain.php index 7438d3b..949614c 100644 --- a/src/Transformer/Chain.php +++ b/src/Transformer/Chain.php @@ -8,6 +8,9 @@ use Phpro\ApiProblem\Http\ExceptionApiProblem; use Throwable; +/** + * @template-implements ExceptionTransformerInterface + */ class Chain implements ExceptionTransformerInterface { /** diff --git a/src/Transformer/ExceptionTransformerInterface.php b/src/Transformer/ExceptionTransformerInterface.php index 9c58782..dc59a7c 100644 --- a/src/Transformer/ExceptionTransformerInterface.php +++ b/src/Transformer/ExceptionTransformerInterface.php @@ -7,9 +7,18 @@ use Phpro\ApiProblem\ApiProblemInterface; use Throwable; +/** + * @template T of \Throwable + */ interface ExceptionTransformerInterface { + /** + * @param T $exception + */ public function transform(Throwable $exception): ApiProblemInterface; + /** + * @psalm-assert-if-true T $exception + */ public function accepts(Throwable $exception): bool; } diff --git a/src/Transformer/HttpExceptionTransformer.php b/src/Transformer/HttpExceptionTransformer.php index acd1ff6..18aedc2 100644 --- a/src/Transformer/HttpExceptionTransformer.php +++ b/src/Transformer/HttpExceptionTransformer.php @@ -9,6 +9,9 @@ use Symfony\Component\HttpKernel\Exception\HttpException; use Throwable; +/** + * @template-implements ExceptionTransformerInterface + */ class HttpExceptionTransformer implements ExceptionTransformerInterface { /** diff --git a/src/Transformer/SecurityExceptionTransformer.php b/src/Transformer/SecurityExceptionTransformer.php index 5eb9855..b6a8a08 100644 --- a/src/Transformer/SecurityExceptionTransformer.php +++ b/src/Transformer/SecurityExceptionTransformer.php @@ -11,6 +11,9 @@ use Symfony\Component\Security\Core\Exception\ExceptionInterface as SecurityException; use Throwable; +/** + * @template-implements ExceptionTransformerInterface + */ class SecurityExceptionTransformer implements ExceptionTransformerInterface { public function transform(Throwable $exception): ApiProblemInterface