PHP TypeLang Help

Date/Time (Clock)

After metadata building, each DTO stores a datetime snapshot with the DTO build time to prevent reading stale data (this can be used, for example, in cache implementations).

To ensure testing, the time generator can be passed explicitly using any PSR-20 library.

Here are the most popular implementations:

To create a time provider, you can install any implementation, for example:

composer require symfony/clock

Or write your own:

final MySimpleClock implements [[[Psr\Clock\ClockInterface|https://www.php-fig.org/psr/psr-20/]]] { public function now(): \DateTimeImmutable { return new \DateTimeImmutable(); } }

Next, in case for the datetime to be "applied" to the metadata, the implementation must be passed to the MetadataBuilder metadata provider.

use TypeLang\Mapper\Mapping\Provider\MetadataBuilder; $provider = [[[new MetadataBuilder(|meta-provider.html]]] clock: new MySimpleClock(), );
06 November 2025