Equality
in package
Shared structural equality/ordering kernel backing every DXN value, native and wrapped alike -- the PHP analog of the JS port's `src/values/equality.cjs`. `kindOf()` dispatches on {@see DXNValueInterface::dxnType()} for wrapped classes, PHP's own native types for scalars, `array_is_list()` to split `array`/`map`, and "any other object" (a plain object with public properties, `stdClass` or otherwise) as `struct` -- the encode-side convenience described in the project's own value-model mapping.
Cross-kind ordering is implementation-defined per dxn/DXN.md;
self::KIND_RANK is this port's own fixed choice, not
required to match the Elixir or JS ports' internal ordering.
Table of Contents
Constants
- KIND_RANK : mixed = ['nil' => 0, 'boolean' => 1, 'integer' => 2, 'f...
Methods
- canonicalKey() : string
- A stable, deterministic string encoding of `$value`'s full structure -- used for set/sorted-set dedup, and as the structural tie-break {@see self::dxnCompare()} falls back to for kinds with no more meaningful natural order.
- dxnCompare() : int
- dxnEquals() : bool
- kindOf() : string
- __construct() : mixed
- durationKey() : string
- flagsKey() : string
- floatEquals() : bool
- floatKey() : string
- listCompare() : int
- listEquals() : bool
- mapEquals() : bool
- mapKey() : string
- natOrCanonicalCompare() : int
- orderedItemsKey() : string
- orderedPairsKey() : string
- pairsCompare() : int
- plainObjectEquals() : bool
- structCompare() : int
- structKey() : string
- unorderedItemsKey() : string
Constants
KIND_RANK
private
mixed
KIND_RANK
= ['nil' => 0, 'boolean' => 1, 'integer' => 2, 'float' => 3, 'decimal' => 4, 'rational' => 5, 'string' => 6, 'char' => 7, 'symbol' => 8, 'keyword' => 9, 'list' => 10, 'tuple' => 11, 'map' => 12, 'ordered-map' => 13, 'set' => 14, 'sorted-set' => 15, 'struct' => 16, 'array' => 17, 'date' => 18, 'time' => 19, 'timestamp' => 20, 'datetime' => 21, 'duration' => 22, 'uuid' => 23, 'uri' => 24, 'bytes' => 25, 'regex' => 26, 'custom-tag' => 27]
Methods
canonicalKey()
A stable, deterministic string encoding of `$value`'s full structure -- used for set/sorted-set dedup, and as the structural tie-break {@see self::dxnCompare()} falls back to for kinds with no more meaningful natural order.
public
static canonicalKey(mixed $value) : string
Parameters
- $value : mixed
Return values
stringdxnCompare()
public
static dxnCompare(mixed $a, mixed $b) : int
Parameters
- $a : mixed
- $b : mixed
Return values
intdxnEquals()
public
static dxnEquals(mixed $a, mixed $b) : bool
Parameters
- $a : mixed
- $b : mixed
Return values
boolkindOf()
public
static kindOf(mixed $value) : string
Parameters
- $value : mixed
Return values
string__construct()
private
__construct() : mixed
durationKey()
private
static durationKey(DXNDuration $duration) : string
Parameters
- $duration : DXNDuration
Return values
stringflagsKey()
private
static flagsKey(array<string, bool> $flags) : string
Parameters
- $flags : array<string, bool>
Return values
stringfloatEquals()
private
static floatEquals(float $a, float $b) : bool
Parameters
- $a : float
- $b : float
Return values
boolfloatKey()
private
static floatKey(float $v) : string
Parameters
- $v : float
Return values
stringlistCompare()
private
static listCompare(array<int, mixed> $a, array<int, mixed> $b) : int
Parameters
- $a : array<int, mixed>
- $b : array<int, mixed>
Return values
intlistEquals()
private
static listEquals(array<int, mixed> $a, array<int, mixed> $b) : bool
Parameters
- $a : array<int, mixed>
- $b : array<int, mixed>
Return values
boolmapEquals()
private
static mapEquals(array<int|string, mixed> $a, array<int|string, mixed> $b) : bool
Parameters
- $a : array<int|string, mixed>
- $b : array<int|string, mixed>
Return values
boolmapKey()
private
static mapKey(array<int|string, mixed> $map) : string
Parameters
- $map : array<int|string, mixed>
Return values
stringnatOrCanonicalCompare()
private
static natOrCanonicalCompare(mixed $a, mixed $b) : int
Parameters
- $a : mixed
- $b : mixed
Return values
intorderedItemsKey()
private
static orderedItemsKey(array<int, mixed> $items) : string
Parameters
- $items : array<int, mixed>
Return values
stringorderedPairsKey()
private
static orderedPairsKey(array<int, array{0: mixed, 1: mixed}> $pairs) : string
Parameters
- $pairs : array<int, array{0: mixed, 1: mixed}>
Return values
stringpairsCompare()
private
static pairsCompare(array<int, array{0: mixed, 1: mixed}> $a, array<int, array{0: mixed, 1: mixed}> $b) : int
Parameters
- $a : array<int, array{0: mixed, 1: mixed}>
- $b : array<int, array{0: mixed, 1: mixed}>
Return values
intplainObjectEquals()
private
static plainObjectEquals(object $a, object $b) : bool
Parameters
- $a : object
- $b : object
Return values
boolstructCompare()
private
static structCompare(DXNStruct $a, mixed $b) : int
Parameters
- $a : DXNStruct
- $b : mixed
Return values
intstructKey()
private
static structKey(DXNStruct $struct) : string
Parameters
- $struct : DXNStruct
Return values
stringunorderedItemsKey()
private
static unorderedItemsKey(array<int, mixed> $items) : string
Parameters
- $items : array<int, mixed>