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 645668f

Browse filesBrowse files
chadyredFlorian CELLIER
authored and
Florian CELLIER
committed
[Serializer] [Normalizer] Add to context current class / attribute name for a denormalized object
Useful for solving everything related to the current class and the attribute such as the information in the DocBlock, and in particular, on the generic types powered by PhpStan for an attribute which required more advanced information on its typing (and according to the data received). For instance : A ClassFoo is triggered for denormalization --> The type of the attribute to denormalize is `mixed` BUT with a `DocBlock` node like `@var GenericTypeA<GenericTypeB<Union|Type|null>>`. Thus, to resolve the type used at the end of the chain, having the current attribute and the current class helps a lot, especially with another extractor or a piece of homemade code, it is really useful to retrieve information about the class by reflexivity for example through the combination `currentClassName:currentAttributeName`
1 parent f9d5e24 commit 645668f
Copy full SHA for 645668f

File tree

1 file changed

+1
-1
lines changed
Filter options

1 file changed

+1
-1
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ private function validateAndDenormalize(array $types, string $currentClass, stri
527527

528528
$childContext = $this->createChildContext($context, $attribute, $format);
529529
if ($this->serializer->supportsDenormalization($data, $class, $format, $childContext)) {
530-
return $this->serializer->denormalize($data, $class, $format, $childContext);
530+
return $this->serializer->denormalize($data, $class, $format, array_merge($childContext, ['current_attribute' => $attribute, 'current_class' => $currentClass]));
531531
}
532532
}
533533

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.