StoredObjects final class
Minn\Runtime\StoredObjects · public/minn/src/Minn/Runtime/StoredObjects.php · 140 lines
The classes a stored blob may name and come back as. The serialized reader never instantiates by itself; the facade registers one factory per value class it owns (WP_Post, WP_Term, WP_Comment), and any other class comes back as itself only when it is plain data: a class that exists, written in PHP, that runs nothing as it is revived or let go (no __wakeup, __unserialize, __destruct or __set, not Serializable), so no stored blob can make code run (PHP object injection). Plugins keep settings in such objects (WooCommerce PayPal Payments does) and read them back typed, as the reference revives them. Anything else stays a stdClass of its properties.
Constants and properties
| private | WRAPPERS = array ( 'arrayobject' => 'ArrayObject', 'arrayiterator' => 'ArrayIterator', 'recursivearrayiterator' => 'RecursiveArrayIterator', ) | PHP's array wrappers a stored record may name, by lower-cased class name. |
| private | static array $factories |
Public
| static | maybeDecode(mixed $data): mixed# | A stored value read back (maybe_unserialize): serialized data decoded, its objects revived by the registered factories; anything else, or data that does not decode, as given. |
| static | register(string $class, Closure $factory): void# | Registers what a record naming this class becomes. |
| static | reviver(): Closure# | The reviver the serialized reader takes: PHP's array wrappers rebuilt, a factory's object, a plain data object, or the properties as they are. |
| static | knows(string $class): bool# | Whether a factory is registered for the class. |
| static | reset(): void# | Forgets every factory, for suites. |
Internals 3
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | plain(string $class, array $pairs): ?object# | A plain data object revived from its stored properties, as PHP's own reader would, without its constructor: each property set in the scope of the class that declares it (a parent's private one by its owner's name, a readonly one where it may be initialized). Null for a class that is not plain data, for the engine's own classes, or when a value does not fit a typed property.
| |||
| private | owner(ReflectionClass $reflection, string $raw): array# | The class whose scope sets a stored property, and the property's name: "\0Owner\0name" is Owner's private one, "\0*\0name" a protected one, any other name the class's own (or a parent's, where it is declared). @return array{0: string, 1: string} | |||
| private | arrayWrapper(string $class, stdClass $properties): ?object# | PHP's own array wrappers, stored as their four numbered parts (flags, storage, member properties, iterator class), rebuilt through their constructors so nothing else runs. Plugins keep settings in them (CleanTalk does), and the reference reads them back as the real class; written back, they serialize to the same bytes. One wrapping an object, or carrying member properties, stays a record of its parts.
|
Nothing matches.