Skip to content

[LiveComponent] Error on Vector props hydratation #2041

Open
@Nek-

Description

@Nek-

I'm using php-ds. But it seems to be highly unsupported by symfony ux. It's really complicated to have something working with. But here is something that looks more like an error to me than something unsupported. Issues with Doctrine collections may be connected.

Here is an example of a component:

class Options
{
    // a vector because they are ordered, it avoids storing the order elsewhere or weird array manipulation
Opt
    /** @var Vector<Option> */
    #[LiveProp(useSerializerForHydration: true, serializationContext: ['groups' => self::SERIALIZATION_GROUP])]
    public Vector $selectedOptions;
}

Looks ok isn't it? Yep, but it does not work. Because the LiveComponentHydrator transforms the type Vector to Option[], you guess the rest: it results in an array, an array is not a Vector, so it fails.

Here is the location of the error:

if (Type::BUILTIN_TYPE_OBJECT === $builtInType) {
$type = $propMetadata->collectionValueType()->getClassName().'[]';
} else {
$type = $builtInType.'[]';
}

Not sure how you want to fix this, it looks not easy.

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