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

[FrameworkBundle] Denormalization doesn't read phpDoc to guess type #41642

Copy link
Copy link
Closed
@wuchen90

Description

@wuchen90
Issue body actions

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.

if (ContainerBuilder::willBeAvailable('phpdocumentor/reflection-docblock', DocBlockFactoryInterface::class, ['symfony/framework-bundle', 'symfony/property-info'])) {

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

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