PHP TypeLang Help

Type Metadata

Type metadata is a DTO containing information about composite types, such as objects, enums, etc., that can be used to supplement existing PHP code.

The metadata can be used directly in type builders that require a description of the rules for normalization or denormalization such types (for example, objects of a certain class).

Thus, information about type metadata should be pass into the platform when necessary, for example:

use TypeLang\Mapper\Mapper; use TypeLang\Mapper\Platform\StandardPlatform; $mapper = new Mapper( [[[platform: new StandardPlatform(|standard-platform.html]]] meta: $readerOrProvider, // ... ), );

To obtain the metadata, two different categories of reading process were implemented:

  • Metadata Reader - Responsible for the process of reading and supplementing metadata from various sources.

  • Metadata Provider - Responsible for the process of "freezing" (building) values onto immutable metadata DTOs and providing the user with the result of the work.

In general, the scheme for obtaining metadata looks like this:

requests metadata for type T

returns immutable metadata DTOs

"freeze" metadata and build result

returns immutable metadata DTOs

reads metadata, uses readers

returns the read mutable data

Platform

ProviderInterface

MetadataBuilder

ReaderInterface

In code, such a composition might look like this:

use TypeLang\Mapper\Mapper; use TypeLang\Mapper\Mapping\Provider\InMemoryProvider; use TypeLang\Mapper\Mapping\Provider\MetadataBuilder; use TypeLang\Mapper\Mapping\Reader\NullReader; use TypeLang\Mapper\Mapping\Reader\ReflectionReader; use TypeLang\Mapper\Platform\StandardPlatform; // An example of a composition from metadata readers $reader = [[[new ReflectionReader(|meta-reader-reflection.html]]] delegate: [[[new NullReader()|meta-reader-null.html]]], ); // Passing readers to the metadata builder $provider = [[[new MetadataBuilder(|meta-provider.html]]] reader: $reader, ); // An example of provider supplement $provider = [[[new InMemoryProvider(|meta-provider-in-memory.html]]] delegate: $provider, ); // Create mapper with a platform that supports metadata $mapper = new Mapper([[[new StandardPlatform(|standard-platform.html]]] meta: $provider, ));
06 November 2025