mirror of
https://github.com/danog/Valinor.git
synced 2024-11-27 04:34:48 +01:00
ecafba3b21
It is now mandatory to explicitly register custom constructors — including named constructors — that can be used by the mapper. The former automatic registration of named constructor feature doesn't work anymore. BREAKING CHANGE: existing code must list all named constructors that were previously automatically used by the mapper, and registerer them using the method `MapperBuilder::registerConstructor()`. The method `MapperBuilder::bind()` has been deprecated, the method above should be used instead. ```php final class SomeClass { public static function namedConstructor(string $foo): self { // … } } (new \CuyZ\Valinor\MapperBuilder()) ->registerConstructor( SomeClass::namedConstructor(...), // …or for PHP < 8.1: [SomeClass::class, 'namedConstructor'], ) ->mapper() ->map(SomeClass::class, [ // … ]); ``` |
||
---|---|---|
.. | ||
Object | ||
Source | ||
Tree | ||
MappingErrorTest.php | ||
TreeMapperContainerTest.php |