minor #22231 [DX] Fix phpdoc for serializer normalizers exceptions (Nek-)

This PR was submitted for the master branch but it was merged into the 3.2 branch instead (closes #22231).

Discussion
----------

[DX] Fix phpdoc for serializer normalizers exceptions

The normalizers throw exceptions. They need to be documented for DX in the normalizer/denormalizer interfaces.

| Q             | A
| ------------- | ---
| Branch?       | master (rebase on 2.7 if you want?)
| Bug fix?      | no
| New feature?  | yes?
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #22218
| License       | MIT
| Doc PR        | Not needed

Commits
-------

ec3cc84656 Fix phpdoc for serializer normalizers exceptions
This commit is contained in:
Fabien Potencier 2017-07-06 10:40:01 +03:00
commit de820d189c
5 changed files with 23 additions and 8 deletions

View File

@ -13,7 +13,6 @@ namespace Symfony\Component\Serializer\Normalizer;
use Symfony\Component\PropertyAccess\Exception\InvalidArgumentException;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Exception\CircularReferenceException;
use Symfony\Component\Serializer\Exception\LogicException;
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface;
@ -52,8 +51,6 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer
/**
* {@inheritdoc}
*
* @throws CircularReferenceException
*/
public function normalize($object, $format = null, array $context = array())
{

View File

@ -31,8 +31,6 @@ class ArrayDenormalizer implements DenormalizerInterface, SerializerAwareInterfa
/**
* {@inheritdoc}
*
* @throws UnexpectedValueException
*/
public function denormalize($data, $class, $format = null, array $context = array())
{

View File

@ -79,9 +79,6 @@ class DataUriNormalizer implements NormalizerInterface, DenormalizerInterface
* Regex adapted from Brian Grinstead code.
*
* @see https://gist.github.com/bgrins/6194623
*
* @throws InvalidArgumentException
* @throws UnexpectedValueException
*/
public function denormalize($data, $class, $format = null, array $context = array())
{

View File

@ -11,6 +11,13 @@
namespace Symfony\Component\Serializer\Normalizer;
use Symfony\Component\Serializer\Exception\BadMethodCallException;
use Symfony\Component\Serializer\Exception\ExtraAttributesException;
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
use Symfony\Component\Serializer\Exception\LogicException;
use Symfony\Component\Serializer\Exception\RuntimeException;
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
/**
* Defines the interface of denormalizers.
*
@ -27,6 +34,13 @@ interface DenormalizerInterface
* @param array $context options available to the denormalizer
*
* @return object
*
* @throws BadMethodCallException Occurs when the normalizer is not called in an expected context
* @throws InvalidArgumentException Occurs when the arguments are not coherent or not supported
* @throws UnexpectedValueException Occurs when the item cannot be hydrated with the given data
* @throws ExtraAttributesException Occurs when the item doesn't have attribute to receive given data
* @throws LogicException Occurs when the normalizer is not supposed to denormalize
* @throws RuntimeException Occurs if the class cannot be instantiated
*/
public function denormalize($data, $class, $format = null, array $context = array());

View File

@ -11,6 +11,10 @@
namespace Symfony\Component\Serializer\Normalizer;
use Symfony\Component\Serializer\Exception\CircularReferenceException;
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
use Symfony\Component\Serializer\Exception\LogicException;
/**
* Defines the interface of normalizers.
*
@ -26,6 +30,11 @@ interface NormalizerInterface
* @param array $context Context options for the normalizer
*
* @return array|scalar
*
* @throws InvalidArgumentException Occurs when the object given is not an attempted type for the normalizer
* @throws CircularReferenceException Occurs when the normalizer detects a circular reference when no circular
* reference handler can fix it
* @throws LogicException Occurs when the normalizer is not called in an expected context
*/
public function normalize($object, $format = null, array $context = array());