Index

ShellArguments

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

class

ShellArguments

ShellRequest.php:17

Parsed command-line arguments (options/flags), as used by ShellRequest's body.

class MMO\core\server\ShellArguments implements MMO\core\interfaces\iArray, JsonSerializable, Stringable use MMO\core\classes\tArray
Namespace
MMO\core\server
Implements
iArray, JsonSerializable, Stringable
Uses traits
tArray
$args = new ShellArguments('-x --name=bar'); $args->getOption('name'); // 'bar' $args->hasOptions('x'); // true

Index

content
clear()Empty the underlying content, keeping the object itself.
count()\Countable::count
getIterator()\IteratorAggregate::getIterator
getOption($opt, $default, $key)
hasOptions($opts)Test if request as options set.
isEmpty()
jsonSerialize()
keys()
loadArray($data)Load every entry of a plain array into the content, through offsetSet (so any offsetSet() override defined by the class using this trait, e.g.
offsetExists($key)\ArrayAccess::offsetExists
offsetGet($key)\ArrayAccess::offsetGet
offsetSet($key, $value)\ArrayAccess::offsetSet -- a null $key appends ($bag[] = $value), like a plain PHP array.
offsetUnset($key)\ArrayAccess::offsetUnset -- on a list (sequential integer keys, as produced by $bag[] = ...), the element is spliced out (closing the gap and reindexing), matching \unset() semantics on a plain …
setContent($args)
toArray()Convert the content to a plain array, recursively converting any nested iArray value (e.g.
__construct($args)
__toString()

Properties1

content

protected $content = []

Methods17

clear()

tArray.php:25

Empty the underlying content, keeping the object itself.

function clear()
returns
$bag->clear(); // count($bag) === 0 afterwards

getOption($opt, $default, $key)

ShellRequest.php:39
function getOption(array|string $opt, mixed $default = null, ?string &$key = null): mixed
$optarray | stringan option name, or a list of alternative names (the first one present wins).
$default = nullmixedreturned if none of $opt is set.
$key = nullnull | string
returnsmixedthe option's value (true for a bare flag), or $default.

hasOptions($opts)

ShellRequest.php:66

Test if request as options set.

function hasOptions(...$opts): boolIt tests for all arguments with AND. If you pass an array as argument, it will use OR in this array.
...$optscan be a string or an array (treated as or).
returnsbool[description]
hasOptions('o','options') -> -o AND --optionshasOptions(['o','options'],'x') -> (-o OR --options) AND -x

isEmpty()

tArray.php:33
function isEmpty()
returnstrue if the underlying content has no elements
$bag->isEmpty(); // true right after clear(), false as soon as an item is set

keys()

tArray.php:82
function keys(): array
returnsarraythe list of keys currently set
$bag->keys(); // e.g. ['x', 0]

loadArray($data)

tArray.php:71

Load every entry of a plain array into the content, through offsetSet (so any offsetSet() override defined by the class using this trait, e.g. for validation or type coercion, is honored for every entry).

function loadArray(array $data): static
$dataarray
returnsstatic$this, for chaining
$bag->loadArray(['x' => 1, 'y' => 2]); // equivalent to $bag['x'] = 1; $bag['y'] = 2;

offsetExists($key)

tArray.php:130

\ArrayAccess::offsetExists

function offsetExists(mixed $key): bool
$keymixed
returnsbool

offsetSet($key, $value)

tArray.php:122

\ArrayAccess::offsetSet -- a null $key appends ($bag[] = $value), like a plain PHP array.

function offsetSet(mixed $key, mixed $value): void
$keymixed
$valuemixed
returnsvoid

offsetUnset($key)

tArray.php:107

\ArrayAccess::offsetUnset -- on a list (sequential integer keys, as produced by $bag[] = ...), the element is spliced out (closing the gap and reindexing), matching \unset() semantics on a plain PHP list; on an associative array, the key is simply removed.

function offsetUnset(mixed $key): void
$keymixed
returnsvoid
unset($bag[0]); // on a list: every following index shifts down by one, like array_splice()

setContent($args)

ShellRequest.php:29
function setContent(array|string $args): void
$argsarray | stringa shell-style argument string/list of tokens (parsed via parse), or an already-parsed option map (assigned as-is).
returnsvoid

toArray()

tArray.php:56

Convert the content to a plain array, recursively converting any nested iArray value (e.g. another object using this same trait) into its own plain-array form as well.

function toArray(): array
returnsarray
$inner = new Bag(); $inner['a'] = 1; $outer = new Bag(); $outer['inner'] = $inner; $outer->toArray(); // ['inner' => ['a' => 1]] -- $inner is recursively expanded, not left as an object

__toString()

ShellRequest.php:80
function __toString(): string
returnsstringthe options re-serialized back into a shell argument string.