Skip to content

Commit 9eec57e

Browse files
authored
Merge pull request #25 from phpro/psalm-types
Add psalm docs
2 parents a153e5e + ad139f7 commit 9eec57e

5 files changed

+21
-0
lines changed

src/Transformer/ApiProblemExceptionTransformer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
use Phpro\ApiProblemBundle\Exception\ApiProblemHttpException;
1010
use Throwable;
1111

12+
/**
13+
* @template-implements ExceptionTransformerInterface<ApiProblemException|ApiProblemHttpException>
14+
*/
1215
class ApiProblemExceptionTransformer implements ExceptionTransformerInterface
1316
{
1417
/**

src/Transformer/Chain.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
use Phpro\ApiProblem\Http\ExceptionApiProblem;
99
use Throwable;
1010

11+
/**
12+
* @template-implements ExceptionTransformerInterface<Throwable>
13+
*/
1114
class Chain implements ExceptionTransformerInterface
1215
{
1316
/**

src/Transformer/ExceptionTransformerInterface.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,18 @@
77
use Phpro\ApiProblem\ApiProblemInterface;
88
use Throwable;
99

10+
/**
11+
* @template T of \Throwable
12+
*/
1013
interface ExceptionTransformerInterface
1114
{
15+
/**
16+
* @param T $exception
17+
*/
1218
public function transform(Throwable $exception): ApiProblemInterface;
1319

20+
/**
21+
* @psalm-assert-if-true T $exception
22+
*/
1423
public function accepts(Throwable $exception): bool;
1524
}

src/Transformer/HttpExceptionTransformer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
use Symfony\Component\HttpKernel\Exception\HttpException;
1010
use Throwable;
1111

12+
/**
13+
* @template-implements ExceptionTransformerInterface<HttpException>
14+
*/
1215
class HttpExceptionTransformer implements ExceptionTransformerInterface
1316
{
1417
/**

src/Transformer/SecurityExceptionTransformer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
use Symfony\Component\Security\Core\Exception\ExceptionInterface as SecurityException;
1212
use Throwable;
1313

14+
/**
15+
* @template-implements ExceptionTransformerInterface<SecurityException>
16+
*/
1417
class SecurityExceptionTransformer implements ExceptionTransformerInterface
1518
{
1619
public function transform(Throwable $exception): ApiProblemInterface

0 commit comments

Comments
 (0)