Skip to content

Changelog 0.13.0 — 31st of July 2022

Notable changes

Reworking of messages body and parameters features

The \CuyZ\Valinor\Mapper\Tree\Message\Message interface is no longer a Stringable, however it defines a new method body that must return the body of the message, which can contain placeholders that will be replaced by parameters.

These parameters can now be defined by implementing the interface \CuyZ\Valinor\Mapper\Tree\Message\HasParameters.

This leads to the deprecation of the no longer needed interface \CuyZ\Valinor\Mapper\Tree\Message\TranslatableMessage which had a confusing name.

final class SomeException
    extends DomainException 
    implements ErrorMessage, HasParameters, HasCode
    private string $someParameter;

    public function __construct(string $someParameter)

        $this->someParameter = $someParameter;

    public function body() : string
        return 'Some message / {some_parameter} / {source_value}';

    public function parameters(): array
        return [
            'some_parameter' => $this->someParameter,

    public function code() : string
        // A unique code that can help to identify the error
        return 'some_unique_code';

Handle numeric-string type

The new numeric-string type can be used in docblocks.

It will accept any string value that is also numeric.

(new MapperBuilder())->mapper()->map('numeric-string', '42'); // ✅
(new MapperBuilder())->mapper()->map('numeric-string', 'foo'); // ❌

Better mapping error message

The message of the exception will now contain more information, especially the total number of errors and the source that was given to the mapper. This change aims to have a better understanding of what is wrong when debugging.


Could not map type `array{foo: string, bar: int}` with the given source.


Could not map type `array{foo: string, bar: int}`. An error occurred at path bar: Value 'some other string' does not match type `int`.


  • Rework messages body and parameters features (ad1207)


  • Allow to declare parameter for message (f61eb5)
  • Display more information in mapping error message (9c1e7c)
  • Handle numeric string type (96a493)
  • Make MessagesFlattener countable (2c1c7c)

Bug Fixes

  • Handle native attribute on promoted parameter (897ca9)


  • Add fixed value for root node path (0b37b4)
  • Remove types stringable behavior (b47a1b)