VALUE
VALUE = 'value'
The key a single serialized value is presented under.
A replay merges field maps, so a realm holding one unnamed value needs a name for it.
Encodes and decodes an operation's payload, per realm.
Most realms hold a map of named values and JSON describes them exactly. State and the key-value collections do not: they hold arbitrary PHP values, and a value that round-tripped through JSON would come back as a different type - an object as an array, an integer-keyed list as an object
Keeping both sides of that decision in one class is the point. The recorder and the replayer have to agree byte for byte, and a payload written by one release has to stay readable by every later one, so the choice cannot live in two places that can drift apart.
Objects are refused rather than reconstructed. Deserializing arbitrary classes out of a backup is how a restore becomes remote code execution, so no class is allowed through. A value that genuinely held an object comes back as unreadable, which makes the subject degraded and leaves the live value alone. Unknown beats incorrect, and a state key holding an object is a bug in whatever put it there.
SERIALIZED_REALMS = [\Drupal\strata\Journal\Realm::STATE, \Drupal\strata\Journal\Realm::KEY_VALUE] : array<int, <a href="classes/Drupal-strata-Journal-Realm.html"><abbr title="\Drupal\strata\Journal\Realm">Realm</abbr></a>>
Realms whose payload is one arbitrary PHP value rather than a map of fields.
encode(\Drupal\strata\Journal\Realm $realm, mixed $value) : string
Encodes a value for storage.
| \Drupal\strata\Journal\Realm | $realm | The realm the operation belongs to. |
| mixed | $value | A field map for most realms; any value for state and key-value. |
When a JSON realm holds a string that is not valid UTF-8. (string) false would otherwise
store an empty payload that decodes to NULL, so the operation would claim to carry a value
it does not.
The payload bytes.
decode(\Drupal\strata\Journal\Realm $realm, string $payload) : array<string,mixed>|null
Decodes a payload back to the field map a replay merges.
| \Drupal\strata\Journal\Realm | $realm | The realm the operation belongs to. |
| string | $payload | The stored bytes. |
The field map, or NULL when the payload does not decode to one. A realm holding a single value presents it under PayloadCodec::VALUE.
unserializeValue(string $payload) : array<string,mixed>|null
Unserializes one stored value, refusing anything holding an object.
| string | $payload | The stored bytes. |
The value under PayloadCodec::VALUE, or NULL when it cannot be reconstructed faithfully.
holdsObject(mixed $value, int $depth = 0) : bool
Whether a decoded value contains a class that was refused.
| mixed | $value | The decoded value. |
| int | $depth | Recursion guard, since a stored value can nest arbitrarily. |
TRUE when anything in it came back as an incomplete class.