-
-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Thanks a lot, this library is so much fun! When playing with it, i found this though:
This one breaks, in the sense that it does NOT add a type key and deserializes to wrong variant:
final class FooBarWrapper {
public function __construct(
#[StaticTypeMap(key: 'type', map: [
'foo' => Foo::class,
'bar' => Bar::class,
])]
public readonly Foo|Bar $variant,
) {}
}
I had to work around it like this:
final class FooBarWrapper {
public function __construct(
#[StaticTypeMap(key: 'type', map: [
'foo' => Foo::class,
'bar' => Bar::class,
])]
// Serde demands interface typehint, union breaks.
public readonly CommonFooBarInterface $variant,
) {}
}
Not a big issue for me, but principle of least surprise violated.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working