yiisoft / hydrator

Create and populate objects with type casting, mapping and dependencies resolving support.
BSD 3-Clause "New" or "Revised" License
24 stars 3 forks source link

Add dehydration #10

Open rustamwin opened 1 year ago

vjik commented 1 year ago

Can you describe you vision of concept?

xepozz commented 1 year ago

Do you mean serialization?

rustamwin commented 1 year ago

I mean hydration and vice versa (aka toArray()).

xepozz commented 1 year ago

https://github.com/yiisoft/var-dumper/blob/master/src/VarDumper.php#L175 :)

vjik commented 1 year ago

I mean hydration and vice versa (aka toArray()).

Seems, it's not hydrator package responsibility. Hydration is a one-way process, it's not serilization/deserilization.

rustamwin commented 1 year ago

It's not deserialization exactly. We have Map attribute.

// request data is ['a' => 'foo', 'b' => 'bar']
#[Map(['x' => 'a', 'y' => 'b'])
class MyDto
{
    public string $x;
    public string $y;
}

Result of dehyration should be ['a' => 'foo', 'b' => 'bar'] not ['x' => 'foo', 'y' => 'bar'].

xepozz commented 1 year ago

$request->getParsedBody()?

rustamwin commented 1 year ago

$request->getParsedBody()?

Any input.