minor #34340 Allow returning null from NormalizerInterface::normalize (teohhanhui)

This PR was merged into the 3.4 branch.

Discussion
----------

Allow returning null from NormalizerInterface::normalize

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes?
| New feature?  | no
| Deprecations? | no
| Tickets       | N/A
| License       | MIT
| Doc PR        | N/A

Looking at the code, it seems that a normalizer might be called with a `null` value for `$data`, and thus it's only sensible that it be allowed to return `null` too:

7064ff35f2/src/Symfony/Component/Serializer/Serializer.php (L141-L148)

Updating the phpdoc to match.

Commits
-------

1c8edc55ad Allow returning null from NormalizerInterface::normalize
This commit is contained in:
Nicolas Grekas 2019-11-13 08:26:33 +01:00
commit 53dc781814
1 changed files with 2 additions and 2 deletions

View File

@ -30,9 +30,9 @@ interface NormalizerInterface
* @param string $format Format the normalization result will be encoded as
* @param array $context Context options for the normalizer
*
* @return array|string|int|float|bool
* @return array|string|int|float|bool|null
*
* @throws InvalidArgumentException Occurs when the object given is not an attempted type for the normalizer
* @throws InvalidArgumentException Occurs when the object given is not a supported 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