Skip to content

Deserialize array of scalars to its doctype #53490

@koekaverna

Description

@koekaverna

Description

When I deserialize {"values":["1","2","3"]} to the class:

final class Test
{
    /** @var array<int> */
    private array $values;

    /** @var array<int> */
    public function __construct(array $values)
    {
        $this->values = $values;
    }

    /** @return array<int> */
    public function getValues(): array
    {
        return $this->values;
    }
}

It's ignore dockblock and serialize values as array of strings.

Is it possible to workaround this and convert type to array<int>?

Example

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureHelp wantedIssues and PRs which are looking for volunteers to complete them.Serializer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions