PHP TypeLang Help

Attribute Reader

This reader is used to read PHP attributes to construct metadata.

To create it, it is enough to instantiate AttributeReader class:

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

After this, you will have access to the description of the types in the PHP Attributes:

use TypeLang\Mapper\Mapping\MapType; final class UserInfo { public function __construct( #[MapType('non-empty-string')] public mixed $name, ) {} }

By default, it supports the following attributes:

If you need to supplement metadata from another reader, you should specify this explicitly using $delegate argument:

use TypeLang\Mapper\Mapping\Reader\AttributeReader; $reader = new AttributeReader( delegate: new AnotherExampleReader(), );
06 November 2025