Skip to content

Commit da3411d

Browse files
committed
deprecate calling createChildContext without the format parameter
1 parent 77f642e commit da3411d

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,12 @@ protected function denormalizeParameter(\ReflectionClass $class, \ReflectionPara
486486
*
487487
* @internal
488488
*/
489-
protected function createChildContext(array $parentContext, $attribute/*, string $format = null */)
489+
protected function createChildContext(array $parentContext, $attribute/*, ?string $format */)
490490
{
491+
if (\func_num_args() < 3) {
492+
@trigger_error(sprintf('Method "%s::%s()" will have a 3rd "?string $format" argument in version 5.0; not defining it is deprecated since Symfony 4.3.', \get_class($this), __FUNCTION__), E_USER_DEPRECATED);
493+
$format = null;
494+
}
491495
if (isset($parentContext[self::ATTRIBUTES][$attribute])) {
492496
$parentContext[self::ATTRIBUTES] = $parentContext[self::ATTRIBUTES][$attribute];
493497
} else {

src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -512,18 +512,19 @@ private function isMaxDepthReached(array $attributesMetadata, string $class, str
512512
* We must not mix up the attribute cache between parent and children.
513513
*
514514
* {@inheritdoc}
515+
*
516+
* @param string|null $format
515517
*/
516-
protected function createChildContext(array $parentContext, $attribute/*, string $format = null */)
518+
protected function createChildContext(array $parentContext, $attribute/*, ?string $format */)
517519
{
518520
if (\func_num_args() >= 3) {
519521
$format = \func_get_arg(2);
520522
} else {
521-
// will be deprecated in version 4
523+
@trigger_error(sprintf('Method "%s::%s()" will have a 3rd "?string $format" argument in version 5.0; not defining it is deprecated since Symfony 4.3.', \get_class($this), __FUNCTION__), E_USER_DEPRECATED);
522524
$format = null;
523525
}
524526

525527
$context = parent::createChildContext($parentContext, $attribute, $format);
526-
// format is already included in the cache_key of the parent.
527528
$context['cache_key'] = $this->getCacheKey($format, $context);
528529

529530
return $context;

0 commit comments

Comments
 (0)