Contract for objects that round-trip the registry cache.
The registry cache serialises to a plain PHP array file. An object placed in
that array would otherwise be flattened to its class name by the cache
writer's get_class() fallback — a silent, lossy degradation: a wrong value
wearing the right shape, found only at runtime under cache (the F11 class of
bug, surfaced by SlotCatalogEntry, the first non-Module/Artifact DTO put
through the cache).
A cacheable DTO implements this contract so the cache writer serialises it structurally via {@see toCache()} and the reader rebuilds it via {@see fromCache()} — instead of relying on a hardcoded type whitelist, and instead of each consumer hand-rolling the (de)serialisation per DTO.
Implementations MUST be lossless — fromCache($x->toCache()) reconstructs an
equivalent object — and {@see toCache()} MUST return only cache-safe values
(scalars and nested arrays of scalars; no objects, closures, or resources).
| Methods | ||
|---|---|---|
public
|
toCache(): array<string, mixed>
|
# |
public
static
|
fromCache(array<string, mixed> $data): static
|
# |