Skip to content

Error when deserializing ArrayObject with annotation #57914

Closed
@asispts

Description

@asispts

Symfony version(s) affected

7.1

Description

I got an error when deserializing an ArrayObject with annotation

Undefined variable $class at symfony/serializer/Normalizer/AbstractObjectNormalizer.php:753

How to reproduce

final readonly class Dto
{
    /**
     * @param ArrayObject<string,mixed> $prop
     */
    public function __construct(
        public ArrayObject $prop
    ) {
    }
}

$data = '{"prop": {"key": "value"}}';
$serializer->deserialize($data, Dto::class, 'json');

Possible Solution

Removing the annotation will fix the issue. But, static analyzers will complain about that

Additional Context

No response

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