MMO\core\arrays
MMO\core\arrays · 21 symbols · generated 5 Oct 2026
count
arrays.php:454Get the number of elements in any iterable (not just a plain array/\Countable) -- for a plain \Iterator without \Countable, this has to fully traverse it (there's no shortcut).
- Namespace
MMO\core\arrays
| $array | Traversable | Countable | array | |
| returns | int |
delete
arrays.php:289Delete the value at the given json-path. If the immediate parent is a list (sequential int keys), the item is spliced out (so later items shift down); otherwise the key is just unset. Any iMutationObserver walked along the path is notified (mutate('-', ...)), innermost first. A missing path is silently a no-op.
- Namespace
MMO\core\arrays
| $src | ArrayAccess | array | |
| $path | array | string | a json-path string, or an already-split array of segments |
| returns | mixed | the value that was removed, or null if $path didn't exist |
Call graph
Used by (1)
diff
arrays.php:475Get the elements of $a whose value is not (strictly) present anywhere in $b -- like \array_diff(), but using strict (===) comparison instead of string-casting comparison, so it works correctly with non-scalar values too. $a's keys are preserved.
- Namespace
MMO\core\arrays
exists
arrays.php:222Tells if a value exists at the given json-path (without fetching it).
- Namespace
MMO\core\arrays
| $src | ArrayAccess | array | |
| $path | array | string | |
| returns | bool |
Call graph
Uses (1)
Used by (1)
filterKeys
arrays.php:94Filter (and, in select mode, reorder) an array's keys recursively.
- Namespace
MMO\core\arrays
| $data | array | the data to filter |
| $fields | array | {path} => {visibility} (a nested path uses /, e.g. 'b/b') |
| $path = '' | string | the current path in the data (internal, for the recursive call). MUST end with / if not empty. |
| returns | array |
Call graph
Uses (1)
Used by (1)
from
arrays.php:33Convert any value into a plain array: an \MMO\core\interfaces\iArray is unwrapped via toArray(), a Generator/Traversable is consumed via \iterator_to_array(), a plain array is returned as-is, and anything else is wrapped as a single-element array (if $force) or rejected.
- Namespace
MMO\core\arrays- See
https://www.php.net/manual/en/language.generators.syntax.php)
| $array | mixed | |
| $force = true | bool | if true (default), a value that isn't array-like is wrapped as [$array] instead of throwing |
| $preserveKeys = null | null | bool | only used when $array is a Generator/Traversable. WARNING: only set this to true when yielding WITH explicit keys. Otherwise values may be lost, since consecutive yields would share the same auto-incremented keys (this is why Generator defaults to false here but a plain Traversable defaults to true -- |
| returns | array | |
| throws | if the value cannot be converted and $force is false |
Call graph
Used by (1)
get
arrays.php:202Get a value at the given json-path.
- Namespace
MMO\core\arrays
| $src | ArrayAccess | array | |
| $path | array | string | |
| $default = null | mixed | returned when $path (or its leaf) doesn't exist -- but see the WARNING above |
| returns | mixed | |
| throws | when a path parent cannot be accessed, or (if $default wasn't passed at all) when the leaf doesn't exist either |
Call graph
Uses (1)
Used by (22)
- Configuration::createInstance
- PackageManager::readManifest
- inject
- mergeAt
- aEntity::get
- aEntity::getArrayProperty
- aEntity::traitSetArrayProperty
- aEntity::traitToArray
- aRepository::onFetch
- tArrayProperties::getArrayProperty
- tArrayProperties::setArrayProperty
- tArrayProperties::toArray
- RepositoryController::routePatch
- Collection::executeFilter
- Importer::ignore
- Importer::loopData
- JsonRepository::onFetch
- Query::applySort
- Container::get
- Filter::test
- FilterPath::getValue
- renderTemplate
inject
arrays.php:575Inject a configuration into $src recursively: every key of $config is itself a json-path into $src, and its value is set() (recursively merge()d with whatever's already there, by default) at that path.
- Namespace
MMO\core\arrays
| $src | ArrayAccess | array | |
| $config | iterable | the configuration to inject into $src |
| $recursive = true | bool | if false, every entry replaces outright instead of merging (like a global = prefix) |
| returns | void |
isUnique
arrays.php:694Tells if every value in $array is distinct (strict, ===, comparison).
- Namespace
MMO\core\arrays
Call graph
Uses (1)
Used by (1)
keys
arrays.php:431Get the keys of any iterable (not just a plain array) as a plain array.
- Namespace
MMO\core\arrays
| $array | iterable | |
| returns | array | |
| throws | if $array is an iArray/array/IteratorAggregate/Iterator none of the above |
matchMask
arrays.php:500- Namespace
MMO\core\arrays
| $mask | array | |
| $value | ArrayAccess | array | |
| $matches = null | null | array | |
| $schemas = null | null | array | a list of schemas to use for the type in placeholders. if null, use the global schemas |
| returns | string | true | true if it matches, else the mask key that failed |
Call graph
Uses (3)
Used by (2)
merge
arrays.php:388Recursively merge $value into $src: for matching keys whose values are themselves both array-like, merge recursively; otherwise $value's value simply overwrites $src's. Two plain lists (sequential int keys) are concatenated (if $appendList) rather than merged key-by-key -- otherwise merging [1,2,3] with [9] would overwrite index 0 instead of appending. Notifies iMutationObserver::mutate('=', ...) for every value actually changed, if $src implements it.
- Namespace
MMO\core\arrays
| $src | ArrayAccess | array | source value (NOT modified if it's a plain array; IS modified in place if it's an ArrayAccess, since arrays are always copied on write but objects aren't) |
| $value | iterable | the data to merge into $src |
| $appendList = true | bool | if false, two lists are merged key-by-key (index 0 with index 0, ...) instead of concatenated |
| returns | ArrayAccess | array | is array ? array<mixed> : ArrayAccess<mixed, mixed>) $src, merged (the same kind it was given) |
Call graph
Uses (1)
Used by (31)
- Application::DefaultConfig
- Application::addInfo
- Application::api
- matchMask
- merge
- mergeAt
- APIRoute::addAPIParameter
- APIRoute::addInfo
- APIRoute::addOptions
- APIRoute::api
- aConverter::addOptions
- aConverter::call
- aEntity::ArrayProperties
- aRequest::withAttributes
- tArrayProperties::ArrayProperties
- tWithOptions::addOptions
- Document::addContent
- Document::addMeta
- Document::addOptions
- Query::addOptions
- Query::execute
- Commit::addOptions
- Create::addOptions
- DocumentRender::addOptions
- Fetch::addOptions
- XmlNodes::__construct
- Schema::setContent
- Curl::addOptions
- Curl::exec
- Curl::handleCurlHeader
- Route::addMiddlewareParameters
mergeAt
arrays.php:419Same as merge(), but merges $value into whatever is already at $path (instead of into $src itself), then writes the result back with set().
- Namespace
MMO\core\arrays
| $src | ArrayAccess | array | |
| $path | string | a json-path |
| $value | mixed | the data to merge in at $path |
| $appendList = true | bool | merge() |
| returns | void |
mergeInject
arrays.php:636A shallow, synchronous cousin of inject(): recursively merge $config into $src and return the result (rather than mutating a reference and honoring the ?/= path-prefix directives), understanding the same $[..] list-splicing placeholder. Useful to pre-merge several config sources into one plain array before actually applying it (e.g. with inject() or set()) later.
- Namespace
MMO\core\arrays
Call graph
Uses (1)
Used by (2)
options
arrays.php:51The options array behind $options: a typed options object (iOptions) gives its toArray(), an array is returned as it is. What accepts both calls this first.
- Namespace
MMO\core\arrays
push
arrays.php:335Append a value to the list at the given json-path (turning a non-list scalar/null already there into a single-element list first, so it can be appended to). Any iMutationObserver walked along the path is notified (mutate('+', ...)), innermost first.
- Namespace
MMO\core\arrays
| $src | ArrayAccess | array | |
| $path | array | string | a json-path string, or an already-split array of segments |
| $value | mixed | the value to push |
| $unique = false | bool | if true, don't push if $value is already present (strict comparison) |
| $create = true | bool | if false, don't create missing intermediate path items (walk()) |
| returns | ArrayAccess | array | a reference to the list $value was pushed into (or would have been, if $unique skipped it), so the caller can keep working with it directly |
Call graph
set
arrays.php:253Set a value at the given json-path, creating missing intermediate arrays by default.
- Namespace
MMO\core\arrays
| $src | ArrayAccess | array | |
| $path | array | string | a json-path string, or an already-split array of segments |
| $value | mixed | the value to set |
| $create = true | bool | if true (default), a missing intermediate array along the path is created |
| returns | void | |
| throws | if $path is empty (there's nothing to assign the value to) |
Call graph
sortPreserve
arrays.php:69Sort an array in place using $sortFn, like \uasort()/\uksort(), but stable: when two items are equivalent ($sortFn returns 0), their original relative order is preserved instead of being left unspecified.
- Namespace
MMO\core\arrays
| $array | array | |
| $sortFn | callable | a comparator: function(mixed $a, mixed $b): int, called with values (or, if $byKeys, with keys) from $array |
| $reverse = false | bool | if true, ties ($sortFn returns 0) are ordered by REVERSE original order instead of original order |
| $byKeys = false | bool | if true, $sortFn receives the two KEYS being compared instead of their values |
| returns | void |
Call graph
Used by (21)
- Application::getJobs
- aMessage::GetListeners
- tEvent::GetListeners
- tException::GetListeners
- RepositoryController::routeGet
- LogQuery::GetListeners
- MailLog::GetListeners
- Query::GetListeners
- Query::applySort
- DocumentInit::GetListeners
- DocumentRender::GetListeners
- Event::GetListeners
- Log::GetListeners
- eDeprecated::GetListeners
- eInvalid::GetListeners
- eLogic::GetListeners
- eRuntime::GetListeners
- scanFolder
- TokenDomain::updateMask
- XMLElement::reorderNodes
- Route::sortMiddlewares
uniqueList
arrays.php:660Merge one or more iterables and keep only the first occurrence of each (strictly, ===) distinct value, re-indexed as a plain list (original keys are discarded).
- Namespace
MMO\core\arrays
Call graph
uniqueMap
arrays.php:676Same as uniqueList(), but preserves the (first-seen) key of each distinct value instead of re-indexing.
- Namespace
MMO\core\arrays
walk
arrays.php:155The low-level primitive get()/exists()/set()/delete()/push() are all built on: walk down a json-path (/-separated, RFC-6902-escaped -- split()) through nested arrays/ArrayAccess objects, yielding each step so the caller can inspect or mutate it along the way.
- Namespace
MMO\core\arrays
| $src | ArrayAccess | array | |
| $path | array | string | a json-path string, or an already-split array of segments |
| $create = false | bool | if true, a missing intermediate array along the path is created (as []) instead of making the walk stop early |
| returns | Generator | must be consumed with foreach |
| throws | if a non-final path segment leads into something that isn't an array/ArrayAccess (and $create didn't apply, e.g. because it's not null but some other scalar) |