CRUDUI PHP API

Members
in package

FinalYes

The member rules that $ref, $patch and the composition orchestrator share: the layering of the members of one node, the shallow merge and the plain-object test (SPEC ยง5).

Table of Contents

Constants

UNDEFINED  : mixed = "\x00__compose_undefined__\x00"
Sentinel for "no $patch seen" or "key absent" (distinct from a present null value).

Methods

isPlainObject()  : bool
Objects are stdClass values or non-list PHP associative arrays.
layer()  : array<string, mixed>
Layer the members of a node in declaration order: a $ref lays its resolved base over the members declared before it, the members declared after it override that base, and a $patch overlays the result.
rebuild()  : array<string, mixed>|stdClass
Apply `$change` to the members of a plain object and return the result in the shape of the input: a stdClass stays a stdClass and an associative array stays an array.
shallowMerge()  : array<string, mixed>
Shallow merge { ...a, ...b }: b's keys override a's, b's new keys append. PHP array union (+) keeps the left value on a clash, so this assigns b over a. Insertion order follows a's order for shared keys, then b's new keys (the JS spread order).

Constants

UNDEFINED

Sentinel for "no $patch seen" or "key absent" (distinct from a present null value).

public mixed UNDEFINED = "\x00__compose_undefined__\x00"

Methods

isPlainObject()

Objects are stdClass values or non-list PHP associative arrays.

public static isPlainObject(mixed $v) : bool
Parameters
$v : mixed
Return values
bool

layer()

Layer the members of a node in declaration order: a $ref lays its resolved base over the members declared before it, the members declared after it override that base, and a $patch overlays the result.

public static layer(array<string, mixed> $node, callable(mixed): array<string, mixed> $resolveRef) : array<string, mixed>
Parameters
$node : array<string, mixed>
$resolveRef : callable(mixed): array<string, mixed>

resolves the value of a $ref

Return values
array<string, mixed>

rebuild()

Apply `$change` to the members of a plain object and return the result in the shape of the input: a stdClass stays a stdClass and an associative array stays an array.

public static rebuild(array<string, mixed>|stdClass $object, callable(array<string, mixed>): array<string, mixed> $change) : array<string, mixed>|stdClass
Parameters
$object : array<string, mixed>|stdClass
$change : callable(array<string, mixed>): array<string, mixed>
Return values
array<string, mixed>|stdClass

shallowMerge()

Shallow merge { ...a, ...b }: b's keys override a's, b's new keys append. PHP array union (+) keeps the left value on a clash, so this assigns b over a. Insertion order follows a's order for shared keys, then b's new keys (the JS spread order).

public static shallowMerge(array<string, mixed> $a, array<string, mixed> $b) : array<string, mixed>
Parameters
$a : array<string, mixed>
$b : array<string, mixed>
Return values
array<string, mixed>
On this page

Search results