php-dextrin

TypeExpr
in package

FinalYes

Internal, compiled representation of a `.dxns` type expression -- the vocabulary of DXNS.md §1 (`any`, `never`, `primitive`, `reference`, `list-of`, `list-items`, `set-of`, `tuple-of`, `tuple-of-all`, `map-of`, `array-of`, `tagged`, `doc`, `if`, `ordered-map-of`, `sorted-set-of`, `enum`, `one-of`, `any-of`, `all-of`, `not`, `nilable`, `refine`) {@see Compiler} turns a parsed `.dxns` value into, and what {@see self::matches()} checks a decoded/to-be-encoded value against. (The 13th `dxn/DXN.md` §4 form, `struct`, isn't a distinct compiled shape here either -- a `%schema{}` entry compiles straight to {@see Compiled}, never to a `TypeExpr` a *field* could hold; `reference` is what a field uses to point at one.)

This vocabulary is fixed, not extensible from outside an actual library change -- what schema authors extend instead is composing these forms into a reusable named type, which needs no new form at all.

One field-per-form, all nullable except form itself, rather than a class hierarchy -- mirrors the JS port's own plain tagged-object representation ({form: 'list-of', elem: ...}) closely enough that porting Compiler stays a mechanical translation.

Table of Contents

Constants

PRIMITIVES  : mixed = ['nil', 'boolean', 'integer', 'float', 'decimal...
RESOLUTIONS  : mixed = ['second' => 1000000000, 'millisecond' => 10000...
A resolution's unit, in nanoseconds.

Properties

$base  : self|null
$branches  : array<string|int, mixed>|null
$constraints  : array<string|int, mixed>|null
$elem  : self|null
$elems  : array<string|int, mixed>|null
$fields  : array<string|int, mixed>|null
$form  : string
$key  : self|null
$literals  : array<string|int, mixed>|null
$name  : string|null
$notes  : array<string|int, mixed>|null
$otherwise  : self|null
$params  : array<string|int, mixed>|null
$particles  : array<string|int, mixed>|null
$value  : self|null
$variants  : array<string|int, mixed>|null

Methods

allOf()  : self
any()  : self
anyOf()  : self
apply()  : self
arrayOf()  : self
case()  : self
`{:case field %{value => type, :else => type}}`: the type the sibling `field`'s value chooses.
conform()  : mixed
`$value` checked against this type in `$ctx`: the value with every shape's missing defaults filled in (design/shapes-and-case.md, Jan, 2026-10-20), or {@see NoMatch}. Nothing but a shape changes a value.
doc()  : self
`{:doc type %{...}}`: `$elem`, annotated (DXNS.md §1b). The annotations change nothing it takes.
enum()  : self
generic()  : self
if()  : self
`{:if test then else}`, JSON Schema's if/then/else: a value that is a `$test` is checked as a `$then`, any other as an `$otherwise`.
isPrimitiveName()  : bool
listItems()  : self
`{:list-items p ...}`: a list's items in order (DXNS.md §1a).
listOf()  : self
mapOf()  : self
matches()  : bool
Whether `$value` matches this type -- shared by both decode (`Validator::materialize()`) and encode-time validation (`Validator::validateForEncode()`): the same recursive check, the same method, for both directions. It is {@see self::conform()} answered as a boolean, so there is one check, not two.
named()  : self
A recursive named type's reference to itself, looked up when it is checked.
never()  : self
nilable()  : self
not()  : self
oneOf()  : self
orderedMapOf()  : self
param()  : self
primitive()  : self
reference()  : self
refine()  : self
setOf()  : self
shape()  : self
`%shape{...}` (design/shapes-and-case.md): a plain map with these fields, its missing defaults filled.
sortedSetOf()  : self
substitute()  : self
This type with each parameter `$bound` names replaced by its argument.
tagged()  : self
`{:tagged name type}`: a custom tag named `$name` whose value is an `$elem` (DXNS.md §1).
tupleOf()  : self
tupleOfAll()  : self
`{:tuple-of-all elem}`: a tuple of any length, every item an `$elem`.
with()  : self
This type with each part replaced, for the compiler's resolution.
withTypes()  : array<string, mixed>
A refine's `$constraints` with each type they hold -- `contains`, `content`, `encodes`, `encodes-seq` -- replaced by what `$map` makes of it.
__construct()  : mixed
all()  : array<int, mixed>|NoMatch
Every item conformed, in order, or {@see NoMatch} at the first that is not.
allConform()  : bool
allTaken()  : array<int, mixed>|NoMatch
The end of a `{:list-items}`: every item taken.
base32()  : string
Unpadded upper-case base32, its alphabet checked by the caller, as bytes; leftover bits dropped.
bitBytes()  : string|null
The bytes `bits` reads: a byte string's own, a non-negative integer's lowest first; `null` for anything else.
chosen()  : self|null
The type the branches give the sibling field's value; the `:else` (`null` without one) when none is equal, or the sibling is absent.
compare()  : int|null
-1, 0 or 1, or `null` for two values that do not compare: NaN with anything, or two values of different kinds.
compareCount()  : int|null
`$count` against a bound, -1, 0 or 1; `null` for a bound that is no number, which the caller's comparisons with -1, 0 and 1 refuse.
conformMap()  : mixed
A DXN map/ordered-map key can be any DXN value, but a bare PHP array's own key is always `int|string` (this port's own map-key coercion, see `MapBuilder`'s doc) -- `map-of`'s own `key:` type is therefore checked against that coerced PHP key directly, never the original pre-coercion DXN key.
conformPairs()  : mixed
conformShape()  : mixed
A map against a shape's fields: each declared field matched by name, whatever spelling its key has (`name:`, `"name" =>`, `:"name" =>`) and refused given twice; a missing field takes its default, under a keyword key; an extra key is kept, and refused by a strict decode -- as a struct's fields are (design/shapes-and-case.md).
conformTagged()  : mixed
A custom tag of this name, its value conformed to the type; or an application's value that the registry's tag encoder for its class writes as one, whose written value is a match (it is answered itself). An encoder that throws writes nothing that matches.
conformTuple()  : mixed
contains()  : bool
Whether between `min-contains` (1 when not given) and `max-contains` of the collection's items are a `$type`.
countOf()  : int|null
A collection's item count, `null` for a value that is none.
decoded()  : string|null
`$text` decoded by RFC 4648's `$encoding`, `null` when it is not valid in it: base64 and base32 with their padding, base64url with or without it, base32 in upper case, base16 in either. The alphabet and the padding are checked here, as PHP's decoders take more than the reference's; the bits past the last byte are not, as the reference does not check them.
distinct()  : bool
Whether no two of `$items` give the same identity; `$identify` answers `[identity]`, or `[]` for an item left out.
durationOrdinal()  : array{0: string, 1: string}|null
A duration's total nanoseconds, a decimal string so no field's size overflows it; `null` with years or months.
encodes()  : bool
The bytes are a `.dxnb` document whose value is a `$type`.
encodesSeq()  : bool
The bytes are `.dxnb` documents back to back, each a `$type`; none at all too.
enumMatches()  : bool
exponent()  : int|null
A decimal's exponent; `null` for anything else.
fieldIdentity()  : array<int, string>
fieldOf()  : array<int, mixed>
The value of the field named `$field`, whatever its key's spelling: `[value]`, or `[]` when there is none.
fromNow()  : bool
A datetime's distance from now, in nanoseconds, given to `$test`; `$wanted` false asks nothing, and anything but a boolean refuses.
hasContent()  : bool
The string, decoded by its `encoding` when it has one, is a DXN document whose value is a `$type`: `.dxnb` under application/dxnb, text otherwise.
hasOffsetIn()  : bool
Whether the datetime's offset, `Z` or `±HH:MM`, is one of `$offsets`.
hasResolution()  : bool
Whether no part of a time, datetime, local date-time or duration is finer than `$unit`.
identity()  : string
Two values are the same when their canonical forms are (DXN.md §1.5): `1` and `1.0` differ, as `name:` and `"name" =>` do. A value with no DXN meaning, an application's object, is compared as itself.
isMultipleOf()  : bool
Whether the number `$value` is an exact multiple of `$n`: two integers by their remainder, anything else by the floats' (which a zero, NaN or an infinity never is).
isNumber()  : bool
Whether `$value` is a number, NaN and the infinities included.
items()  : array<int, mixed>|NoMatch
`$particles` from the `$p`th matched against `$items` from the `$at`th, then `$rest` against the position they leave: the items conformed, in order, or {@see NoMatch}. A repeat takes as many items as it can while the rest still matches, and gives back one at a time until it does (DXNS.md §1a).
itemsOf()  : array<int, mixed>|null
A collection's items, `null` for a value that is none.
keyName()  : string|null
The name a map key gives a field, or `null`.
lengthOf()  : int|null
A string's, keyword's or symbol's length in codepoints; a byte string's in bytes, in bits under `:bits`; `null` for anything else.
mask()  : int
The bits of `$allowed` that fall in the byte starting at bit `$from`, shifted down to it.
matchesPattern()  : bool
Whether `$value` matches the regex `$re`: a name's text, or a byte string one character per byte -- its bytes as they are, or, for a pattern with the `u` flag, as the Latin-1 characters they are.
matchesReference()  : bool
nanosOf()  : int|null
A time's, datetime's, local date-time's or duration's nanoseconds, the part a resolution looks at; `null` for anything else.
nativeOrdinal()  : array{0: string, 1: int}|null
A native datetime's place, `null` past 64 bits of nanoseconds.
nowNanos()  : numeric-string
The time of the check, as nanoseconds since 1970, a decimal string.
numeric()  : numeric-string
An integer, or a big one's digits, as the numeric string bcmath takes.
onlyBits()  : bool
Whether only the bits numbered in `$allowed` are set (RFC 8610's `.bits`): a non-negative integer's from its lowest, a byte string's from its first byte's lowest. Both are read as bytes, the integer's lowest first.
ordinal()  : array{0: string, 1: int|float|string}|null
A value as its kind and its place in that kind's order: a number (an integer exactly, as an int or a big one's digits; anything else as a float, NaN and the infinities included), or a date, time, datetime, local date-time or duration as a count of days or nanoseconds. A duration with years or months has no place: their length varies. `null` for a value of no ordered kind.
orNull()  : string|null
precision()  : int|null
A decimal's coefficient's digit count, as written; `null` for anything else.
primitiveMatches()  : bool
read()  : array<int, mixed>|null
What `$decode` reads, or `null` when it fails: a document that does not read is content of no type, never an error of the check.
repeat()  : array<int, mixed>|NoMatch
One more repetition first, while `$most` allows it; stopping once `$least` is reached. A repetition that took no item is the last: every further one would take none either, so `$least` is met by them.
satisfiesConstraint()  : bool
One refine key against `$value` (DXNS.md §2). NaN lies outside every range, as every IEEE 754 comparison with it is false; the infinities compare as the numbers they are (Jan, 2026-10-20).
satisfiesConstraints()  : bool
Every constraint holds. A constraint on a value it does not apply to -- a length on an integer, a range on a string -- refuses it (DXNS.md §2, Jan, 2026-10-20). `$base` is the type refined, which says whether a length counts bytes or bits.
utf8Size()  : int|null
A string's, keyword's or symbol's UTF-8 byte count; `null` for anything else.
within()  : bool
Whether `$count` lies between `$least` and `$most`, either `null` for no bound; a `null` count, of a value that has none, never does, nor does a bound that is no number.
withinOfNow()  : bool
Whether a datetime is no further from now than the duration `$span`, either way.

Constants

PRIMITIVES

private mixed PRIMITIVES = ['nil', 'boolean', 'integer', 'float', 'decimal', 'rational', 'string', 'char', 'symbol', 'keyword', 'list', 'tuple', 'map', 'ordered-map', 'set', 'sorted-set', 'array', 'date', 'time', 'datetime', 'local-datetime', 'duration', 'uuid', 'objectid', 'ip', 'uri', 'bytes', 'bits', 'regex']

RESOLUTIONS

A resolution's unit, in nanoseconds.

private mixed RESOLUTIONS = ['second' => 1000000000, 'millisecond' => 1000000, 'microsecond' => 1000, 'nanosecond' => 1]

Properties

$base read-only

public self|null $base = null

$branches read-only

public array<string|int, mixed>|null $branches = null

$constraints read-only

public array<string|int, mixed>|null $constraints = null

$elem read-only

public self|null $elem = null

$elems read-only

public array<string|int, mixed>|null $elems = null

$fields read-only

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

$key read-only

public self|null $key = null

$literals read-only

public array<string|int, mixed>|null $literals = null

$name read-only

public string|null $name = null

$notes read-only

public array<string|int, mixed>|null $notes = null

$otherwise read-only

public self|null $otherwise = null

$params read-only

public array<string|int, mixed>|null $params = null

$particles read-only

public array<string|int, mixed>|null $particles = null

$value read-only

public self|null $value = null

$variants read-only

public array<string|int, mixed>|null $variants = null

Methods

allOf()

public static allOf(array<int, self> $variants) : self
Parameters
$variants : array<int, self>
Return values
self

any()

public static any() : self
Return values
self

anyOf()

public static anyOf(array<int, self> $variants) : self
Parameters
$variants : array<int, self>
Return values
self

apply()

public static apply(string $name, array<int, self> $args) : self
Parameters
$name : string
$args : array<int, self>
Return values
self

arrayOf()

public static arrayOf(self $elem) : self
Parameters
$elem : self
Return values
self

case()

`{:case field %{value => type, :else => type}}`: the type the sibling `field`'s value chooses.

public static case(string $field, array<int, array{0: mixed, 1: self}> $branches, self|null $otherwise) : self
Parameters
$field : string
$branches : array<int, array{0: mixed, 1: self}>
$otherwise : self|null
Return values
self

conform()

`$value` checked against this type in `$ctx`: the value with every shape's missing defaults filled in (design/shapes-and-case.md, Jan, 2026-10-20), or {@see NoMatch}. Nothing but a shape changes a value.

public conform(mixed $value, Context $ctx) : mixed
Parameters
$value : mixed
$ctx : Context

doc()

`{:doc type %{...}}`: `$elem`, annotated (DXNS.md §1b). The annotations change nothing it takes.

public static doc(self $elem, array<string, mixed> $notes) : self
Parameters
$elem : self
$notes : array<string, mixed>
Return values
self

enum()

public static enum(array<int, mixed> $literals) : self
Parameters
$literals : array<int, mixed>
Return values
self

generic()

public static generic(array<int, string> $params, self $body) : self
Parameters
$params : array<int, string>
$body : self
Return values
self

if()

`{:if test then else}`, JSON Schema's if/then/else: a value that is a `$test` is checked as a `$then`, any other as an `$otherwise`.

public static if(self $test, self $then, self $otherwise) : self

The test is held as base, the then as elem.

Parameters
$test : self
$then : self
$otherwise : self
Return values
self

isPrimitiveName()

public static isPrimitiveName(string $name) : bool
Parameters
$name : string
Return values
bool

listItems()

`{:list-items p ...}`: a list's items in order (DXNS.md §1a).

public static listItems(array<int, Particle> $particles) : self
Parameters
$particles : array<int, Particle>
Return values
self

listOf()

public static listOf(self $elem) : self
Parameters
$elem : self
Return values
self

mapOf()

public static mapOf(self $key, self $value) : self
Parameters
$key : self
$value : self
Return values
self

matches()

Whether `$value` matches this type -- shared by both decode (`Validator::materialize()`) and encode-time validation (`Validator::validateForEncode()`): the same recursive check, the same method, for both directions. It is {@see self::conform()} answered as a boolean, so there is one check, not two.

public matches(mixed $value[, Registry|null $registry = null ]) : bool

{form: 'reference', name} checks the originating schema's name, not the value's own shape -- which is how it correctly rejects a materialized value that satisfies its own schema but is the wrong one for this field. Two sources carry that name: an opaque, unregistered DXNStruct carries its own wire name directly; a value that went through a registered schema (decode or encode-time validation alike) carries it via Validated. The third, encode-only source: $registry (null for decode, which never needs it) lets a real, unwrapped application class instance's own class be checked against whatever class was registered for name -- needed only for a value that turned out to have no schema of its own to be wrapped by.

Parameters
$value : mixed
$registry : Registry|null = null
Return values
bool

named()

A recursive named type's reference to itself, looked up when it is checked.

public static named(string $name) : self
Parameters
$name : string
Return values
self

never()

public static never() : self
Return values
self

nilable()

public static nilable(self $elem) : self
Parameters
$elem : self
Return values
self

not()

public static not(self $elem) : self
Parameters
$elem : self
Return values
self

oneOf()

public static oneOf(array<int, self> $variants) : self
Parameters
$variants : array<int, self>
Return values
self

orderedMapOf()

public static orderedMapOf(self $key, self $value) : self
Parameters
$key : self
$value : self
Return values
self

param()

public static param(string $name) : self
Parameters
$name : string
Return values
self

primitive()

public static primitive(string $name) : self
Parameters
$name : string
Return values
self

reference()

public static reference(string $name) : self
Parameters
$name : string
Return values
self

refine()

public static refine(self $base, array<string, mixed> $constraints) : self
Parameters
$base : self
$constraints : array<string, mixed>
Return values
self

setOf()

public static setOf(self $elem) : self
Parameters
$elem : self
Return values
self

shape()

`%shape{...}` (design/shapes-and-case.md): a plain map with these fields, its missing defaults filled.

public static shape(string|null $name, array<int, Field> $fields) : self
Parameters
$name : string|null
$fields : array<int, Field>
Return values
self

sortedSetOf()

public static sortedSetOf(self $elem) : self
Parameters
$elem : self
Return values
self

substitute()

This type with each parameter `$bound` names replaced by its argument.

public substitute(array<string, self> $bound) : self
Parameters
$bound : array<string, self>
Return values
self

tagged()

`{:tagged name type}`: a custom tag named `$name` whose value is an `$elem` (DXNS.md §1).

public static tagged(string $name, self $elem) : self
Parameters
$name : string
$elem : self
Return values
self

tupleOf()

public static tupleOf(array<int, self> $elems) : self
Parameters
$elems : array<int, self>
Return values
self

tupleOfAll()

`{:tuple-of-all elem}`: a tuple of any length, every item an `$elem`.

public static tupleOfAll(self $elem) : self
Parameters
$elem : self
Return values
self

with()

This type with each part replaced, for the compiler's resolution.

public with(array<string, mixed> $parts) : self
Parameters
$parts : array<string, mixed>
Return values
self

withTypes()

A refine's `$constraints` with each type they hold -- `contains`, `content`, `encodes`, `encodes-seq` -- replaced by what `$map` makes of it.

public static withTypes(array<string, mixed> $constraints, callable(self): self $map) : array<string, mixed>
Parameters
$constraints : array<string, mixed>
$map : callable(self): self
Return values
array<string, mixed>

__construct()

private __construct(string $form[, string|null $name = null ][, self|null $elem = null ][, array<int, self>|null $elems = null ][, self|null $key = null ][, self|null $value = null ][, array<int, mixed>|null $literals = null ][, array<int, self>|null $variants = null ][, self|null $base = null ][, array<string, mixed>|null $constraints = null ][, array<int, Field>|null $fields = null ][, array<int, array{0: mixed, 1: self}>|null $branches = null ][, self|null $otherwise = null ][, array<int, string>|null $params = null ][, array<int, Particle>|null $particles = null ][, array<string, mixed>|null $notes = null ]) : mixed
Parameters
$form : string
$name : string|null = null
$elem : self|null = null
$elems : array<int, self>|null = null

tuple-of; a use's arguments (apply)

$key : self|null = null
$value : self|null = null
$literals : array<int, mixed>|null = null

enum

$variants : array<int, self>|null = null

one-of / any-of / all-of

$base : self|null = null
$constraints : array<string, mixed>|null = null

refine

$fields : array<int, Field>|null = null

shape

$branches : array<int, array{0: mixed, 1: self}>|null = null

case

$otherwise : self|null = null
$params : array<int, string>|null = null

generic

$particles : array<int, Particle>|null = null

list-items

$notes : array<string, mixed>|null = null

doc: its annotations by name

all()

Every item conformed, in order, or {@see NoMatch} at the first that is not.

private static all(self|null $elem, array<int, mixed> $items, Context $ctx) : array<int, mixed>|NoMatch
Parameters
$elem : self|null
$items : array<int, mixed>
$ctx : Context
Return values
array<int, mixed>|NoMatch

allConform()

private static allConform(self $type, array<int, mixed> $documents, Context $ctx) : bool
Parameters
$type : self
$documents : array<int, mixed>
$ctx : Context
Return values
bool

allTaken()

The end of a `{:list-items}`: every item taken.

private static allTaken(int $at, int $count) : array<int, mixed>|NoMatch
Parameters
$at : int
$count : int
Return values
array<int, mixed>|NoMatch

base32()

Unpadded upper-case base32, its alphabet checked by the caller, as bytes; leftover bits dropped.

private static base32(string $text) : string
Parameters
$text : string
Return values
string

bitBytes()

The bytes `bits` reads: a byte string's own, a non-negative integer's lowest first; `null` for anything else.

private static bitBytes(mixed $value) : string|null
Parameters
$value : mixed
Return values
string|null

chosen()

The type the branches give the sibling field's value; the `:else` (`null` without one) when none is equal, or the sibling is absent.

private chosen(array<string, mixed>|null $siblings) : self|null
Parameters
$siblings : array<string, mixed>|null
Return values
self|null

compare()

-1, 0 or 1, or `null` for two values that do not compare: NaN with anything, or two values of different kinds.

private static compare(mixed $a, mixed $b) : int|null
Parameters
$a : mixed
$b : mixed
Return values
int|null

compareCount()

`$count` against a bound, -1, 0 or 1; `null` for a bound that is no number, which the caller's comparisons with -1, 0 and 1 refuse.

private static compareCount(int $count, mixed $bound) : int|null
Parameters
$count : int
$bound : mixed
Return values
int|null

conformMap()

A DXN map/ordered-map key can be any DXN value, but a bare PHP array's own key is always `int|string` (this port's own map-key coercion, see `MapBuilder`'s doc) -- `map-of`'s own `key:` type is therefore checked against that coerced PHP key directly, never the original pre-coercion DXN key.

private conformMap(array<int|string, mixed> $value, Context $ctx) : mixed
Parameters
$value : array<int|string, mixed>
$ctx : Context

conformPairs()

private conformPairs(array<int, array{0: mixed, 1: mixed}> $pairs, Context $ctx) : mixed
Parameters
$pairs : array<int, array{0: mixed, 1: mixed}>
$ctx : Context

conformShape()

A map against a shape's fields: each declared field matched by name, whatever spelling its key has (`name:`, `"name" =>`, `:"name" =>`) and refused given twice; a missing field takes its default, under a keyword key; an extra key is kept, and refused by a strict decode -- as a struct's fields are (design/shapes-and-case.md).

private conformShape(array<int|string, mixed>|DXNMap $map, Context $ctx) : mixed
Parameters
$map : array<int|string, mixed>|DXNMap
$ctx : Context

conformTagged()

A custom tag of this name, its value conformed to the type; or an application's value that the registry's tag encoder for its class writes as one, whose written value is a match (it is answered itself). An encoder that throws writes nothing that matches.

private conformTagged(mixed $value, Context $ctx) : mixed
Parameters
$value : mixed
$ctx : Context

conformTuple()

private conformTuple(mixed $value, Context $ctx) : mixed
Parameters
$value : mixed
$ctx : Context

contains()

Whether between `min-contains` (1 when not given) and `max-contains` of the collection's items are a `$type`.

private static contains(self $type, array<string, mixed> $constraints, mixed $value, Context $ctx) : bool
Parameters
$type : self
$constraints : array<string, mixed>
$value : mixed
$ctx : Context
Return values
bool

countOf()

A collection's item count, `null` for a value that is none.

private static countOf(mixed $value) : int|null
Parameters
$value : mixed
Return values
int|null

decoded()

`$text` decoded by RFC 4648's `$encoding`, `null` when it is not valid in it: base64 and base32 with their padding, base64url with or without it, base32 in upper case, base16 in either. The alphabet and the padding are checked here, as PHP's decoders take more than the reference's; the bits past the last byte are not, as the reference does not check them.

private static decoded(string $encoding, string $text) : string|null
Parameters
$encoding : string
$text : string
Return values
string|null

distinct()

Whether no two of `$items` give the same identity; `$identify` answers `[identity]`, or `[]` for an item left out.

private static distinct(array<int, mixed>|null $items, callable(mixed): array<int, string> $identify) : bool
Parameters
$items : array<int, mixed>|null
$identify : callable(mixed): array<int, string>
Return values
bool

durationOrdinal()

A duration's total nanoseconds, a decimal string so no field's size overflows it; `null` with years or months.

private static durationOrdinal(DXNDuration $d) : array{0: string, 1: string}|null
Parameters
$d : DXNDuration
Return values
array{0: string, 1: string}|null

encodes()

The bytes are a `.dxnb` document whose value is a `$type`.

private static encodes(self $type, mixed $value, Context $ctx) : bool
Parameters
$type : self
$value : mixed
$ctx : Context
Return values
bool

encodesSeq()

The bytes are `.dxnb` documents back to back, each a `$type`; none at all too.

private static encodesSeq(self $type, mixed $value, Context $ctx) : bool
Parameters
$type : self
$value : mixed
$ctx : Context
Return values
bool

enumMatches()

private enumMatches(mixed $value) : bool
Parameters
$value : mixed
Return values
bool

exponent()

A decimal's exponent; `null` for anything else.

private static exponent(mixed $value) : int|null
Parameters
$value : mixed
Return values
int|null

fieldIdentity()

private static fieldIdentity(mixed $item, string $field) : array<int, string>
Parameters
$item : mixed
$field : string
Return values
array<int, string>

fieldOf()

The value of the field named `$field`, whatever its key's spelling: `[value]`, or `[]` when there is none.

private static fieldOf(mixed $value, string $field) : array<int, mixed>
Parameters
$value : mixed
$field : string
Return values
array<int, mixed>

fromNow()

A datetime's distance from now, in nanoseconds, given to `$test`; `$wanted` false asks nothing, and anything but a boolean refuses.

private static fromNow(mixed $value, mixed $wanted, callable(string): bool $test) : bool
Parameters
$value : mixed
$wanted : mixed
$test : callable(string): bool
Return values
bool

hasContent()

The string, decoded by its `encoding` when it has one, is a DXN document whose value is a `$type`: `.dxnb` under application/dxnb, text otherwise.

private static hasContent(self $type, array<string, mixed> $constraints, mixed $value, Context $ctx) : bool
Parameters
$type : self
$constraints : array<string, mixed>
$value : mixed
$ctx : Context
Return values
bool

hasOffsetIn()

Whether the datetime's offset, `Z` or `±HH:MM`, is one of `$offsets`.

private static hasOffsetIn(mixed $value, mixed $offsets) : bool
Parameters
$value : mixed
$offsets : mixed
Return values
bool

hasResolution()

Whether no part of a time, datetime, local date-time or duration is finer than `$unit`.

private static hasResolution(mixed $value, mixed $unit) : bool
Parameters
$value : mixed
$unit : mixed
Return values
bool

identity()

Two values are the same when their canonical forms are (DXN.md §1.5): `1` and `1.0` differ, as `name:` and `"name" =>` do. A value with no DXN meaning, an application's object, is compared as itself.

private static identity(mixed $value) : string
Parameters
$value : mixed
Return values
string

isMultipleOf()

Whether the number `$value` is an exact multiple of `$n`: two integers by their remainder, anything else by the floats' (which a zero, NaN or an infinity never is).

private static isMultipleOf(mixed $value, mixed $n) : bool
Parameters
$value : mixed
$n : mixed
Return values
bool

isNumber()

Whether `$value` is a number, NaN and the infinities included.

private static isNumber(mixed $value) : bool
Parameters
$value : mixed
Return values
bool

items()

`$particles` from the `$p`th matched against `$items` from the `$at`th, then `$rest` against the position they leave: the items conformed, in order, or {@see NoMatch}. A repeat takes as many items as it can while the rest still matches, and gives back one at a time until it does (DXNS.md §1a).

private static items(array<int, Particle> $particles, int $p, array<int, mixed> $items, int $at, Context $ctx, Warning: Array to string conversion in /opt/phpdoc/src/phpDocumentor/Transformer/Writer/Twig/LinkRenderer/CallableAdapter.php on line 87 callable(int): Array $rest) : array<int, mixed>|NoMatch
Parameters
$particles : array<int, Particle>
$p : int
$items : array<int, mixed>
$at : int
$ctx : Context
$rest : Warning: Array to string conversion in /opt/phpdoc/src/phpDocumentor/Transformer/Writer/Twig/LinkRenderer/CallableAdapter.php on line 87 callable(int): Array
Return values
array<int, mixed>|NoMatch

itemsOf()

A collection's items, `null` for a value that is none.

private static itemsOf(mixed $value) : array<int, mixed>|null
Parameters
$value : mixed
Return values
array<int, mixed>|null

keyName()

The name a map key gives a field, or `null`.

private static keyName(mixed $key) : string|null
Parameters
$key : mixed
Return values
string|null

lengthOf()

A string's, keyword's or symbol's length in codepoints; a byte string's in bytes, in bits under `:bits`; `null` for anything else.

private static lengthOf(mixed $value, self|null $base) : int|null
Parameters
$value : mixed
$base : self|null
Return values
int|null

mask()

The bits of `$allowed` that fall in the byte starting at bit `$from`, shifted down to it.

private static mask(array<string|int, mixed> $allowed, int $from) : int
Parameters
$allowed : array<string|int, mixed>

integers, checked by the caller

$from : int
Return values
int

matchesPattern()

Whether `$value` matches the regex `$re`: a name's text, or a byte string one character per byte -- its bytes as they are, or, for a pattern with the `u` flag, as the Latin-1 characters they are.

private static matchesPattern(mixed $value, mixed $re) : bool
Parameters
$value : mixed
$re : mixed
Return values
bool

matchesReference()

private static matchesReference(string $name, mixed $value, Registry|null $registry) : bool
Parameters
$name : string
$value : mixed
$registry : Registry|null
Return values
bool

nanosOf()

A time's, datetime's, local date-time's or duration's nanoseconds, the part a resolution looks at; `null` for anything else.

private static nanosOf(mixed $value) : int|null
Parameters
$value : mixed
Return values
int|null

nativeOrdinal()

A native datetime's place, `null` past 64 bits of nanoseconds.

private static nativeOrdinal(DateTimeInterface $value) : array{0: string, 1: int}|null
Parameters
$value : DateTimeInterface
Return values
array{0: string, 1: int}|null

nowNanos()

The time of the check, as nanoseconds since 1970, a decimal string.

private static nowNanos() : numeric-string
Return values
numeric-string

numeric()

An integer, or a big one's digits, as the numeric string bcmath takes.

private static numeric(int|float|string $n) : numeric-string
Parameters
$n : int|float|string
Return values
numeric-string

onlyBits()

Whether only the bits numbered in `$allowed` are set (RFC 8610's `.bits`): a non-negative integer's from its lowest, a byte string's from its first byte's lowest. Both are read as bytes, the integer's lowest first.

private static onlyBits(mixed $value, mixed $allowed) : bool
Parameters
$value : mixed
$allowed : mixed
Return values
bool

ordinal()

A value as its kind and its place in that kind's order: a number (an integer exactly, as an int or a big one's digits; anything else as a float, NaN and the infinities included), or a date, time, datetime, local date-time or duration as a count of days or nanoseconds. A duration with years or months has no place: their length varies. `null` for a value of no ordered kind.

private static ordinal(mixed $value) : array{0: string, 1: int|float|string}|null
Parameters
$value : mixed
Return values
array{0: string, 1: int|float|string}|null

orNull()

private static orNull(string|false $bytes) : string|null
Parameters
$bytes : string|false
Return values
string|null

precision()

A decimal's coefficient's digit count, as written; `null` for anything else.

private static precision(mixed $value) : int|null
Parameters
$value : mixed
Return values
int|null

primitiveMatches()

private static primitiveMatches(string $name, mixed $value) : bool
Parameters
$name : string
$value : mixed
Return values
bool

read()

What `$decode` reads, or `null` when it fails: a document that does not read is content of no type, never an error of the check.

private static read(callable(): array<int, mixed> $decode) : array<int, mixed>|null
Parameters
$decode : callable(): array<int, mixed>
Return values
array<int, mixed>|null

repeat()

One more repetition first, while `$most` allows it; stopping once `$least` is reached. A repetition that took no item is the last: every further one would take none either, so `$least` is met by them.

private static repeat(array<int, Particle> $group, int $least, int|null $most, array<int, mixed> $items, int $at, Context $ctx, Warning: Array to string conversion in /opt/phpdoc/src/phpDocumentor/Transformer/Writer/Twig/LinkRenderer/CallableAdapter.php on line 87 callable(int): Array $rest) : array<int, mixed>|NoMatch
Parameters
$group : array<int, Particle>
$least : int
$most : int|null
$items : array<int, mixed>
$at : int
$ctx : Context
$rest : Warning: Array to string conversion in /opt/phpdoc/src/phpDocumentor/Transformer/Writer/Twig/LinkRenderer/CallableAdapter.php on line 87 callable(int): Array
Return values
array<int, mixed>|NoMatch

satisfiesConstraint()

One refine key against `$value` (DXNS.md §2). NaN lies outside every range, as every IEEE 754 comparison with it is false; the infinities compare as the numbers they are (Jan, 2026-10-20).

private static satisfiesConstraint(string $key, mixed $arg, mixed $value) : bool

Dates, times and durations compare with their own kind.

Parameters
$key : string
$arg : mixed
$value : mixed
Return values
bool

satisfiesConstraints()

Every constraint holds. A constraint on a value it does not apply to -- a length on an integer, a range on a string -- refuses it (DXNS.md §2, Jan, 2026-10-20). `$base` is the type refined, which says whether a length counts bytes or bits.

private static satisfiesConstraints(mixed $value, array<string, mixed> $constraints, self|null $base, Context $ctx) : bool
Parameters
$value : mixed
$constraints : array<string, mixed>
$base : self|null
$ctx : Context
Return values
bool

utf8Size()

A string's, keyword's or symbol's UTF-8 byte count; `null` for anything else.

private static utf8Size(mixed $value) : int|null
Parameters
$value : mixed
Return values
int|null

within()

Whether `$count` lies between `$least` and `$most`, either `null` for no bound; a `null` count, of a value that has none, never does, nor does a bound that is no number.

private static within(int|null $count, mixed $least, mixed $most) : bool
Parameters
$count : int|null
$least : mixed
$most : mixed
Return values
bool

withinOfNow()

Whether a datetime is no further from now than the duration `$span`, either way.

private static withinOfNow(mixed $value, mixed $span) : bool
Parameters
$value : mixed
$span : mixed
Return values
bool
On this page

Search results