Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add psalm docs #25

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Transformer/ApiProblemExceptionTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
use Phpro\ApiProblemBundle\Exception\ApiProblemHttpException;
use Throwable;

/**
* @template-implements ExceptionTransformerInterface<ApiProblemException|ApiProblemHttpException>
*/
class ApiProblemExceptionTransformer implements ExceptionTransformerInterface
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/Transformer/Chain.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
use Phpro\ApiProblem\Http\ExceptionApiProblem;
use Throwable;

/**
* @template-implements ExceptionTransformerInterface<Throwable>
*/
class Chain implements ExceptionTransformerInterface
{
/**
Expand Down
9 changes: 9 additions & 0 deletions src/Transformer/ExceptionTransformerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
3 changes: 3 additions & 0 deletions src/Transformer/HttpExceptionTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
use Symfony\Component\HttpKernel\Exception\HttpException;
use Throwable;

/**
* @template-implements ExceptionTransformerInterface<HttpException>
*/
class HttpExceptionTransformer implements ExceptionTransformerInterface
{
/**
Expand Down
3 changes: 3 additions & 0 deletions src/Transformer/SecurityExceptionTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
use Symfony\Component\Security\Core\Exception\ExceptionInterface as SecurityException;
use Throwable;

/**
* @template-implements ExceptionTransformerInterface<SecurityException>
*/
class SecurityExceptionTransformer implements ExceptionTransformerInterface
{
public function transform(Throwable $exception): ApiProblemInterface
Expand Down
Loading