Skip to content

1.10.0

Compare
Choose a tag to compare
@romm romm released this 12 Mar 07:02
· 61 commits to master since this release

Notable changes

Dropping support for PHP 8.0

PHP 8.0 security support has ended on the 26th of November 2023. Therefore, we are dropping support for PHP 8.0 in this version.

If any security issue was to be found, we might consider backporting the fix to the 1.9.x version if people need it, but we strongly recommend upgrading your application to a supported PHP version.

Introducing Constructor attribute

A long awaited feature has landed in the library!

The Constructor attribute can be assigned to any method inside an object, to automatically mark the method as a constructor for the class. This is a more convenient way of registering constructors than using the MapperBuilder::registerConstructor method, although it does not replace it.

The method targeted by a Constructor attribute must be public, static and return an instance of the class it is part of.

final readonly class Email
{
    // When another constructor is registered for the class, the native
    // constructor is disabled. To enable it again, it is mandatory to
    // explicitly register it again.
    #[\CuyZ\Valinor\Mapper\Object\Constructor]
    public function __construct(public string $value) {}

    #[\CuyZ\Valinor\Mapper\Object\Constructor]
    public static function createFrom(
        string $userName, string $domainName
    ): self {
        return new self($userName . '@' . $domainName);
    }
}

(new \CuyZ\Valinor\MapperBuilder())
    ->mapper()
    ->map(Email::class, [
        'userName' => 'john.doe',
        'domainName' => 'example.com',
    ]); // john.doe@example.com

Features

  • Introduce Constructor attribute (d86295)

Bug Fixes

  • Properly encode scalar value in JSON normalization (2107ea)
  • Properly handle list type when input contains superfluous keys (1b8efa)

Other

  • Drop support for PHP 8.0 (dafcc8)
  • Improve internal definitions string types (105281)
  • Refactor file system cache to improve performance (e692f0)
  • Remove unneeded closure conversion (972e65)
  • Update dependencies (c5627f)