Index

aExporter

MMO\core\classes · 1 symbol · generated 5 Oct 2026

class

aExporter

aExporter.php:20

An aConverter specialized for exporting arbitrary PHP values (objects, arrays, enums) into a plain, serializable structure -- recursively, with automatic cycle detection (an object seen more than once in the same export is replaced by its own hash the second time, instead of causing infinite recursion).

abstract class MMO\core\classes\aExporter extends MMO\core\classes\aConverter implements MMO\core\interfaces\iExporter
Namespace
MMO\core\classes
Extends
aConverter
Implements
iExporter
Built-in converters: 'instance' (any object, exported property-by-property via reflection, its static ones left out), 'array' (a list), 'object' (an associative array), 'enum'. Register additional per-class converters (via the setFunction/setFunctions of [`aConverter`](https://mcp.mmoframework.fr/documentation/mmo.core/php/classes/aConverter.md#aconverter)) to customize how specific classes are exported.
class MyExporter extends aExporter { public function hash(object $value, array $options = []): mixed {return spl_object_id($value);} } MyExporter::Export(new Point(1, 2)); // ['x' => 1, 'y' => 2], via reflection over Point's properties MyExporter::Export($selfReferencingObject); // the second occurrence becomes hash($obj) instead of looping forever

Index

Export($value, $options, $type) staticExport any value, dispatching to the right converter based on its type (or the explicit $type).
exportArray($value, $options)Built-in 'array' converter (a list): recursively exports every value, in place.
exportEnum($value, $options)Built-in 'enum' converter.
exportInstance($value, $options)Built-in 'instance' converter: exports every property of $value (including protected/private ones, via reflection) recursively, tracking each property's path in $options['path'] (e.g.
exportObject($value, $options)Built-in 'object' converter (an associative array): recursively exports every value, in place.
ExportProperties($value, $options) staticExport an object exportInstance method
exportsProperty($prop, $value)Whether exportInstance exports $prop of $value: not a static property -- it is the class's, not $value's -- nor an uninitialized one, which has no value (the properties (array)$value holds).
hash($value, $options) abstractCompute a stable identifier for $value, used to detect (and short-circuit) cycles during export: the second time the same object is encountered within one Export call, this hash is returned in…
resetHash($value, $options)Forget that $value was already seen, within the given $options['hashes'] tracking map: the next time $value is encountered in this same export, it is exported in full again instead of collapsing to…
__construct($config)Registers the built-in 'instance'/'array'/'object'/'enum' converters as defaults, letting any $config['functions'] supplied via the module's configuration override or add to them.
__invoke($value, $options, $type)The actual export entry point (also what iExporter's $exporter($value) calling convention invokes).

Methods11

Export($value, $options, $type)

staticaExporter.php:50

Export any value, dispatching to the right converter based on its type (or the explicit $type).

static function Export( mixed $value, MMO\core\interfaces\iOptions|array $options = [], ?string $type = null ): mixed
$valuemixed
$options = []iOptions | array
$type = nullnull | stringforce a specific converter type instead of auto-detecting it via aConverter::getType
returnsmixed
MyExporter::Export(['a' => 1, 'b' => [2, 3]]); // recursively exported, unchanged for plain scalars/arrays

exportArray($value, $options)

aExporter.php:185

Built-in 'array' converter (a list): recursively exports every value, in place.

function exportArray(array $value, array $options)
$valuearray
$optionsarray
returns

exportEnum($value, $options)

aExporter.php:115

Built-in 'enum' converter.

function exportEnum(UnitEnum $value, array $options)
$valueUnitEnum
$optionsarray
returnsthe enum case's name
$exporter->exportEnum(Color::Red, []); // 'Red'

exportInstance($value, $options)

aExporter.php:130

Built-in 'instance' converter: exports every property of $value (including protected/private ones, via reflection) recursively, tracking each property's path in $options['path'] (e.g. 'address/city') for converters further down that want to know where they are in the structure. Not every property: the ones that exportsProperty accepts (not the static ones).

function exportInstance(object $value, array $options): mixed
$valueobject
$optionsarray
returnsmixedproperty name => recursively exported value
$exporter->exportInstance($point, []); // ['x' => 1, 'y' => 2]$exporter->exportInstance(new Event('shop'), []); // ['origin' => 'shop']: not tEvent's static $Listeners

exportObject($value, $options)

aExporter.php:168

Built-in 'object' converter (an associative array): recursively exports every value, in place.

function exportObject(array $value, array $options)
$valuearray
$optionsarray
returns

ExportProperties($value, $options)

staticaExporter.php:38

Export an object exportInstance method

static function ExportProperties(object $value, array $options = []): array
$valueobject
$options = []array
returnsarray
MyExporter::ExportProperties($point); // ['x' => 1, 'y' => 2]

exportsProperty($prop, $value)

aExporter.php:158

Whether exportInstance exports $prop of $value: not a static property -- it is the class's, not $value's -- nor an uninitialized one, which has no value (the properties (array)$value holds). A subclass leaves out more.

protected function exportsProperty(ReflectionProperty $prop, object $value): boolNOTE: reflection lists the static properties too, and they were exported: an object printed by TextPrinter (HtmlPrinter, XmlPrinter...), encoded by JsonPrinter or put in a spreadsheet exported its class's caches and what they hold -- for an Event, tEvent's listeners, the application among them and its output stream, which HtmlPrinter read ("Bad file descriptor"): tens of KB. An uninitialized typed property threw ("must not be accessed before initialization"), which TextPrinter printed in place of the whole object.
$propReflectionPropertya property of $value's class
$valueobject
returnsbool
$this->exportsProperty(new \ReflectionProperty(Event::class, 'Listeners'), $event); // false: static

hash($value, $options)

abstractaExporter.php:29

Compute a stable identifier for $value, used to detect (and short-circuit) cycles during export: the second time the same object is encountered within one Export call, this hash is returned instead of re-exporting (and instead of recursing forever on a self-referencing structure).

abstract function hash(object $value, array $options = []): mixed
$valueobject
$options = []array
returnsmixednull to opt an object out of cycle-tracking entirely (it will always be fully re-exported)

resetHash($value, $options)

aExporter.php:101

Forget that $value was already seen, within the given $options['hashes'] tracking map: the next time $value is encountered in this same export, it is exported in full again instead of collapsing to its hash.

function resetHash(mixed $value, array $options = []): boolNOTE: although $options is passed by value, $options['hashes'] is a \WeakMap object -- object reference semantics mean this still mutates the SAME tracking map the caller (and any other recursive call sharing it) sees.
$valuemixed
$options = []arraymust contain the same 'hashes' \WeakMap that was used to export $value
returnsbooltrue if $value had actually been tracked (and is now forgotten)

__construct($config)

aExporter.php:60

Registers the built-in 'instance'/'array'/'object'/'enum' converters as defaults, letting any $config['functions'] supplied via the module's configuration override or add to them.

protected function __construct(array &$config)
$configarray

__invoke($value, $options, $type)

aExporter.php:79

The actual export entry point (also what iExporter's $exporter($value) calling convention invokes). Lazily creates $options['hashes'] (a \WeakMap) on the outermost call, and threads it through every recursive call so cycles are tracked across the whole export, not just one level.

function __invoke(mixed $value, array $options = [], ?string $type = null): mixed
$valuemixed
$options = []array
$type = nullnull | string
returnsmixed
Inherited members (61)
ConstantsDeclared byDescription
ALERTiLogLevelAlert: Action must be taken immediately.
ALLiLogLevelMask for all
ALL_PLUSiLogLeveldebug everything
BACKTRACEiLogLevel
CRITICALiLogLevelCritical: Critical conditions.
DEBUGiLogLevelDebug: Detailed debug information.
DEEPiLogLeveldebug everything with arguments
EMERGENCYiLogLevelEmergency: System is unusable.
ERRORiLogLevelError: Runtime errors that do not require immediate action but should typically be logged and monitored.
ERROR_PLUSiLogLevelMask for all error
FATALiLogLevelMask for all fatal error
INFOiLogLevelInfo: Interesting events.
INFO_PLUSiLogLevelMask for all errors/warning/notices/info
MEMORYiLogLevelinclude backtrace object
NOTICEiLogLevelNotice: Normal but significant events.
NOTICE_PLUSiLogLevelMask for all errors/warning/notices/info
TRACEiLogLevelinclude backtrace as origins
WARNINGiLogLevelWarning: Exceptional occurrences that are not errors.
WARNING_PLUSiLogLevelMask for all errors and warnings
PropertiesDeclared byDescription
functionsaConverter
globalOptionsaConverter
verbosityaModule
MethodsDeclared byDescription
addOptions($type, $options)aConverterMerge $options into $type's existing options (via merge), rather than replacing them wholesale like setOptions.
alert($message, $context)aModuleAction must be taken immediately.
backtraces($message, $context)aModuleForce-log a message at INFO level together with a full stack trace/memory snapshot (iLogLevel::BACKTRACE), bypassing the verbosity mask entirely (any non-zero verbosity is enough to trigger it).
call($type, $value, $options)aConverterCall the function associated to a type
clear()aConverterRemove every registered type/function.
Configure($config)aModuleMerge $config into this module's configuration in the shared Configuration.
critical($message, $context)aModuleCritical conditions. No-op if CRITICAL is currently filtered out by the verbosity mask.
debug($message, $context)aModuleDetailed debug information.
debugName()aModuleHuman-readable identifier used as the default {origin} in this instance's log messages.
DefaultConfig()aModuleThe config a module starts from before anything loaded via Configuration is merged in.
emergency($message, $context)aModuleSystem is unusable. No-op if EMERGENCY is currently filtered out by the verbosity mask.
error($message, $context)aModuleRuntime errors that do not require immediate action but should typically be logged and monitored.
getClassFunction($class)aConverterFind which registered type (a class or interface name) applies to $class: itself if directly registered, else the closest registered ancestor class or implemented interface.
getFunction($type)aConverter
getFunctions()aConverter
getOptions($type)aConverter
getType($value, $allowClass)aConverterNormalize $value's type into one of this converter's type names.
getVerbosity()aModule
hasType($type)aConverter
info($message, $context)aModuleInteresting events. No-op if INFO is currently filtered out by the verbosity mask.
Instantiate($config)aModule(Re)create the shared instance immediately, configured with $config merged into the class's existing config.
IsShared()aModule
log($level, $message, $context)aModuleLogs with an arbitrary level.
notice($message, $context)aModuleNormal but significant events.
offsetExists($key)aModule\ArrayAccess::offsetExists -- tells whether $key is a declared property at all, regardless of whether it is currently readable/writable through array access.
offsetGet($key)aModule\ArrayAccess::offsetGet -- reads a property directly, unless it has a #[Serialize(serialize: 'methodName')] attribute, in which case that zero-argument method is called instead (e.g.
offsetSet($key, $value)aModule\ArrayAccess::offsetSet -- sets a property directly, unless it has a #[Serialize(unserialize: 'methodName')] attribute, in which case that method is called with $value instead (e.g.
offsetUnset($key)aModule\ArrayAccess::offsetUnset -- equivalent to $module[$key] = null.
serialize($path, $serializer)aModule\MMO\core\interfaces\iSerializable::serialize -- exports every property (via
setFunction($type, $fn, $options)aConverterSet a coercer
setFunctions($fns)aConverterRegister many functions at once, e.g.
setOptions($type, $options)aConverterReplace $type's options wholesale.
setVerbosity($verb)aModuleSet the current verbosity mask, replacing whatever it was before.
Shared()aModuleGet the shared instance, creating (and configuring) it on first call.
testVerbosity($level)aModuleTest whether a given level (or set of levels) is currently enabled by this instance's verbosity mask.
traitUnshare($serialize)aModuleRemove the shared instance, so the next Shared() call creates a fresh one.
unserialize($data, $path, $instances)aModule\MMO\core\interfaces\iSerializable::unserialize -- merges $data onto DefaultConfig, runs it through the (possibly overridden) constructor, then applies each resulting value to its property (via
Unshare($serialize)aModuleLike tSingleton::Unshare, but also disconnects this module's instance from every event it was listening to (via Event::DisconnectListeners) before dropping it.
warning($message, $context)aModuleExceptional occurrences that are not errors.