8000 Mapping array properties with symfony/property-info >= 5.1.6 · Issue #425 · janephp/janephp · GitHub
[go: up one dir, main page]

Skip to content
Mapping array properties with symfony/property-info >= 5.1.6 #425
@odolbeau

Description

@odolbeau

Jane version(s) affected: ?

Description
With symfony/property-info >= 5.1.6 I get a problem mapping arrays without PHPDoc.
The problem have been introduced by this PR on symfony/property-info (this is the only commit merged between 5.1.5 & 5.1.6).

How to reproduce
I try to map a class A to a class B.

Class A contains:

    /**
     * @ORM\Column(type="bigint[]")
     */
    private array $property = [];

    public function getProperty(): array
    {
        return $this->property;
    }

Class B contains:

    public array $property = [];

I try to map them like this:

$a = new Class A();
$a->setProperty([1, 2, 3, 4]);

$b = $mapper->map($a, B::class);
var_dump($b->property); // [] <== empty array instead of [1, 2, 3, 4]

Possible Solution
This is not a solution but adding the annotation @var string[] on both properties solves the problem.
Edit: Adding this annotation only on the output class works as well.

Additional context
TBH I don't even know if this problem is linked to the automapper or to the property info component. :/

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0