Closed
Description
Symfony version(s) affected: 5.3.0
Description
When I try to denormalize to a class with properties that are typed with phpDoc, the properties of the resulting object are not denormalized.
How to reproduce
class Foo {
/**
* @var \DateTimeInterface
*/
public $date;
}
$data = [
'date' => '2021-01-01 00:00:00',
];
$result = $serializer->denormalize($data, Foo::class);
// $result->date === '2021-01-01 00:00:00' instead of instance of \DateTimeImmutable
Possible Solution
The bug is created by this PR #40140.
ContainerBuilder::willBeAvailable
returns false
when we have $parentPackages
that is installed in dev requirements AND in no-dev requirements.
If I have symfony/framework-bundle
explicitly in my dev requirements and doctrine/mongodb-odm-bundle
which requires symfony/framework-bundle
in my no-dev requirements, the Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor
service won't be loaded and serialization with phpDoc typehint will fail.