Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c5772ae

Browse filesBrowse files
committed
feature #31030 [Serializer] Deprecate calling createChildContext without the format parameter (dbu)
This PR was submitted for the master branch but it was merged into the 4.3 branch instead (closes #31030). Discussion ---------- [Serializer] Deprecate calling createChildContext without the format parameter | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - as discussed in #30907 deprecate omitting the format parameter when extending the AbstractNormalizer. Commits ------- cb77902 deprecate calling createChildContext without the format parameter
2 parents b529e07 + cb77902 commit c5772ae
Copy full SHA for c5772ae

File tree

2 files changed

+9
-4
lines changed
Filter options

2 files changed

+9
-4
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php
+5-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php
+4-3Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.