php-dextrin

DXNMap
in package
implements DXNValueInterface, Countable, IteratorAggregate

FinalYes

A DXN map that a native PHP array cannot hold.

A map decodes to a native array whenever it can: every key an integer, a keyword or a string, no two of them colliding once PHP coerces them to array keys, and not shaped like a list (which would read back as a DXN array). Anything else -- a char, uuid, objectid, date, bytes or symbol key, 1 beside "1", an empty map -- is one of these.

Keys are compared by value (DXN.md ยง1.6): two keys are the same key exactly when their canonical forms are. A repeated key keeps its last value and its first key object.

Tags
implements

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.
Countable
IteratorAggregate

Constants

DXN_TYPE  : mixed = 'map'

Properties

$entries  : array<string, array{0: mixed, 1: mixed}>

Methods

__construct()  : mixed
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.
count()  : int
dxnType()  : string
The DXN type name this value represents, e.g. "symbol", "uuid".
equals()  : bool
Structural equality, recursing into nested DXN values as needed.
get()  : mixed
getIterator()  : Generator<mixed, mixed>
has()  : bool
pairs()  : array<int, array{0: mixed, 1: mixed}>

Constants

DXN_TYPE

private mixed DXN_TYPE = 'map'

Properties

$entries

private array<string, array{0: mixed, 1: mixed}> $entries = []

identity => [key, value]

Methods

__construct()

public __construct([iterable<string|int, array{0: mixed, 1: mixed}> $pairs = [] ]) : mixed
Parameters
$pairs : iterable<string|int, array{0: mixed, 1: mixed}> = []

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

count()

public count() : int
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

get()

public get(mixed $key[, mixed $default = null ]) : mixed
Parameters
$key : mixed
$default : mixed = null

getIterator()

public getIterator() : Generator<mixed, mixed>
Return values
Generator<mixed, mixed>

has()

public has(mixed $key) : bool
Parameters
$key : mixed
Return values
bool

pairs()

public pairs() : array<int, array{0: mixed, 1: mixed}>
Return values
array<int, array{0: mixed, 1: mixed}>
On this page

Search results