php-dextrin

DXNStruct
in package
implements DXNValueInterface

FinalYes

DXN `struct` (`%Name{...}` / `%Name[...]`), opaque without a schema. Keeps the keyed/positional shapes distinct rather than normalizing to one, same as the Elixir and JS ports -- `.dxnb` is always positional and can't recover field names without a schema.

This is decode's default representation for an unregistered struct name; on encode, any plain PHP object with public properties is also accepted directly (see Equality::kindOf()) without needing to be built into a DXNStruct by hand first.

Tags
phpstan-type

Pair array{0: string, 1: mixed}

Table of Contents

Interfaces

DXNValueInterface
Implemented by every `DXN*` wrapper class -- the PHP analog of the `dxnType` string tag used for kind dispatch in the JS port, and of `Dextrin.Value`'s closed type union in the Elixir original. Native PHP values (`null`, `bool`, `int`, `float`, `string`, and `array` for `map`/`array`) never implement this; {@see Equality::kindOf()} handles those directly.

Constants

DXN_TYPE  : mixed = 'struct'

Properties

$kind  : string
$name  : string
$pairs  : array<int, Pair>
$values  : array<int, mixed>

Methods

compareTo()  : int
A total order against any other DXN value, not just another instance of this class -- backs {@see DXNSortedSet}. Cross-kind ordering is implementation-defined per DXN.md; within a kind, uses the kind's own natural order where one exists, or a deterministic structural fallback where it doesn't.
dxnType()  : string
The DXN type name this value represents, e.g. "symbol", "uuid".
equals()  : bool
Structural equality, recursing into nested DXN values as needed.
isKeyed()  : bool
isPositional()  : bool
keyed()  : self
pairs()  : array<int, Pair>
positional()  : self
values()  : array<int, mixed>
__construct()  : mixed

Constants

Properties

$pairs read-only

private array<int, Pair> $pairs

$values read-only

private array<int, mixed> $values

Methods

compareTo()

A total order against any other DXN value, not just another instance of this class -- backs {@see DXNSortedSet}. Cross-kind ordering is implementation-defined per DXN.md; within a kind, uses the kind's own natural order where one exists, or a deterministic structural fallback where it doesn't.

public compareTo(mixed $other) : int
Parameters
$other : mixed
Return values
int

dxnType()

The DXN type name this value represents, e.g. "symbol", "uuid".

public dxnType() : string
Return values
string

equals()

Structural equality, recursing into nested DXN values as needed.

public equals(mixed $other) : bool
Parameters
$other : mixed
Return values
bool

isKeyed()

public isKeyed() : bool
Return values
bool

isPositional()

public isPositional() : bool
Return values
bool

keyed()

public static keyed(string $name, array<string|int, Pair$pairs) : self
Parameters
$name : string
$pairs : array<string|int, Pair>
Return values
self

pairs()

public pairs() : array<int, Pair>
Return values
array<int, Pair>

positional()

public static positional(string $name, array<string|int, mixed> $values) : self
Parameters
$name : string
$values : array<string|int, mixed>
Return values
self

values()

public values() : array<int, mixed>
Return values
array<int, mixed>

__construct()

private __construct(string $name, string $kind, array<int, Pair$pairs, array<int, mixed> $values) : mixed
Parameters
$name : string
$kind : string
$pairs : array<int, Pair>
$values : array<int, mixed>
On this page

Search results