This attribute is used to alter the serialization process.
#[Attribute(8)]
class MMO\core\attributes\Serialize
Namespace
MMO\core\attributes
NOTE: By default, all the properties of an object are serialized.
the serialized and unserialized properties allow to:
- if false: won't serialize/unserialize data
- if null: use instance property
- if a string: use the public method to get/set the property
function unserialize(mixed $value): void
function serialize(array $options): mixed. You don't need to serialize inner values, the serialization will do it.
The order is used to order the priority of properties. It is done in ascending order.
#[Serialize(false)] protected array $cachedStuff = []; // never serialized/unserialized
#[Serialize(null, 'setLanguage')] protected string $lang = ''; // read directly, written via setLanguage()
#[Serialize(serialize: 'getPaths', unserialize: 'setPaths', order: -100)] protected array $paths = []; // both custom, applied first