Skip to content

Commit dc98d5a

Browse files
Nek-fabpot
authored andcommitted
Fix phpdoc for serializer normalizers exceptions
The normalizers throw exceptions. They need to be documented for DX in the normalizer/denormalizer interfaces. [Serializer] fit Symfony phpdoc standard It also adds meaning of each exception throw. Fix grammary in phpdoc
1 parent 993a79c commit dc98d5a

File tree

5 files changed

+23
-8
lines changed

5 files changed

+23
-8
lines changed

Normalizer/AbstractObjectNormalizer.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Symfony\Component\PropertyAccess\Exception\InvalidArgumentException;
1515
use Symfony\Component\Serializer\Encoder\JsonEncoder;
16-
use Symfony\Component\Serializer\Exception\CircularReferenceException;
1716
use Symfony\Component\Serializer\Exception\LogicException;
1817
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
1918
use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface;
@@ -52,8 +51,6 @@ public function supportsNormalization($data, $format = null)
5251

5352
/**
5453
* {@inheritdoc}
55-
*
56-
* @throws CircularReferenceException
5754
*/
5855
public function normalize($object, $format = null, array $context = array())
5956
{

Normalizer/ArrayDenormalizer.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ class ArrayDenormalizer implements DenormalizerInterface, SerializerAwareInterfa
3131

3232
/**
3333
* {@inheritdoc}
34-
*
35-
* @throws UnexpectedValueException
3634
*/
3735
public function denormalize($data, $class, $format = null, array $context = array())
3836
{

Normalizer/DataUriNormalizer.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ public function supportsNormalization($data, $format = null)
7979
* Regex adapted from Brian Grinstead code.
8080
*
8181
* @see https://gist.github.com/bgrins/6194623
82-
*
83-
* @throws InvalidArgumentException
84-
* @throws UnexpectedValueException
8582
*/
8683
public function denormalize($data, $class, $format = null, array $context = array())
8784
{

Normalizer/DenormalizerInterface.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111

1212
namespace Symfony\Component\Serializer\Normalizer;
1313

14+
use Symfony\Component\Serializer\Exception\BadMethodCallException;
15+
use Symfony\Component\Serializer\Exception\ExtraAttributesException;
16+
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
17+
use Symfony\Component\Serializer\Exception\LogicException;
18+
use Symfony\Component\Serializer\Exception\RuntimeException;
19+
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
20+
1421
/**
1522
* Defines the interface of denormalizers.
1623
*
@@ -27,6 +34,13 @@ interface DenormalizerInterface
2734
* @param array $context options available to the denormalizer
2835
*
2936
* @return object
37+
*
38+
* @throws BadMethodCallException Occurs when the normalizer is not called in an expected context
39+
* @throws InvalidArgumentException Occurs when the arguments are not coherent or not supported
40+
* @throws UnexpectedValueException Occurs when the item cannot be hydrated with the given data
41+
* @throws ExtraAttributesException Occurs when the item doesn't have attribute to receive given data
42+
* @throws LogicException Occurs when the normalizer is not supposed to denormalize
43+
* @throws RuntimeException Occurs if the class cannot be instantiated
3044
*/
3145
public function denormalize($data, $class, $format = null, array $context = array());
3246

Normalizer/NormalizerInterface.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111

1212
namespace Symfony\Component\Serializer\Normalizer;
1313

14+
use Symfony\Component\Serializer\Exception\CircularReferenceException;
15+
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
16+
use Symfony\Component\Serializer\Exception\LogicException;
17+
1418
/**
1519
* Defines the interface of normalizers.
1620
*
@@ -26,6 +30,11 @@ interface NormalizerInterface
2630
* @param array $context Context options for the normalizer
2731
*
2832
* @return array|scalar
33+
*
34+
* @throws InvalidArgumentException Occurs when the object given is not an attempted type for the normalizer
35+
* @throws CircularReferenceException Occurs when the normalizer detects a circular reference when no circular
36+
* reference handler can fix it
37+
* @throws LogicException Occurs when the normalizer is not called in an expected context
2938
*/
3039
public function normalize($object, $format = null, array $context = array());
3140

0 commit comments

Comments
 (0)