diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php index 898963f5d2..44eb42bdf4 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php @@ -555,8 +555,12 @@ abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerIn * * @internal */ - protected function createChildContext(array $parentContext, $attribute/*, string $format = null */) + protected function createChildContext(array $parentContext, $attribute/*, ?string $format */) { + if (\func_num_args() < 3) { + @trigger_error(sprintf('Method "%s::%s()" will have a third "?string $format" argument in version 5.0; not defining it is deprecated since Symfony 4.3.', \get_class($this), __FUNCTION__), E_USER_DEPRECATED); + $format = null; + } if (isset($parentContext[self::ATTRIBUTES][$attribute])) { $parentContext[self::ATTRIBUTES] = $parentContext[self::ATTRIBUTES][$attribute]; } else { diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php index e4cba584e7..7f22a1df19 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php @@ -559,18 +559,19 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer * We must not mix up the attribute cache between parent and children. * * {@inheritdoc} + * + * @param string|null $format */ - protected function createChildContext(array $parentContext, $attribute/*, string $format = null */) + protected function createChildContext(array $parentContext, $attribute/*, ?string $format */) { if (\func_num_args() >= 3) { $format = \func_get_arg(2); } else { - // will be deprecated in version 4 + @trigger_error(sprintf('Method "%s::%s()" will have a third "?string $format" argument in version 5.0; not defining it is deprecated since Symfony 4.3.', \get_class($this), __FUNCTION__), E_USER_DEPRECATED); $format = null; } $context = parent::createChildContext($parentContext, $attribute, $format); - // format is already included in the cache_key of the parent. $context['cache_key'] = $this->getCacheKey($format, $context); return $context;