Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cb77902

Browse files
dbufabpot
authored andcommitted
deprecate calling createChildContext without the format parameter
1 parent b529e07 commit cb77902

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,12 @@ protected function denormalizeParameter(\ReflectionClass $class, \ReflectionPara
555555
*
556556
* @internal
557557
*/
558-
protected function createChildContext(array $parentContext, $attribute/*, string $format = null */)
558+
protected function createChildContext(array $parentContext, $attribute/*, ?string $format */)
559559
{
560+
if (\func_num_args() < 3) {
561+
@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);
562+
$format = null;
563+
}
560564
if (isset($parentContext[self::ATTRIBUTES][$attribute])) {
561565
$parentContext[self::ATTRIBUTES] = $parentContext[self::ATTRIBUTES][$attribute];
562566
} else {

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,18 +559,19 @@ private function isMaxDepthReached(array $attributesMetadata, string $class, str
559559
* We must not mix up the attribute cache between parent and children.
560560
*
561561
* {@inheritdoc}
562+
*
563+
* @param string|null $format
562564
*/
563-
protected function createChildContext(array $parentContext, $attribute/*, string $format = null */)
565+
protected function createChildContext(array $parentContext, $attribute/*, ?string $format */)
564566
{
565567
if (\func_num_args() >= 3) {
566568
$format = \func_get_arg(2);
567569
} else {
568-
// will be deprecated in version 4
570+
@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);
569571
$format = null;
570572
}
571573

572574
$context = parent::createChildContext($parentContext, $attribute, $format);
573-
// format is already included in the cache_key of the parent.
574575
$context['cache_key'] = $this->getCacheKey($format, $context);
575576

576577
return $context;

0 commit comments

Comments
 (0)