Skip to content

Changelog 0.7.0 — 24th of March 2022

Notable changes

Warning This release introduces a major breaking change that must be considered before updating

Constructor registration

The automatic named constructor discovery has been disabled. It is now mandatory to explicitly register custom constructors that can be used by the mapper.

This decision was made because of a security issue reported by @Ocramius and described in advisory advisory GHSA-xhr8-mpwq-2rr2.

As a result, 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 in favor of the method above that should be used instead.

final class SomeClass
    public static function namedConstructor(string $foo): self
        // …

(new \CuyZ\Valinor\MapperBuilder())
        // …or for PHP < 8.1:
        [SomeClass::class, 'namedConstructor'],
    ->map(SomeClass::class, [
        // …

See documentation for more information.

Source builder

The Source class is a new entry point for sources that are not plain array or iterable. It allows accessing other features like camel-case keys or custom paths mapping in a convenient way.

It should be used as follows:

$source = \CuyZ\Valinor\Mapper\Source\Source::json($jsonString)
        'towns' => 'cities',
        'towns.*.label' => 'name',

$result = (new \CuyZ\Valinor\MapperBuilder())
    ->map(SomeClass::class, $source);

See documentation for more details about its usage.


  • Change Attributes::ofType return type to array (1a599b)
  • Introduce method to register constructors used during mapping (ecafba)


  • Introduce a path-mapping source modifier (b7a7d2)
  • Introduce a source builder (ad5103)

Bug Fixes

  • Handle numeric key with camel case source key modifier (b8a18f)
  • Handle parameter default object value compilation (fdef93)
  • Handle variadic arguments in callable constructors (b646cc)
  • Properly handle alias types for function reflection (e5b515)


  • Add Striker HTML report when running infection (79c7a4)
  • Handle class name in function definition (e2451d)
  • Introduce functions container to wrap definition handling (fd1117)