schmittjoh / serializer

Library for (de-)serializing data of any complexity (supports JSON, and XML)
http://jmsyst.com/libs/serializer
MIT License
2.32k stars 589 forks source link

feat(stringable-type): Allow stringable object as type. #1492

Closed pmysiak closed 1 year ago

pmysiak commented 1 year ago
Q A
Bug fix? no
New feature? yes
Doc updated no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #...
License MIT

Allow pass type as stringable object (object implementing __toString() method).

Before

#[Serializer\Type('array<MyHandler<My\Class>>')]
private $array;

After

#[Serializer\Type(new ArrayOfMyHandler(MyClass::class))]
private $array;

Better readability. IDE can autocomplete. If this pull request make sens I will update doc.

scyzoryck commented 1 year ago

Thanks @pmysiak for contribution! I believe it will be great User experience improvement. I really like it :)

Best, scyzoryck.

scyzoryck commented 1 year ago

Thanks! I think it would be nice to cover existing types like arrays etc, with such types for autocompletion in the future :)

Best!

pmysiak commented 1 year ago

@scyzoryck Hi, I updated docs in this pull request but still don't see it live https://jmsyst.com/libs/serializer/master/reference/annotations#type Do I forget something to do?

scyzoryck commented 1 year ago

Hi. Unfortunately the docs building script is broken for some time. I guess also @goetas had too limited access to fix it :(