CuyZ / Valinor

PHP library that helps to map any input into a strongly-typed value object structure.
https://valinor.cuyz.io
MIT License
1.32k stars 74 forks source link

Support writeable object shape #569

Open momala454 opened 3 weeks ago

momala454 commented 3 weeks ago

Apparently, to be able to make properties writeable, you must combine the object shape with stdclass (ref : https://github.com/phpstan/phpstan/discussions/10079) However, it is not supported

Could not parse the type `\stdClass&object{info: string}` that should be mapped: Invalid intersection member `object`, it must be a class name or an interface name
(new \CuyZ\Valinor\MapperBuilder())
    ->allowSuperfluousKeys()
    ->allowPermissiveTypes()
    ->mapper()
    ->map(
        '\stdClass&object{info: string}',
        \CuyZ\Valinor\Mapper\Source\Source::json($string),
    );
momala454 commented 3 weeks ago

sorry I forgot you don't support object (https://github.com/CuyZ/Valinor/discussions/564#discussioncomment-10677070) Is there any possibility to support objects ?