php-dextrin

Equality
in package

FinalYes

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
string

dxnCompare()

public static dxnCompare(mixed $a, mixed $b) : int
Parameters
$a : mixed
$b : mixed
Return values
int

dxnEquals()

public static dxnEquals(mixed $a, mixed $b) : bool
Parameters
$a : mixed
$b : mixed
Return values
bool

kindOf()

public static kindOf(mixed $value) : string
Parameters
$value : mixed
Return values
string

__construct()

private __construct() : mixed

flagsKey()

private static flagsKey(array<string, bool> $flags) : string
Parameters
$flags : array<string, bool>
Return values
string

floatEquals()

private static floatEquals(float $a, float $b) : bool
Parameters
$a : float
$b : float
Return values
bool

floatKey()

private static floatKey(float $v) : string
Parameters
$v : float
Return values
string

listCompare()

private static listCompare(array<int, mixed> $a, array<int, mixed> $b) : int
Parameters
$a : array<int, mixed>
$b : array<int, mixed>
Return values
int

listEquals()

private static listEquals(array<int, mixed> $a, array<int, mixed> $b) : bool
Parameters
$a : array<int, mixed>
$b : array<int, mixed>
Return values
bool

mapEquals()

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
bool

mapKey()

private static mapKey(array<int|string, mixed> $map) : string
Parameters
$map : array<int|string, mixed>
Return values
string

natOrCanonicalCompare()

private static natOrCanonicalCompare(mixed $a, mixed $b) : int
Parameters
$a : mixed
$b : mixed
Return values
int

orderedItemsKey()

private static orderedItemsKey(array<int, mixed> $items) : string
Parameters
$items : array<int, mixed>
Return values
string

orderedPairsKey()

private static orderedPairsKey(array<int, array{0: mixed, 1: mixed}> $pairs) : string
Parameters
$pairs : array<int, array{0: mixed, 1: mixed}>
Return values
string

pairsCompare()

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
int

plainObjectEquals()

private static plainObjectEquals(object $a, object $b) : bool
Parameters
$a : object
$b : object
Return values
bool

structCompare()

private static structCompare(DXNStruct $a, mixed $b) : int
Parameters
$a : DXNStruct
$b : mixed
Return values
int

unorderedItemsKey()

private static unorderedItemsKey(array<int, mixed> $items) : string
Parameters
$items : array<int, mixed>
Return values
string
On this page

Search results