php-dextrin

Compiled
in package

FinalYes

The result of compiling one `%schema{}` 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, which is exactly why a schema's own fields: has to be an @ordered %{...} in the source document, not a plain map (.dxn's map type makes no ordering guarantee, but field order here is semantically load-bearing, not incidental).

Tags
phpstan-type

RefineFn \Closure(array<string, mixed>): (bool|string)

Table of Contents

Properties

$closed  : bool
$fields  : array<string|int, mixed>
$forbidden  : array<string|int, mixed>
$name  : string|null
$refineFn  : Closure|null

Methods

__construct()  : mixed
fieldNames()  : array<int, string>
fieldValues()  : array<int, array{0: string, 1: mixed}>
Reads `$instance`'s fields (an arbitrary registered PHP class instance, not a {@see \JOetjen\Dextrin\Value\DXNStruct}) out in this schema's own canonical field order -- the same order `.dxnb`'s positional wire encoding needs. A field this schema declares but `$instance` doesn't have is `null`, same as any other absent field; extra instance properties the schema doesn't know about are simply not included.
withName()  : self
A schema's `name` is only known once {@see Compiler} finishes compiling its enclosing document -- returns a copy with it set.

Properties

$closed read-only

public bool $closed = false

$fields read-only

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

$forbidden read-only

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

$name read-only

public string|null $name = null

$refineFn read-only

public Closure|null $refineFn = null

Methods

__construct()

public __construct([string|null $name = null ][, array<int, Field$fields = [] ][, bool $closed = false ][, array<int, string> $forbidden = [] ][, RefineFn|null $refineFn = null ]) : mixed
Parameters
$name : string|null = null
$fields : array<int, Field> = []
$closed : bool = false
$forbidden : array<int, string> = []
$refineFn : RefineFn|null = null

resolved is this schema's own already-type-checked field values; return true to accept the value, or a string describing why not.

fieldNames()

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

fieldValues()

Reads `$instance`'s fields (an arbitrary registered PHP class instance, not a {@see \JOetjen\Dextrin\Value\DXNStruct}) out in this schema's own canonical field order -- the same order `.dxnb`'s positional wire encoding needs. A field this schema declares but `$instance` doesn't have is `null`, same as any other absent field; extra instance properties the schema doesn't know about are simply not included.

public fieldValues(object $instance) : array<int, array{0: string, 1: mixed}>
Parameters
$instance : object
Return values
array<int, array{0: string, 1: mixed}>

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