Open Bilge opened 2 months ago
Hi.
Can you provide full working example of the code that you are trying to execute and achieve?
In general you are trying to Inline the property that has string type - when Inline
was designed to work with nested objects.
If you think that we are missing some feature feel free to provide some Pull Request with changes. I will be glad to help to add this code to the next release.
Best Marcin.
The purpose of what I was trying to achieve is just to have an object be represented as some value, without having to specify in everything that consumes it how to represent it. With VirtualProperty
and a bunch of Exclude
s as necessary, we can represent the object as a single key/value pair, but I just want a value with no key (i.e. the formatted date of the DateTimeImmutable
object).
I would suggest to use custom handler for such classes - see DateHandler
as an example. I believe it will be an easier solution to maintain in a long term but also better from performance point of view.
Best Marcin
Perhaps DateHandler
should automatically apply to objects extending DateTime
/DateTimeImmutable
, instead of only matching the class names verbatim.
Handlers are meant to subscribe to specific class only - they do not apply to the child classes. Event listeners can apply to child classes and interfaces.
How is one supposed to inline a virtual property? The following does not work:
(Aside, it shouldn't be necessary to specify a name for an inlined property, nor should it be necessary to specify an empty array after the inline class).
Expected Result
{Foo: "2026-12-31T12:30:00+00:00"}
Actual Result
{Foo: {}}