PHP TypeLang Help

Array Reader

The PHP Array reader allows you to specify metadata declaratively using simple PHP arrays. As an example, let's specify simple information for the class below:

final class UserInfo { public function __construct( public string $name, ) {} }

To create an array reader with the specified configuration rules, you should create a new ArrayReader instance, passing the settings in the $config property.

use TypeLang\Mapper\Mapper; use TypeLang\Mapper\Platform\StandardPlatform; use TypeLang\Mapper\Mapping\Reader\ArrayReader; $reader = new ArrayReader(config: [ // Example settings for class "UserInfo" UserInfo::class => [ 'normalize_as_array' => true, 'properties' => [ 'name' => 'non-empty-string', ], ], ]); $mapper = new Mapper( [[[platform: new StandardPlatform(|standard-platform.html]]] meta: $reader, // ... ), );

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

use TypeLang\Mapper\Mapping\Reader\ArrayReader; $reader = new ArrayReader( config: [ ... ], delegate: new AnotherExampleReader(), );
06 November 2025