php-dextrin

Compiled
in package

FinalYes

The result of compiling one `%schema(N){}` entry from a `.dxns` document ({@see Compiler}) -- enough to both validate a decoded value and convert it both directions between `.dxnb`'s always-positional wire shape and a named field map.

fields is ordered -- that order is the canonical position <-> name mapping .dxnb's positional struct encoding needs, and it is the order the fields are written in the %schema(N){...} body.

version is which version of name this is (DXNS.md §8), 1 for a schema written without a header.

annotations are what a {:doc %schema{...} %{...}} around the entry says about it (DXNS.md §1b), by name; [] without one.

Table of Contents

Properties

$annotations  : array<string|int, mixed>
$fields  : array<string|int, mixed>
$name  : string|null
$version  : int

Methods

__construct()  : mixed
fieldNames()  : array<int, string>
structOf()  : DXNStruct
`$instance` -- a registered application class instance -- as the keyed struct named `$name` it is written as (DXNS.md §3, §4.7), its fields in this schema's order. A field it does not have -- a property the class does not declare, or a typed one left uninitialised -- is absent, never null: a reader refuses null unless the type admits it, and a property holding null is a field holding nil. Any other public property is an extra field, written back with the struct, as an Elixir struct's undeclared keys are.
withAnnotations()  : self
A copy annotated with `$annotations`.
withName()  : self
A schema's `name` is only known once {@see Compiler} finishes compiling its enclosing document -- returns a copy with it set.

Properties

$annotations read-only

public array<string|int, mixed> $annotations = []

$fields read-only

public array<string|int, mixed> $fields = []

$name read-only

public string|null $name = null

$version read-only

public int $version = 1

Methods

__construct()

public __construct([string|null $name = null ][, array<int, Field> $fields = [] ][, int $version = 1 ][, array<string, mixed> $annotations = [] ]) : mixed
Parameters
$name : string|null = null
$fields : array<int, Field> = []
$version : int = 1
$annotations : array<string, mixed> = []

fieldNames()

public fieldNames() : array<int, string>
Return values
array<int, string>

structOf()

`$instance` -- a registered application class instance -- as the keyed struct named `$name` it is written as (DXNS.md §3, §4.7), its fields in this schema's order. A field it does not have -- a property the class does not declare, or a typed one left uninitialised -- is absent, never null: a reader refuses null unless the type admits it, and a property holding null is a field holding nil. Any other public property is an extra field, written back with the struct, as an Elixir struct's undeclared keys are.

public structOf(string $name, object $instance) : DXNStruct
Parameters
$name : string
$instance : object
Return values
DXNStruct

withAnnotations()

A copy annotated with `$annotations`.

public withAnnotations(array<string, mixed> $annotations) : self
Parameters
$annotations : array<string, mixed>
Return values
self

withName()

A schema's `name` is only known once {@see Compiler} finishes compiling its enclosing document -- returns a copy with it set.

public withName(string $name) : self
Parameters
$name : string
Return values
self
On this page

Search results