Skip to content

Commit cbf5b9c

Browse files
hxvondrejmirtes
authored andcommitted
Add @throws annotations in DenormalizerInterface::denormalize() and NormalizerInterface::normalize().
1 parent 2107dee commit cbf5b9c

11 files changed

+102
-0
lines changed

extension.neon

+8
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ parameters:
5858
- stubs/Symfony/Component/Serializer/Encoder/ContextAwareDecoderInterface.stub
5959
- stubs/Symfony/Component/Serializer/Encoder/DecoderInterface.stub
6060
- stubs/Symfony/Component/Serializer/Encoder/EncoderInterface.stub
61+
- stubs/Symfony/Component/Serializer/Exception/BadMethodCallException.stub
62+
- stubs/Symfony/Component/Serializer/Exception/CircularReferenceException.stub
63+
- stubs/Symfony/Component/Serializer/Exception/ExceptionInterface.stub
64+
- stubs/Symfony/Component/Serializer/Exception/ExtraAttributesException.stub
65+
- stubs/Symfony/Component/Serializer/Exception/InvalidArgumentException.stub
66+
- stubs/Symfony/Component/Serializer/Exception/LogicException.stub
67+
- stubs/Symfony/Component/Serializer/Exception/RuntimeException.stub
68+
- stubs/Symfony/Component/Serializer/Exception/UnexpectedValueException.stub
6169
- stubs/Symfony/Component/Serializer/Normalizer/ContextAwareDenormalizerInterface.stub
6270
- stubs/Symfony/Component/Serializer/Normalizer/ContextAwareNormalizerInterface.stub
6371
- stubs/Symfony/Component/Serializer/Normalizer/DenormalizableInterface.stub
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Symfony\Component\Serializer\Exception;
4+
5+
class BadMethodCallException extends \BadMethodCallException implements ExceptionInterface
6+
{
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Symfony\Component\Serializer\Exception;
4+
5+
class CircularReferenceException extends RuntimeException
6+
{
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Symfony\Component\Serializer\Exception;
4+
5+
interface ExceptionInterface extends \Throwable
6+
{
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace Symfony\Component\Serializer\Exception;
4+
5+
class ExtraAttributesException extends RuntimeException
6+
{
7+
/**
8+
* @param string[] $extraAttributes
9+
*/
10+
public function __construct(array $extraAttributes, \Throwable $previous = null)
11+
{
12+
}
13+
14+
/**
15+
* @return string[]
16+
*/
17+
public function getExtraAttributes()
18+
{
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Symfony\Component\Serializer\Exception;
4+
5+
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
6+
{
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Symfony\Component\Serializer\Exception;
4+
5+
class LogicException extends \LogicException implements ExceptionInterface
6+
{
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Symfony\Component\Serializer\Exception;
4+
5+
class RuntimeException extends \RuntimeException implements ExceptionInterface
6+
{
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Symfony\Component\Serializer\Exception;
4+
5+
class UnexpectedValueException extends \UnexpectedValueException implements ExceptionInterface
6+
{
7+
}

stubs/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.stub

+16
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
namespace Symfony\Component\Serializer\Normalizer;
44

5+
use Symfony\Component\Serializer\Exception\BadMethodCallException;
6+
use Symfony\Component\Serializer\Exception\ExceptionInterface;
7+
use Symfony\Component\Serializer\Exception\ExtraAttributesException;
8+
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
9+
use Symfony\Component\Serializer\Exception\LogicException;
10+
use Symfony\Component\Serializer\Exception\RuntimeException;
11+
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
12+
513
interface DenormalizerInterface
614
{
715
/**
@@ -10,6 +18,14 @@ interface DenormalizerInterface
1018
* @param string|null $format
1119
* @param array<mixed> $context
1220
* @return mixed
21+
*
22+
* @throws BadMethodCallException
23+
* @throws InvalidArgumentException
24+
* @throws UnexpectedValueException
25+
* @throws ExtraAttributesException
26+
* @throws LogicException
27+
* @throws RuntimeException
28+
* @throws ExceptionInterface
1329
*/
1430
public function denormalize($data, $type, $format = null, array $context = []);
1531

stubs/Symfony/Component/Serializer/Normalizer/NormalizerInterface.stub

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
namespace Symfony\Component\Serializer\Normalizer;
44

55
use ArrayObject;
6+
use Symfony\Component\Serializer\Exception\CircularReferenceException;
7+
use Symfony\Component\Serializer\Exception\ExceptionInterface;
8+
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
9+
use Symfony\Component\Serializer\Exception\LogicException;
610

711
interface NormalizerInterface
812
{
@@ -12,6 +16,11 @@ interface NormalizerInterface
1216
* @param array<mixed> $context
1317
*
1418
* @return array<mixed>|ArrayObject<array-key, mixed>|string|int|float|bool|null
19+
*
20+
* @throws InvalidArgumentException
21+
* @throws CircularReferenceException
22+
* @throws LogicException
23+
* @throws ExceptionInterface
1524
*/
1625
public function normalize($object, $format = null, array $context = []);
1726

0 commit comments

Comments
 (0)