Skip to content

Commit

Permalink
Merge pull request #25 from phpro/psalm-types
Browse files Browse the repository at this point in the history
Add psalm docs
  • Loading branch information
veewee authored Nov 7, 2024
2 parents a153e5e + ad139f7 commit 9eec57e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
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

0 comments on commit 9eec57e

Please sign in to comment.